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
DiamondDolphins
@openzeppelin/contracts/access/Ownable.sol
0x881018075d93573d581d129574cbff3c632daaea
Solidity
Ownable
abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
/** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */
NatSpecMultiLine
transferOwnership
function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); }
/** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://763a4f36c2c223ff72c53e3c00d7bad788692853f811b911cf0ece4d394dca26
{ "func_code_index": [ 1299, 1496 ] }
5,107
DiamondDolphins
@openzeppelin/contracts/access/Ownable.sol
0x881018075d93573d581d129574cbff3c632daaea
Solidity
DiamondDolphins
contract DiamondDolphins is ERC721Enumerable, Ownable { using Strings for uint256; string public baseURI; string public baseExtension = ".json"; uint256 public cost = 0.10 ether; uint256 public maxSupply = 7777; uint256 public maxMintAmount = 50; bool public paused = false; bool public whitelistOnly = false; uint256 public walletLimit = 50; mapping(address => bool) public whitelisted; constructor( string memory _name, string memory _symbol, string memory _initBaseURI ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); // To change the amount of Reserved Owner Tokens, // change the x in the mint(msg.sender, x) method below // to any other number you want. mint(msg.sender, 50); // After setting a reserve mint, you can change the // maxMintAmount or walletLimit maxMintAmount = 10; walletLimit = 10; } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(address _to, uint256 _mintAmount) public payable { uint256 supply = totalSupply(); require(!paused); require(_mintAmount > 0); require(_mintAmount <= maxMintAmount); require(supply + _mintAmount <= maxSupply); require((balanceOf(msg.sender) + _mintAmount) <= walletLimit, 'Wallet limit is reached.'); if (whitelistOnly == false) { if (msg.sender != owner()) { if(whitelisted[msg.sender] != true) { require(msg.value >= cost * _mintAmount); } } for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } } else if (whitelistOnly == true) { require(whitelisted[msg.sender] == true, 'Address is not whitelisted.'); for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } } } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent NFT" ); string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } // // ONLY THE OWNER CAN CALL THE FUNCTIONS BELOW. // // This sets the minting price of each NFT. // Example: If you pass in 0.1, then you will need to pay 0.1 ETH + gas to mint 1 NFT. function setCost(uint256 _newCost) public onlyOwner() { cost = _newCost; } // This sets the amount users can mint at once. // Example: If you want your users to be able to mint 20 NFTs at once, // then you can set the setMaxMintAmount to 20. // // *THIS IS NOT A WALLET LIMIT. THERE IS ANOTHER FUNCTION FOR THAT BELOW* function setMaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner() { maxMintAmount = _newmaxMintAmount; } // This sets the wallet limit. // Example: If you set the setWalletLimit function to 5, then users can have AT MOST 5 NFTs in their wallet. // You can change this to adjust the pre-mint wallet limit vs. the main minting phase's wallet limit. function setWalletLimit(uint256 _newWalletLimit) public onlyOwner() { walletLimit = _newWalletLimit; } // If you want to save gas by setting the maxMintAmount and walletLimit // at the same time, you can use this function. // Simply pass in the new maxMintAmount first, and the newWalletLimit second. // Example: // If you want to set a pre-mint phase where users can only mint 3 NFTs at a time, // and have a wallet limit of 9 NFTs, you can pass in the arguments // 3 and 9 respectively. // Then, to activate full minting for your official launch phase, // simply pass in new arguments to change the maxMintAmount and walletLimit. // Example: // Now that you're fully launching, you can pass in 10 to the newMaxMintAmount argument // which would allow users to mint up to 10 at a time, and pass in 20 to the // newWalletLimit argument which would create a wallet limit of 20 NFTs. function setMaxMintAmountAndWalletLimit(uint256 _newmaxMintAmount, uint256 _newWalletLimit) public onlyOwner() { maxMintAmount = _newmaxMintAmount; walletLimit = _newWalletLimit; } // This sets the max supply. This will be set to 10,000 by default, although it is changable. function setMaxSupply(uint256 _newSupply) public onlyOwner() { maxSupply = _newSupply; } // This changes the baseURI. // Example: If you pass in "https://google.com/", then every new NFT that is minted // will have a URI corresponding to the baseURI you passed in. // The first NFT you mint would have a URI of "https://google.com/1", // The second NFT you mint would have a URI of "https://google.com/2", etc. function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } // This sets the baseURI extension. // Example: If your database requires that the URI of each NFT // must have a .json at the end of the URI // (like https://google.com/1.json instead of just https://google.com/1) // then you can use this function to set the base extension. // For the above example, you would pass in ".json" to add the .json extension. function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } // This pauses or unpauses sales. // If paused, no NFTs can be minted, including by whitelisted users. // Must be set to false for NFTs to be minted. function pause(bool _state) public onlyOwner { paused = _state; } // This activates or deactivates the whitelist. // set to false = anyone can mint // set to true = only whitelisted users can mint function activateWhitelist(bool _state) public onlyOwner { whitelistOnly = _state; } // This whitelists users. // You MUST use an array for this function, and put quotes around the addresses you would like to whitelist. // Example: // If you want to whitelist 0x000000000000000000000000000000000000, // then pass in the argument: // ["0x000000000000000000000000000000000000"] // // If you want to whitelist multiple users, then pass in the argument with commas // seperating the user's addresses. // Example: // ["0x000000000000000000000000000000000000","0x111111111111111111111111111111111", "0x222222222222222222222222222222222"] function whitelistUser(address[] memory _user) public onlyOwner { uint256 x = 0; for (x = 0; x < _user.length; x++) { whitelisted[_user[x]] = true; } } // This removes whitelisted users. // It's arguments are the same as for whitelisting users. // You MUST use an array, and put quotes around the addresses you would like to remove from the whitelist. function removeWhitelistUser(address[] memory _user) public onlyOwner { uint256 x = 0; for (x = 0; x < _user.length; x++) { whitelisted[_user[x]] = false; } } // This withdraws the contract's balance of ETH to the Owner's (whoever launched the contract) address. function withdraw() public payable onlyOwner { require(payable(msg.sender).send(address(this).balance)); } }
_baseURI
function _baseURI() internal view virtual override returns (string memory) { return baseURI; }
// internal
LineComment
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://763a4f36c2c223ff72c53e3c00d7bad788692853f811b911cf0ece4d394dca26
{ "func_code_index": [ 931, 1036 ] }
5,108
DiamondDolphins
@openzeppelin/contracts/access/Ownable.sol
0x881018075d93573d581d129574cbff3c632daaea
Solidity
DiamondDolphins
contract DiamondDolphins is ERC721Enumerable, Ownable { using Strings for uint256; string public baseURI; string public baseExtension = ".json"; uint256 public cost = 0.10 ether; uint256 public maxSupply = 7777; uint256 public maxMintAmount = 50; bool public paused = false; bool public whitelistOnly = false; uint256 public walletLimit = 50; mapping(address => bool) public whitelisted; constructor( string memory _name, string memory _symbol, string memory _initBaseURI ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); // To change the amount of Reserved Owner Tokens, // change the x in the mint(msg.sender, x) method below // to any other number you want. mint(msg.sender, 50); // After setting a reserve mint, you can change the // maxMintAmount or walletLimit maxMintAmount = 10; walletLimit = 10; } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(address _to, uint256 _mintAmount) public payable { uint256 supply = totalSupply(); require(!paused); require(_mintAmount > 0); require(_mintAmount <= maxMintAmount); require(supply + _mintAmount <= maxSupply); require((balanceOf(msg.sender) + _mintAmount) <= walletLimit, 'Wallet limit is reached.'); if (whitelistOnly == false) { if (msg.sender != owner()) { if(whitelisted[msg.sender] != true) { require(msg.value >= cost * _mintAmount); } } for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } } else if (whitelistOnly == true) { require(whitelisted[msg.sender] == true, 'Address is not whitelisted.'); for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } } } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent NFT" ); string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } // // ONLY THE OWNER CAN CALL THE FUNCTIONS BELOW. // // This sets the minting price of each NFT. // Example: If you pass in 0.1, then you will need to pay 0.1 ETH + gas to mint 1 NFT. function setCost(uint256 _newCost) public onlyOwner() { cost = _newCost; } // This sets the amount users can mint at once. // Example: If you want your users to be able to mint 20 NFTs at once, // then you can set the setMaxMintAmount to 20. // // *THIS IS NOT A WALLET LIMIT. THERE IS ANOTHER FUNCTION FOR THAT BELOW* function setMaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner() { maxMintAmount = _newmaxMintAmount; } // This sets the wallet limit. // Example: If you set the setWalletLimit function to 5, then users can have AT MOST 5 NFTs in their wallet. // You can change this to adjust the pre-mint wallet limit vs. the main minting phase's wallet limit. function setWalletLimit(uint256 _newWalletLimit) public onlyOwner() { walletLimit = _newWalletLimit; } // If you want to save gas by setting the maxMintAmount and walletLimit // at the same time, you can use this function. // Simply pass in the new maxMintAmount first, and the newWalletLimit second. // Example: // If you want to set a pre-mint phase where users can only mint 3 NFTs at a time, // and have a wallet limit of 9 NFTs, you can pass in the arguments // 3 and 9 respectively. // Then, to activate full minting for your official launch phase, // simply pass in new arguments to change the maxMintAmount and walletLimit. // Example: // Now that you're fully launching, you can pass in 10 to the newMaxMintAmount argument // which would allow users to mint up to 10 at a time, and pass in 20 to the // newWalletLimit argument which would create a wallet limit of 20 NFTs. function setMaxMintAmountAndWalletLimit(uint256 _newmaxMintAmount, uint256 _newWalletLimit) public onlyOwner() { maxMintAmount = _newmaxMintAmount; walletLimit = _newWalletLimit; } // This sets the max supply. This will be set to 10,000 by default, although it is changable. function setMaxSupply(uint256 _newSupply) public onlyOwner() { maxSupply = _newSupply; } // This changes the baseURI. // Example: If you pass in "https://google.com/", then every new NFT that is minted // will have a URI corresponding to the baseURI you passed in. // The first NFT you mint would have a URI of "https://google.com/1", // The second NFT you mint would have a URI of "https://google.com/2", etc. function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } // This sets the baseURI extension. // Example: If your database requires that the URI of each NFT // must have a .json at the end of the URI // (like https://google.com/1.json instead of just https://google.com/1) // then you can use this function to set the base extension. // For the above example, you would pass in ".json" to add the .json extension. function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } // This pauses or unpauses sales. // If paused, no NFTs can be minted, including by whitelisted users. // Must be set to false for NFTs to be minted. function pause(bool _state) public onlyOwner { paused = _state; } // This activates or deactivates the whitelist. // set to false = anyone can mint // set to true = only whitelisted users can mint function activateWhitelist(bool _state) public onlyOwner { whitelistOnly = _state; } // This whitelists users. // You MUST use an array for this function, and put quotes around the addresses you would like to whitelist. // Example: // If you want to whitelist 0x000000000000000000000000000000000000, // then pass in the argument: // ["0x000000000000000000000000000000000000"] // // If you want to whitelist multiple users, then pass in the argument with commas // seperating the user's addresses. // Example: // ["0x000000000000000000000000000000000000","0x111111111111111111111111111111111", "0x222222222222222222222222222222222"] function whitelistUser(address[] memory _user) public onlyOwner { uint256 x = 0; for (x = 0; x < _user.length; x++) { whitelisted[_user[x]] = true; } } // This removes whitelisted users. // It's arguments are the same as for whitelisting users. // You MUST use an array, and put quotes around the addresses you would like to remove from the whitelist. function removeWhitelistUser(address[] memory _user) public onlyOwner { uint256 x = 0; for (x = 0; x < _user.length; x++) { whitelisted[_user[x]] = false; } } // This withdraws the contract's balance of ETH to the Owner's (whoever launched the contract) address. function withdraw() public payable onlyOwner { require(payable(msg.sender).send(address(this).balance)); } }
mint
function mint(address _to, uint256 _mintAmount) public payable { uint256 supply = totalSupply(); require(!paused); require(_mintAmount > 0); require(_mintAmount <= maxMintAmount); require(supply + _mintAmount <= maxSupply); require((balanceOf(msg.sender) + _mintAmount) <= walletLimit, 'Wallet limit is reached.'); if (whitelistOnly == false) { if (msg.sender != owner()) { if(whitelisted[msg.sender] != true) { require(msg.value >= cost * _mintAmount); } } for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } } else if (whitelistOnly == true) { require(whitelisted[msg.sender] == true, 'Address is not whitelisted.'); for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } } }
// public
LineComment
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://763a4f36c2c223ff72c53e3c00d7bad788692853f811b911cf0ece4d394dca26
{ "func_code_index": [ 1052, 1964 ] }
5,109
DiamondDolphins
@openzeppelin/contracts/access/Ownable.sol
0x881018075d93573d581d129574cbff3c632daaea
Solidity
DiamondDolphins
contract DiamondDolphins is ERC721Enumerable, Ownable { using Strings for uint256; string public baseURI; string public baseExtension = ".json"; uint256 public cost = 0.10 ether; uint256 public maxSupply = 7777; uint256 public maxMintAmount = 50; bool public paused = false; bool public whitelistOnly = false; uint256 public walletLimit = 50; mapping(address => bool) public whitelisted; constructor( string memory _name, string memory _symbol, string memory _initBaseURI ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); // To change the amount of Reserved Owner Tokens, // change the x in the mint(msg.sender, x) method below // to any other number you want. mint(msg.sender, 50); // After setting a reserve mint, you can change the // maxMintAmount or walletLimit maxMintAmount = 10; walletLimit = 10; } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(address _to, uint256 _mintAmount) public payable { uint256 supply = totalSupply(); require(!paused); require(_mintAmount > 0); require(_mintAmount <= maxMintAmount); require(supply + _mintAmount <= maxSupply); require((balanceOf(msg.sender) + _mintAmount) <= walletLimit, 'Wallet limit is reached.'); if (whitelistOnly == false) { if (msg.sender != owner()) { if(whitelisted[msg.sender] != true) { require(msg.value >= cost * _mintAmount); } } for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } } else if (whitelistOnly == true) { require(whitelisted[msg.sender] == true, 'Address is not whitelisted.'); for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } } } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent NFT" ); string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } // // ONLY THE OWNER CAN CALL THE FUNCTIONS BELOW. // // This sets the minting price of each NFT. // Example: If you pass in 0.1, then you will need to pay 0.1 ETH + gas to mint 1 NFT. function setCost(uint256 _newCost) public onlyOwner() { cost = _newCost; } // This sets the amount users can mint at once. // Example: If you want your users to be able to mint 20 NFTs at once, // then you can set the setMaxMintAmount to 20. // // *THIS IS NOT A WALLET LIMIT. THERE IS ANOTHER FUNCTION FOR THAT BELOW* function setMaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner() { maxMintAmount = _newmaxMintAmount; } // This sets the wallet limit. // Example: If you set the setWalletLimit function to 5, then users can have AT MOST 5 NFTs in their wallet. // You can change this to adjust the pre-mint wallet limit vs. the main minting phase's wallet limit. function setWalletLimit(uint256 _newWalletLimit) public onlyOwner() { walletLimit = _newWalletLimit; } // If you want to save gas by setting the maxMintAmount and walletLimit // at the same time, you can use this function. // Simply pass in the new maxMintAmount first, and the newWalletLimit second. // Example: // If you want to set a pre-mint phase where users can only mint 3 NFTs at a time, // and have a wallet limit of 9 NFTs, you can pass in the arguments // 3 and 9 respectively. // Then, to activate full minting for your official launch phase, // simply pass in new arguments to change the maxMintAmount and walletLimit. // Example: // Now that you're fully launching, you can pass in 10 to the newMaxMintAmount argument // which would allow users to mint up to 10 at a time, and pass in 20 to the // newWalletLimit argument which would create a wallet limit of 20 NFTs. function setMaxMintAmountAndWalletLimit(uint256 _newmaxMintAmount, uint256 _newWalletLimit) public onlyOwner() { maxMintAmount = _newmaxMintAmount; walletLimit = _newWalletLimit; } // This sets the max supply. This will be set to 10,000 by default, although it is changable. function setMaxSupply(uint256 _newSupply) public onlyOwner() { maxSupply = _newSupply; } // This changes the baseURI. // Example: If you pass in "https://google.com/", then every new NFT that is minted // will have a URI corresponding to the baseURI you passed in. // The first NFT you mint would have a URI of "https://google.com/1", // The second NFT you mint would have a URI of "https://google.com/2", etc. function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } // This sets the baseURI extension. // Example: If your database requires that the URI of each NFT // must have a .json at the end of the URI // (like https://google.com/1.json instead of just https://google.com/1) // then you can use this function to set the base extension. // For the above example, you would pass in ".json" to add the .json extension. function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } // This pauses or unpauses sales. // If paused, no NFTs can be minted, including by whitelisted users. // Must be set to false for NFTs to be minted. function pause(bool _state) public onlyOwner { paused = _state; } // This activates or deactivates the whitelist. // set to false = anyone can mint // set to true = only whitelisted users can mint function activateWhitelist(bool _state) public onlyOwner { whitelistOnly = _state; } // This whitelists users. // You MUST use an array for this function, and put quotes around the addresses you would like to whitelist. // Example: // If you want to whitelist 0x000000000000000000000000000000000000, // then pass in the argument: // ["0x000000000000000000000000000000000000"] // // If you want to whitelist multiple users, then pass in the argument with commas // seperating the user's addresses. // Example: // ["0x000000000000000000000000000000000000","0x111111111111111111111111111111111", "0x222222222222222222222222222222222"] function whitelistUser(address[] memory _user) public onlyOwner { uint256 x = 0; for (x = 0; x < _user.length; x++) { whitelisted[_user[x]] = true; } } // This removes whitelisted users. // It's arguments are the same as for whitelisting users. // You MUST use an array, and put quotes around the addresses you would like to remove from the whitelist. function removeWhitelistUser(address[] memory _user) public onlyOwner { uint256 x = 0; for (x = 0; x < _user.length; x++) { whitelisted[_user[x]] = false; } } // This withdraws the contract's balance of ETH to the Owner's (whoever launched the contract) address. function withdraw() public payable onlyOwner { require(payable(msg.sender).send(address(this).balance)); } }
setCost
function setCost(uint256 _newCost) public onlyOwner() { cost = _newCost; }
// // ONLY THE OWNER CAN CALL THE FUNCTIONS BELOW. // // This sets the minting price of each NFT. // Example: If you pass in 0.1, then you will need to pay 0.1 ETH + gas to mint 1 NFT.
LineComment
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://763a4f36c2c223ff72c53e3c00d7bad788692853f811b911cf0ece4d394dca26
{ "func_code_index": [ 2947, 3032 ] }
5,110
DiamondDolphins
@openzeppelin/contracts/access/Ownable.sol
0x881018075d93573d581d129574cbff3c632daaea
Solidity
DiamondDolphins
contract DiamondDolphins is ERC721Enumerable, Ownable { using Strings for uint256; string public baseURI; string public baseExtension = ".json"; uint256 public cost = 0.10 ether; uint256 public maxSupply = 7777; uint256 public maxMintAmount = 50; bool public paused = false; bool public whitelistOnly = false; uint256 public walletLimit = 50; mapping(address => bool) public whitelisted; constructor( string memory _name, string memory _symbol, string memory _initBaseURI ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); // To change the amount of Reserved Owner Tokens, // change the x in the mint(msg.sender, x) method below // to any other number you want. mint(msg.sender, 50); // After setting a reserve mint, you can change the // maxMintAmount or walletLimit maxMintAmount = 10; walletLimit = 10; } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(address _to, uint256 _mintAmount) public payable { uint256 supply = totalSupply(); require(!paused); require(_mintAmount > 0); require(_mintAmount <= maxMintAmount); require(supply + _mintAmount <= maxSupply); require((balanceOf(msg.sender) + _mintAmount) <= walletLimit, 'Wallet limit is reached.'); if (whitelistOnly == false) { if (msg.sender != owner()) { if(whitelisted[msg.sender] != true) { require(msg.value >= cost * _mintAmount); } } for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } } else if (whitelistOnly == true) { require(whitelisted[msg.sender] == true, 'Address is not whitelisted.'); for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } } } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent NFT" ); string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } // // ONLY THE OWNER CAN CALL THE FUNCTIONS BELOW. // // This sets the minting price of each NFT. // Example: If you pass in 0.1, then you will need to pay 0.1 ETH + gas to mint 1 NFT. function setCost(uint256 _newCost) public onlyOwner() { cost = _newCost; } // This sets the amount users can mint at once. // Example: If you want your users to be able to mint 20 NFTs at once, // then you can set the setMaxMintAmount to 20. // // *THIS IS NOT A WALLET LIMIT. THERE IS ANOTHER FUNCTION FOR THAT BELOW* function setMaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner() { maxMintAmount = _newmaxMintAmount; } // This sets the wallet limit. // Example: If you set the setWalletLimit function to 5, then users can have AT MOST 5 NFTs in their wallet. // You can change this to adjust the pre-mint wallet limit vs. the main minting phase's wallet limit. function setWalletLimit(uint256 _newWalletLimit) public onlyOwner() { walletLimit = _newWalletLimit; } // If you want to save gas by setting the maxMintAmount and walletLimit // at the same time, you can use this function. // Simply pass in the new maxMintAmount first, and the newWalletLimit second. // Example: // If you want to set a pre-mint phase where users can only mint 3 NFTs at a time, // and have a wallet limit of 9 NFTs, you can pass in the arguments // 3 and 9 respectively. // Then, to activate full minting for your official launch phase, // simply pass in new arguments to change the maxMintAmount and walletLimit. // Example: // Now that you're fully launching, you can pass in 10 to the newMaxMintAmount argument // which would allow users to mint up to 10 at a time, and pass in 20 to the // newWalletLimit argument which would create a wallet limit of 20 NFTs. function setMaxMintAmountAndWalletLimit(uint256 _newmaxMintAmount, uint256 _newWalletLimit) public onlyOwner() { maxMintAmount = _newmaxMintAmount; walletLimit = _newWalletLimit; } // This sets the max supply. This will be set to 10,000 by default, although it is changable. function setMaxSupply(uint256 _newSupply) public onlyOwner() { maxSupply = _newSupply; } // This changes the baseURI. // Example: If you pass in "https://google.com/", then every new NFT that is minted // will have a URI corresponding to the baseURI you passed in. // The first NFT you mint would have a URI of "https://google.com/1", // The second NFT you mint would have a URI of "https://google.com/2", etc. function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } // This sets the baseURI extension. // Example: If your database requires that the URI of each NFT // must have a .json at the end of the URI // (like https://google.com/1.json instead of just https://google.com/1) // then you can use this function to set the base extension. // For the above example, you would pass in ".json" to add the .json extension. function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } // This pauses or unpauses sales. // If paused, no NFTs can be minted, including by whitelisted users. // Must be set to false for NFTs to be minted. function pause(bool _state) public onlyOwner { paused = _state; } // This activates or deactivates the whitelist. // set to false = anyone can mint // set to true = only whitelisted users can mint function activateWhitelist(bool _state) public onlyOwner { whitelistOnly = _state; } // This whitelists users. // You MUST use an array for this function, and put quotes around the addresses you would like to whitelist. // Example: // If you want to whitelist 0x000000000000000000000000000000000000, // then pass in the argument: // ["0x000000000000000000000000000000000000"] // // If you want to whitelist multiple users, then pass in the argument with commas // seperating the user's addresses. // Example: // ["0x000000000000000000000000000000000000","0x111111111111111111111111111111111", "0x222222222222222222222222222222222"] function whitelistUser(address[] memory _user) public onlyOwner { uint256 x = 0; for (x = 0; x < _user.length; x++) { whitelisted[_user[x]] = true; } } // This removes whitelisted users. // It's arguments are the same as for whitelisting users. // You MUST use an array, and put quotes around the addresses you would like to remove from the whitelist. function removeWhitelistUser(address[] memory _user) public onlyOwner { uint256 x = 0; for (x = 0; x < _user.length; x++) { whitelisted[_user[x]] = false; } } // This withdraws the contract's balance of ETH to the Owner's (whoever launched the contract) address. function withdraw() public payable onlyOwner { require(payable(msg.sender).send(address(this).balance)); } }
setMaxMintAmount
function setMaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner() { maxMintAmount = _newmaxMintAmount; }
// This sets the amount users can mint at once. // Example: If you want your users to be able to mint 20 NFTs at once, // then you can set the setMaxMintAmount to 20. // // *THIS IS NOT A WALLET LIMIT. THERE IS ANOTHER FUNCTION FOR THAT BELOW*
LineComment
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://763a4f36c2c223ff72c53e3c00d7bad788692853f811b911cf0ece4d394dca26
{ "func_code_index": [ 3289, 3410 ] }
5,111
DiamondDolphins
@openzeppelin/contracts/access/Ownable.sol
0x881018075d93573d581d129574cbff3c632daaea
Solidity
DiamondDolphins
contract DiamondDolphins is ERC721Enumerable, Ownable { using Strings for uint256; string public baseURI; string public baseExtension = ".json"; uint256 public cost = 0.10 ether; uint256 public maxSupply = 7777; uint256 public maxMintAmount = 50; bool public paused = false; bool public whitelistOnly = false; uint256 public walletLimit = 50; mapping(address => bool) public whitelisted; constructor( string memory _name, string memory _symbol, string memory _initBaseURI ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); // To change the amount of Reserved Owner Tokens, // change the x in the mint(msg.sender, x) method below // to any other number you want. mint(msg.sender, 50); // After setting a reserve mint, you can change the // maxMintAmount or walletLimit maxMintAmount = 10; walletLimit = 10; } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(address _to, uint256 _mintAmount) public payable { uint256 supply = totalSupply(); require(!paused); require(_mintAmount > 0); require(_mintAmount <= maxMintAmount); require(supply + _mintAmount <= maxSupply); require((balanceOf(msg.sender) + _mintAmount) <= walletLimit, 'Wallet limit is reached.'); if (whitelistOnly == false) { if (msg.sender != owner()) { if(whitelisted[msg.sender] != true) { require(msg.value >= cost * _mintAmount); } } for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } } else if (whitelistOnly == true) { require(whitelisted[msg.sender] == true, 'Address is not whitelisted.'); for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } } } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent NFT" ); string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } // // ONLY THE OWNER CAN CALL THE FUNCTIONS BELOW. // // This sets the minting price of each NFT. // Example: If you pass in 0.1, then you will need to pay 0.1 ETH + gas to mint 1 NFT. function setCost(uint256 _newCost) public onlyOwner() { cost = _newCost; } // This sets the amount users can mint at once. // Example: If you want your users to be able to mint 20 NFTs at once, // then you can set the setMaxMintAmount to 20. // // *THIS IS NOT A WALLET LIMIT. THERE IS ANOTHER FUNCTION FOR THAT BELOW* function setMaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner() { maxMintAmount = _newmaxMintAmount; } // This sets the wallet limit. // Example: If you set the setWalletLimit function to 5, then users can have AT MOST 5 NFTs in their wallet. // You can change this to adjust the pre-mint wallet limit vs. the main minting phase's wallet limit. function setWalletLimit(uint256 _newWalletLimit) public onlyOwner() { walletLimit = _newWalletLimit; } // If you want to save gas by setting the maxMintAmount and walletLimit // at the same time, you can use this function. // Simply pass in the new maxMintAmount first, and the newWalletLimit second. // Example: // If you want to set a pre-mint phase where users can only mint 3 NFTs at a time, // and have a wallet limit of 9 NFTs, you can pass in the arguments // 3 and 9 respectively. // Then, to activate full minting for your official launch phase, // simply pass in new arguments to change the maxMintAmount and walletLimit. // Example: // Now that you're fully launching, you can pass in 10 to the newMaxMintAmount argument // which would allow users to mint up to 10 at a time, and pass in 20 to the // newWalletLimit argument which would create a wallet limit of 20 NFTs. function setMaxMintAmountAndWalletLimit(uint256 _newmaxMintAmount, uint256 _newWalletLimit) public onlyOwner() { maxMintAmount = _newmaxMintAmount; walletLimit = _newWalletLimit; } // This sets the max supply. This will be set to 10,000 by default, although it is changable. function setMaxSupply(uint256 _newSupply) public onlyOwner() { maxSupply = _newSupply; } // This changes the baseURI. // Example: If you pass in "https://google.com/", then every new NFT that is minted // will have a URI corresponding to the baseURI you passed in. // The first NFT you mint would have a URI of "https://google.com/1", // The second NFT you mint would have a URI of "https://google.com/2", etc. function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } // This sets the baseURI extension. // Example: If your database requires that the URI of each NFT // must have a .json at the end of the URI // (like https://google.com/1.json instead of just https://google.com/1) // then you can use this function to set the base extension. // For the above example, you would pass in ".json" to add the .json extension. function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } // This pauses or unpauses sales. // If paused, no NFTs can be minted, including by whitelisted users. // Must be set to false for NFTs to be minted. function pause(bool _state) public onlyOwner { paused = _state; } // This activates or deactivates the whitelist. // set to false = anyone can mint // set to true = only whitelisted users can mint function activateWhitelist(bool _state) public onlyOwner { whitelistOnly = _state; } // This whitelists users. // You MUST use an array for this function, and put quotes around the addresses you would like to whitelist. // Example: // If you want to whitelist 0x000000000000000000000000000000000000, // then pass in the argument: // ["0x000000000000000000000000000000000000"] // // If you want to whitelist multiple users, then pass in the argument with commas // seperating the user's addresses. // Example: // ["0x000000000000000000000000000000000000","0x111111111111111111111111111111111", "0x222222222222222222222222222222222"] function whitelistUser(address[] memory _user) public onlyOwner { uint256 x = 0; for (x = 0; x < _user.length; x++) { whitelisted[_user[x]] = true; } } // This removes whitelisted users. // It's arguments are the same as for whitelisting users. // You MUST use an array, and put quotes around the addresses you would like to remove from the whitelist. function removeWhitelistUser(address[] memory _user) public onlyOwner { uint256 x = 0; for (x = 0; x < _user.length; x++) { whitelisted[_user[x]] = false; } } // This withdraws the contract's balance of ETH to the Owner's (whoever launched the contract) address. function withdraw() public payable onlyOwner { require(payable(msg.sender).send(address(this).balance)); } }
setWalletLimit
function setWalletLimit(uint256 _newWalletLimit) public onlyOwner() { walletLimit = _newWalletLimit; }
// This sets the wallet limit. // Example: If you set the setWalletLimit function to 5, then users can have AT MOST 5 NFTs in their wallet. // You can change this to adjust the pre-mint wallet limit vs. the main minting phase's wallet limit.
LineComment
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://763a4f36c2c223ff72c53e3c00d7bad788692853f811b911cf0ece4d394dca26
{ "func_code_index": [ 3663, 3776 ] }
5,112
DiamondDolphins
@openzeppelin/contracts/access/Ownable.sol
0x881018075d93573d581d129574cbff3c632daaea
Solidity
DiamondDolphins
contract DiamondDolphins is ERC721Enumerable, Ownable { using Strings for uint256; string public baseURI; string public baseExtension = ".json"; uint256 public cost = 0.10 ether; uint256 public maxSupply = 7777; uint256 public maxMintAmount = 50; bool public paused = false; bool public whitelistOnly = false; uint256 public walletLimit = 50; mapping(address => bool) public whitelisted; constructor( string memory _name, string memory _symbol, string memory _initBaseURI ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); // To change the amount of Reserved Owner Tokens, // change the x in the mint(msg.sender, x) method below // to any other number you want. mint(msg.sender, 50); // After setting a reserve mint, you can change the // maxMintAmount or walletLimit maxMintAmount = 10; walletLimit = 10; } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(address _to, uint256 _mintAmount) public payable { uint256 supply = totalSupply(); require(!paused); require(_mintAmount > 0); require(_mintAmount <= maxMintAmount); require(supply + _mintAmount <= maxSupply); require((balanceOf(msg.sender) + _mintAmount) <= walletLimit, 'Wallet limit is reached.'); if (whitelistOnly == false) { if (msg.sender != owner()) { if(whitelisted[msg.sender] != true) { require(msg.value >= cost * _mintAmount); } } for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } } else if (whitelistOnly == true) { require(whitelisted[msg.sender] == true, 'Address is not whitelisted.'); for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } } } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent NFT" ); string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } // // ONLY THE OWNER CAN CALL THE FUNCTIONS BELOW. // // This sets the minting price of each NFT. // Example: If you pass in 0.1, then you will need to pay 0.1 ETH + gas to mint 1 NFT. function setCost(uint256 _newCost) public onlyOwner() { cost = _newCost; } // This sets the amount users can mint at once. // Example: If you want your users to be able to mint 20 NFTs at once, // then you can set the setMaxMintAmount to 20. // // *THIS IS NOT A WALLET LIMIT. THERE IS ANOTHER FUNCTION FOR THAT BELOW* function setMaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner() { maxMintAmount = _newmaxMintAmount; } // This sets the wallet limit. // Example: If you set the setWalletLimit function to 5, then users can have AT MOST 5 NFTs in their wallet. // You can change this to adjust the pre-mint wallet limit vs. the main minting phase's wallet limit. function setWalletLimit(uint256 _newWalletLimit) public onlyOwner() { walletLimit = _newWalletLimit; } // If you want to save gas by setting the maxMintAmount and walletLimit // at the same time, you can use this function. // Simply pass in the new maxMintAmount first, and the newWalletLimit second. // Example: // If you want to set a pre-mint phase where users can only mint 3 NFTs at a time, // and have a wallet limit of 9 NFTs, you can pass in the arguments // 3 and 9 respectively. // Then, to activate full minting for your official launch phase, // simply pass in new arguments to change the maxMintAmount and walletLimit. // Example: // Now that you're fully launching, you can pass in 10 to the newMaxMintAmount argument // which would allow users to mint up to 10 at a time, and pass in 20 to the // newWalletLimit argument which would create a wallet limit of 20 NFTs. function setMaxMintAmountAndWalletLimit(uint256 _newmaxMintAmount, uint256 _newWalletLimit) public onlyOwner() { maxMintAmount = _newmaxMintAmount; walletLimit = _newWalletLimit; } // This sets the max supply. This will be set to 10,000 by default, although it is changable. function setMaxSupply(uint256 _newSupply) public onlyOwner() { maxSupply = _newSupply; } // This changes the baseURI. // Example: If you pass in "https://google.com/", then every new NFT that is minted // will have a URI corresponding to the baseURI you passed in. // The first NFT you mint would have a URI of "https://google.com/1", // The second NFT you mint would have a URI of "https://google.com/2", etc. function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } // This sets the baseURI extension. // Example: If your database requires that the URI of each NFT // must have a .json at the end of the URI // (like https://google.com/1.json instead of just https://google.com/1) // then you can use this function to set the base extension. // For the above example, you would pass in ".json" to add the .json extension. function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } // This pauses or unpauses sales. // If paused, no NFTs can be minted, including by whitelisted users. // Must be set to false for NFTs to be minted. function pause(bool _state) public onlyOwner { paused = _state; } // This activates or deactivates the whitelist. // set to false = anyone can mint // set to true = only whitelisted users can mint function activateWhitelist(bool _state) public onlyOwner { whitelistOnly = _state; } // This whitelists users. // You MUST use an array for this function, and put quotes around the addresses you would like to whitelist. // Example: // If you want to whitelist 0x000000000000000000000000000000000000, // then pass in the argument: // ["0x000000000000000000000000000000000000"] // // If you want to whitelist multiple users, then pass in the argument with commas // seperating the user's addresses. // Example: // ["0x000000000000000000000000000000000000","0x111111111111111111111111111111111", "0x222222222222222222222222222222222"] function whitelistUser(address[] memory _user) public onlyOwner { uint256 x = 0; for (x = 0; x < _user.length; x++) { whitelisted[_user[x]] = true; } } // This removes whitelisted users. // It's arguments are the same as for whitelisting users. // You MUST use an array, and put quotes around the addresses you would like to remove from the whitelist. function removeWhitelistUser(address[] memory _user) public onlyOwner { uint256 x = 0; for (x = 0; x < _user.length; x++) { whitelisted[_user[x]] = false; } } // This withdraws the contract's balance of ETH to the Owner's (whoever launched the contract) address. function withdraw() public payable onlyOwner { require(payable(msg.sender).send(address(this).balance)); } }
setMaxMintAmountAndWalletLimit
function setMaxMintAmountAndWalletLimit(uint256 _newmaxMintAmount, uint256 _newWalletLimit) public onlyOwner() { maxMintAmount = _newmaxMintAmount; walletLimit = _newWalletLimit; }
// If you want to save gas by setting the maxMintAmount and walletLimit // at the same time, you can use this function. // Simply pass in the new maxMintAmount first, and the newWalletLimit second. // Example: // If you want to set a pre-mint phase where users can only mint 3 NFTs at a time, // and have a wallet limit of 9 NFTs, you can pass in the arguments // 3 and 9 respectively. // Then, to activate full minting for your official launch phase, // simply pass in new arguments to change the maxMintAmount and walletLimit. // Example: // Now that you're fully launching, you can pass in 10 to the newMaxMintAmount argument // which would allow users to mint up to 10 at a time, and pass in 20 to the // newWalletLimit argument which would create a wallet limit of 20 NFTs.
LineComment
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://763a4f36c2c223ff72c53e3c00d7bad788692853f811b911cf0ece4d394dca26
{ "func_code_index": [ 4587, 4783 ] }
5,113
DiamondDolphins
@openzeppelin/contracts/access/Ownable.sol
0x881018075d93573d581d129574cbff3c632daaea
Solidity
DiamondDolphins
contract DiamondDolphins is ERC721Enumerable, Ownable { using Strings for uint256; string public baseURI; string public baseExtension = ".json"; uint256 public cost = 0.10 ether; uint256 public maxSupply = 7777; uint256 public maxMintAmount = 50; bool public paused = false; bool public whitelistOnly = false; uint256 public walletLimit = 50; mapping(address => bool) public whitelisted; constructor( string memory _name, string memory _symbol, string memory _initBaseURI ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); // To change the amount of Reserved Owner Tokens, // change the x in the mint(msg.sender, x) method below // to any other number you want. mint(msg.sender, 50); // After setting a reserve mint, you can change the // maxMintAmount or walletLimit maxMintAmount = 10; walletLimit = 10; } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(address _to, uint256 _mintAmount) public payable { uint256 supply = totalSupply(); require(!paused); require(_mintAmount > 0); require(_mintAmount <= maxMintAmount); require(supply + _mintAmount <= maxSupply); require((balanceOf(msg.sender) + _mintAmount) <= walletLimit, 'Wallet limit is reached.'); if (whitelistOnly == false) { if (msg.sender != owner()) { if(whitelisted[msg.sender] != true) { require(msg.value >= cost * _mintAmount); } } for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } } else if (whitelistOnly == true) { require(whitelisted[msg.sender] == true, 'Address is not whitelisted.'); for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } } } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent NFT" ); string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } // // ONLY THE OWNER CAN CALL THE FUNCTIONS BELOW. // // This sets the minting price of each NFT. // Example: If you pass in 0.1, then you will need to pay 0.1 ETH + gas to mint 1 NFT. function setCost(uint256 _newCost) public onlyOwner() { cost = _newCost; } // This sets the amount users can mint at once. // Example: If you want your users to be able to mint 20 NFTs at once, // then you can set the setMaxMintAmount to 20. // // *THIS IS NOT A WALLET LIMIT. THERE IS ANOTHER FUNCTION FOR THAT BELOW* function setMaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner() { maxMintAmount = _newmaxMintAmount; } // This sets the wallet limit. // Example: If you set the setWalletLimit function to 5, then users can have AT MOST 5 NFTs in their wallet. // You can change this to adjust the pre-mint wallet limit vs. the main minting phase's wallet limit. function setWalletLimit(uint256 _newWalletLimit) public onlyOwner() { walletLimit = _newWalletLimit; } // If you want to save gas by setting the maxMintAmount and walletLimit // at the same time, you can use this function. // Simply pass in the new maxMintAmount first, and the newWalletLimit second. // Example: // If you want to set a pre-mint phase where users can only mint 3 NFTs at a time, // and have a wallet limit of 9 NFTs, you can pass in the arguments // 3 and 9 respectively. // Then, to activate full minting for your official launch phase, // simply pass in new arguments to change the maxMintAmount and walletLimit. // Example: // Now that you're fully launching, you can pass in 10 to the newMaxMintAmount argument // which would allow users to mint up to 10 at a time, and pass in 20 to the // newWalletLimit argument which would create a wallet limit of 20 NFTs. function setMaxMintAmountAndWalletLimit(uint256 _newmaxMintAmount, uint256 _newWalletLimit) public onlyOwner() { maxMintAmount = _newmaxMintAmount; walletLimit = _newWalletLimit; } // This sets the max supply. This will be set to 10,000 by default, although it is changable. function setMaxSupply(uint256 _newSupply) public onlyOwner() { maxSupply = _newSupply; } // This changes the baseURI. // Example: If you pass in "https://google.com/", then every new NFT that is minted // will have a URI corresponding to the baseURI you passed in. // The first NFT you mint would have a URI of "https://google.com/1", // The second NFT you mint would have a URI of "https://google.com/2", etc. function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } // This sets the baseURI extension. // Example: If your database requires that the URI of each NFT // must have a .json at the end of the URI // (like https://google.com/1.json instead of just https://google.com/1) // then you can use this function to set the base extension. // For the above example, you would pass in ".json" to add the .json extension. function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } // This pauses or unpauses sales. // If paused, no NFTs can be minted, including by whitelisted users. // Must be set to false for NFTs to be minted. function pause(bool _state) public onlyOwner { paused = _state; } // This activates or deactivates the whitelist. // set to false = anyone can mint // set to true = only whitelisted users can mint function activateWhitelist(bool _state) public onlyOwner { whitelistOnly = _state; } // This whitelists users. // You MUST use an array for this function, and put quotes around the addresses you would like to whitelist. // Example: // If you want to whitelist 0x000000000000000000000000000000000000, // then pass in the argument: // ["0x000000000000000000000000000000000000"] // // If you want to whitelist multiple users, then pass in the argument with commas // seperating the user's addresses. // Example: // ["0x000000000000000000000000000000000000","0x111111111111111111111111111111111", "0x222222222222222222222222222222222"] function whitelistUser(address[] memory _user) public onlyOwner { uint256 x = 0; for (x = 0; x < _user.length; x++) { whitelisted[_user[x]] = true; } } // This removes whitelisted users. // It's arguments are the same as for whitelisting users. // You MUST use an array, and put quotes around the addresses you would like to remove from the whitelist. function removeWhitelistUser(address[] memory _user) public onlyOwner { uint256 x = 0; for (x = 0; x < _user.length; x++) { whitelisted[_user[x]] = false; } } // This withdraws the contract's balance of ETH to the Owner's (whoever launched the contract) address. function withdraw() public payable onlyOwner { require(payable(msg.sender).send(address(this).balance)); } }
setMaxSupply
function setMaxSupply(uint256 _newSupply) public onlyOwner() { maxSupply = _newSupply; }
// This sets the max supply. This will be set to 10,000 by default, although it is changable.
LineComment
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://763a4f36c2c223ff72c53e3c00d7bad788692853f811b911cf0ece4d394dca26
{ "func_code_index": [ 4882, 4981 ] }
5,114
DiamondDolphins
@openzeppelin/contracts/access/Ownable.sol
0x881018075d93573d581d129574cbff3c632daaea
Solidity
DiamondDolphins
contract DiamondDolphins is ERC721Enumerable, Ownable { using Strings for uint256; string public baseURI; string public baseExtension = ".json"; uint256 public cost = 0.10 ether; uint256 public maxSupply = 7777; uint256 public maxMintAmount = 50; bool public paused = false; bool public whitelistOnly = false; uint256 public walletLimit = 50; mapping(address => bool) public whitelisted; constructor( string memory _name, string memory _symbol, string memory _initBaseURI ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); // To change the amount of Reserved Owner Tokens, // change the x in the mint(msg.sender, x) method below // to any other number you want. mint(msg.sender, 50); // After setting a reserve mint, you can change the // maxMintAmount or walletLimit maxMintAmount = 10; walletLimit = 10; } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(address _to, uint256 _mintAmount) public payable { uint256 supply = totalSupply(); require(!paused); require(_mintAmount > 0); require(_mintAmount <= maxMintAmount); require(supply + _mintAmount <= maxSupply); require((balanceOf(msg.sender) + _mintAmount) <= walletLimit, 'Wallet limit is reached.'); if (whitelistOnly == false) { if (msg.sender != owner()) { if(whitelisted[msg.sender] != true) { require(msg.value >= cost * _mintAmount); } } for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } } else if (whitelistOnly == true) { require(whitelisted[msg.sender] == true, 'Address is not whitelisted.'); for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } } } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent NFT" ); string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } // // ONLY THE OWNER CAN CALL THE FUNCTIONS BELOW. // // This sets the minting price of each NFT. // Example: If you pass in 0.1, then you will need to pay 0.1 ETH + gas to mint 1 NFT. function setCost(uint256 _newCost) public onlyOwner() { cost = _newCost; } // This sets the amount users can mint at once. // Example: If you want your users to be able to mint 20 NFTs at once, // then you can set the setMaxMintAmount to 20. // // *THIS IS NOT A WALLET LIMIT. THERE IS ANOTHER FUNCTION FOR THAT BELOW* function setMaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner() { maxMintAmount = _newmaxMintAmount; } // This sets the wallet limit. // Example: If you set the setWalletLimit function to 5, then users can have AT MOST 5 NFTs in their wallet. // You can change this to adjust the pre-mint wallet limit vs. the main minting phase's wallet limit. function setWalletLimit(uint256 _newWalletLimit) public onlyOwner() { walletLimit = _newWalletLimit; } // If you want to save gas by setting the maxMintAmount and walletLimit // at the same time, you can use this function. // Simply pass in the new maxMintAmount first, and the newWalletLimit second. // Example: // If you want to set a pre-mint phase where users can only mint 3 NFTs at a time, // and have a wallet limit of 9 NFTs, you can pass in the arguments // 3 and 9 respectively. // Then, to activate full minting for your official launch phase, // simply pass in new arguments to change the maxMintAmount and walletLimit. // Example: // Now that you're fully launching, you can pass in 10 to the newMaxMintAmount argument // which would allow users to mint up to 10 at a time, and pass in 20 to the // newWalletLimit argument which would create a wallet limit of 20 NFTs. function setMaxMintAmountAndWalletLimit(uint256 _newmaxMintAmount, uint256 _newWalletLimit) public onlyOwner() { maxMintAmount = _newmaxMintAmount; walletLimit = _newWalletLimit; } // This sets the max supply. This will be set to 10,000 by default, although it is changable. function setMaxSupply(uint256 _newSupply) public onlyOwner() { maxSupply = _newSupply; } // This changes the baseURI. // Example: If you pass in "https://google.com/", then every new NFT that is minted // will have a URI corresponding to the baseURI you passed in. // The first NFT you mint would have a URI of "https://google.com/1", // The second NFT you mint would have a URI of "https://google.com/2", etc. function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } // This sets the baseURI extension. // Example: If your database requires that the URI of each NFT // must have a .json at the end of the URI // (like https://google.com/1.json instead of just https://google.com/1) // then you can use this function to set the base extension. // For the above example, you would pass in ".json" to add the .json extension. function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } // This pauses or unpauses sales. // If paused, no NFTs can be minted, including by whitelisted users. // Must be set to false for NFTs to be minted. function pause(bool _state) public onlyOwner { paused = _state; } // This activates or deactivates the whitelist. // set to false = anyone can mint // set to true = only whitelisted users can mint function activateWhitelist(bool _state) public onlyOwner { whitelistOnly = _state; } // This whitelists users. // You MUST use an array for this function, and put quotes around the addresses you would like to whitelist. // Example: // If you want to whitelist 0x000000000000000000000000000000000000, // then pass in the argument: // ["0x000000000000000000000000000000000000"] // // If you want to whitelist multiple users, then pass in the argument with commas // seperating the user's addresses. // Example: // ["0x000000000000000000000000000000000000","0x111111111111111111111111111111111", "0x222222222222222222222222222222222"] function whitelistUser(address[] memory _user) public onlyOwner { uint256 x = 0; for (x = 0; x < _user.length; x++) { whitelisted[_user[x]] = true; } } // This removes whitelisted users. // It's arguments are the same as for whitelisting users. // You MUST use an array, and put quotes around the addresses you would like to remove from the whitelist. function removeWhitelistUser(address[] memory _user) public onlyOwner { uint256 x = 0; for (x = 0; x < _user.length; x++) { whitelisted[_user[x]] = false; } } // This withdraws the contract's balance of ETH to the Owner's (whoever launched the contract) address. function withdraw() public payable onlyOwner { require(payable(msg.sender).send(address(this).balance)); } }
setBaseURI
function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; }
// This changes the baseURI. // Example: If you pass in "https://google.com/", then every new NFT that is minted // will have a URI corresponding to the baseURI you passed in. // The first NFT you mint would have a URI of "https://google.com/1", // The second NFT you mint would have a URI of "https://google.com/2", etc.
LineComment
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://763a4f36c2c223ff72c53e3c00d7bad788692853f811b911cf0ece4d394dca26
{ "func_code_index": [ 5318, 5419 ] }
5,115
DiamondDolphins
@openzeppelin/contracts/access/Ownable.sol
0x881018075d93573d581d129574cbff3c632daaea
Solidity
DiamondDolphins
contract DiamondDolphins is ERC721Enumerable, Ownable { using Strings for uint256; string public baseURI; string public baseExtension = ".json"; uint256 public cost = 0.10 ether; uint256 public maxSupply = 7777; uint256 public maxMintAmount = 50; bool public paused = false; bool public whitelistOnly = false; uint256 public walletLimit = 50; mapping(address => bool) public whitelisted; constructor( string memory _name, string memory _symbol, string memory _initBaseURI ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); // To change the amount of Reserved Owner Tokens, // change the x in the mint(msg.sender, x) method below // to any other number you want. mint(msg.sender, 50); // After setting a reserve mint, you can change the // maxMintAmount or walletLimit maxMintAmount = 10; walletLimit = 10; } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(address _to, uint256 _mintAmount) public payable { uint256 supply = totalSupply(); require(!paused); require(_mintAmount > 0); require(_mintAmount <= maxMintAmount); require(supply + _mintAmount <= maxSupply); require((balanceOf(msg.sender) + _mintAmount) <= walletLimit, 'Wallet limit is reached.'); if (whitelistOnly == false) { if (msg.sender != owner()) { if(whitelisted[msg.sender] != true) { require(msg.value >= cost * _mintAmount); } } for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } } else if (whitelistOnly == true) { require(whitelisted[msg.sender] == true, 'Address is not whitelisted.'); for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } } } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent NFT" ); string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } // // ONLY THE OWNER CAN CALL THE FUNCTIONS BELOW. // // This sets the minting price of each NFT. // Example: If you pass in 0.1, then you will need to pay 0.1 ETH + gas to mint 1 NFT. function setCost(uint256 _newCost) public onlyOwner() { cost = _newCost; } // This sets the amount users can mint at once. // Example: If you want your users to be able to mint 20 NFTs at once, // then you can set the setMaxMintAmount to 20. // // *THIS IS NOT A WALLET LIMIT. THERE IS ANOTHER FUNCTION FOR THAT BELOW* function setMaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner() { maxMintAmount = _newmaxMintAmount; } // This sets the wallet limit. // Example: If you set the setWalletLimit function to 5, then users can have AT MOST 5 NFTs in their wallet. // You can change this to adjust the pre-mint wallet limit vs. the main minting phase's wallet limit. function setWalletLimit(uint256 _newWalletLimit) public onlyOwner() { walletLimit = _newWalletLimit; } // If you want to save gas by setting the maxMintAmount and walletLimit // at the same time, you can use this function. // Simply pass in the new maxMintAmount first, and the newWalletLimit second. // Example: // If you want to set a pre-mint phase where users can only mint 3 NFTs at a time, // and have a wallet limit of 9 NFTs, you can pass in the arguments // 3 and 9 respectively. // Then, to activate full minting for your official launch phase, // simply pass in new arguments to change the maxMintAmount and walletLimit. // Example: // Now that you're fully launching, you can pass in 10 to the newMaxMintAmount argument // which would allow users to mint up to 10 at a time, and pass in 20 to the // newWalletLimit argument which would create a wallet limit of 20 NFTs. function setMaxMintAmountAndWalletLimit(uint256 _newmaxMintAmount, uint256 _newWalletLimit) public onlyOwner() { maxMintAmount = _newmaxMintAmount; walletLimit = _newWalletLimit; } // This sets the max supply. This will be set to 10,000 by default, although it is changable. function setMaxSupply(uint256 _newSupply) public onlyOwner() { maxSupply = _newSupply; } // This changes the baseURI. // Example: If you pass in "https://google.com/", then every new NFT that is minted // will have a URI corresponding to the baseURI you passed in. // The first NFT you mint would have a URI of "https://google.com/1", // The second NFT you mint would have a URI of "https://google.com/2", etc. function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } // This sets the baseURI extension. // Example: If your database requires that the URI of each NFT // must have a .json at the end of the URI // (like https://google.com/1.json instead of just https://google.com/1) // then you can use this function to set the base extension. // For the above example, you would pass in ".json" to add the .json extension. function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } // This pauses or unpauses sales. // If paused, no NFTs can be minted, including by whitelisted users. // Must be set to false for NFTs to be minted. function pause(bool _state) public onlyOwner { paused = _state; } // This activates or deactivates the whitelist. // set to false = anyone can mint // set to true = only whitelisted users can mint function activateWhitelist(bool _state) public onlyOwner { whitelistOnly = _state; } // This whitelists users. // You MUST use an array for this function, and put quotes around the addresses you would like to whitelist. // Example: // If you want to whitelist 0x000000000000000000000000000000000000, // then pass in the argument: // ["0x000000000000000000000000000000000000"] // // If you want to whitelist multiple users, then pass in the argument with commas // seperating the user's addresses. // Example: // ["0x000000000000000000000000000000000000","0x111111111111111111111111111111111", "0x222222222222222222222222222222222"] function whitelistUser(address[] memory _user) public onlyOwner { uint256 x = 0; for (x = 0; x < _user.length; x++) { whitelisted[_user[x]] = true; } } // This removes whitelisted users. // It's arguments are the same as for whitelisting users. // You MUST use an array, and put quotes around the addresses you would like to remove from the whitelist. function removeWhitelistUser(address[] memory _user) public onlyOwner { uint256 x = 0; for (x = 0; x < _user.length; x++) { whitelisted[_user[x]] = false; } } // This withdraws the contract's balance of ETH to the Owner's (whoever launched the contract) address. function withdraw() public payable onlyOwner { require(payable(msg.sender).send(address(this).balance)); } }
setBaseExtension
function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; }
// This sets the baseURI extension. // Example: If your database requires that the URI of each NFT // must have a .json at the end of the URI // (like https://google.com/1.json instead of just https://google.com/1) // then you can use this function to set the base extension. // For the above example, you would pass in ".json" to add the .json extension.
LineComment
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://763a4f36c2c223ff72c53e3c00d7bad788692853f811b911cf0ece4d394dca26
{ "func_code_index": [ 5791, 5916 ] }
5,116
DiamondDolphins
@openzeppelin/contracts/access/Ownable.sol
0x881018075d93573d581d129574cbff3c632daaea
Solidity
DiamondDolphins
contract DiamondDolphins is ERC721Enumerable, Ownable { using Strings for uint256; string public baseURI; string public baseExtension = ".json"; uint256 public cost = 0.10 ether; uint256 public maxSupply = 7777; uint256 public maxMintAmount = 50; bool public paused = false; bool public whitelistOnly = false; uint256 public walletLimit = 50; mapping(address => bool) public whitelisted; constructor( string memory _name, string memory _symbol, string memory _initBaseURI ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); // To change the amount of Reserved Owner Tokens, // change the x in the mint(msg.sender, x) method below // to any other number you want. mint(msg.sender, 50); // After setting a reserve mint, you can change the // maxMintAmount or walletLimit maxMintAmount = 10; walletLimit = 10; } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(address _to, uint256 _mintAmount) public payable { uint256 supply = totalSupply(); require(!paused); require(_mintAmount > 0); require(_mintAmount <= maxMintAmount); require(supply + _mintAmount <= maxSupply); require((balanceOf(msg.sender) + _mintAmount) <= walletLimit, 'Wallet limit is reached.'); if (whitelistOnly == false) { if (msg.sender != owner()) { if(whitelisted[msg.sender] != true) { require(msg.value >= cost * _mintAmount); } } for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } } else if (whitelistOnly == true) { require(whitelisted[msg.sender] == true, 'Address is not whitelisted.'); for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } } } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent NFT" ); string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } // // ONLY THE OWNER CAN CALL THE FUNCTIONS BELOW. // // This sets the minting price of each NFT. // Example: If you pass in 0.1, then you will need to pay 0.1 ETH + gas to mint 1 NFT. function setCost(uint256 _newCost) public onlyOwner() { cost = _newCost; } // This sets the amount users can mint at once. // Example: If you want your users to be able to mint 20 NFTs at once, // then you can set the setMaxMintAmount to 20. // // *THIS IS NOT A WALLET LIMIT. THERE IS ANOTHER FUNCTION FOR THAT BELOW* function setMaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner() { maxMintAmount = _newmaxMintAmount; } // This sets the wallet limit. // Example: If you set the setWalletLimit function to 5, then users can have AT MOST 5 NFTs in their wallet. // You can change this to adjust the pre-mint wallet limit vs. the main minting phase's wallet limit. function setWalletLimit(uint256 _newWalletLimit) public onlyOwner() { walletLimit = _newWalletLimit; } // If you want to save gas by setting the maxMintAmount and walletLimit // at the same time, you can use this function. // Simply pass in the new maxMintAmount first, and the newWalletLimit second. // Example: // If you want to set a pre-mint phase where users can only mint 3 NFTs at a time, // and have a wallet limit of 9 NFTs, you can pass in the arguments // 3 and 9 respectively. // Then, to activate full minting for your official launch phase, // simply pass in new arguments to change the maxMintAmount and walletLimit. // Example: // Now that you're fully launching, you can pass in 10 to the newMaxMintAmount argument // which would allow users to mint up to 10 at a time, and pass in 20 to the // newWalletLimit argument which would create a wallet limit of 20 NFTs. function setMaxMintAmountAndWalletLimit(uint256 _newmaxMintAmount, uint256 _newWalletLimit) public onlyOwner() { maxMintAmount = _newmaxMintAmount; walletLimit = _newWalletLimit; } // This sets the max supply. This will be set to 10,000 by default, although it is changable. function setMaxSupply(uint256 _newSupply) public onlyOwner() { maxSupply = _newSupply; } // This changes the baseURI. // Example: If you pass in "https://google.com/", then every new NFT that is minted // will have a URI corresponding to the baseURI you passed in. // The first NFT you mint would have a URI of "https://google.com/1", // The second NFT you mint would have a URI of "https://google.com/2", etc. function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } // This sets the baseURI extension. // Example: If your database requires that the URI of each NFT // must have a .json at the end of the URI // (like https://google.com/1.json instead of just https://google.com/1) // then you can use this function to set the base extension. // For the above example, you would pass in ".json" to add the .json extension. function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } // This pauses or unpauses sales. // If paused, no NFTs can be minted, including by whitelisted users. // Must be set to false for NFTs to be minted. function pause(bool _state) public onlyOwner { paused = _state; } // This activates or deactivates the whitelist. // set to false = anyone can mint // set to true = only whitelisted users can mint function activateWhitelist(bool _state) public onlyOwner { whitelistOnly = _state; } // This whitelists users. // You MUST use an array for this function, and put quotes around the addresses you would like to whitelist. // Example: // If you want to whitelist 0x000000000000000000000000000000000000, // then pass in the argument: // ["0x000000000000000000000000000000000000"] // // If you want to whitelist multiple users, then pass in the argument with commas // seperating the user's addresses. // Example: // ["0x000000000000000000000000000000000000","0x111111111111111111111111111111111", "0x222222222222222222222222222222222"] function whitelistUser(address[] memory _user) public onlyOwner { uint256 x = 0; for (x = 0; x < _user.length; x++) { whitelisted[_user[x]] = true; } } // This removes whitelisted users. // It's arguments are the same as for whitelisting users. // You MUST use an array, and put quotes around the addresses you would like to remove from the whitelist. function removeWhitelistUser(address[] memory _user) public onlyOwner { uint256 x = 0; for (x = 0; x < _user.length; x++) { whitelisted[_user[x]] = false; } } // This withdraws the contract's balance of ETH to the Owner's (whoever launched the contract) address. function withdraw() public payable onlyOwner { require(payable(msg.sender).send(address(this).balance)); } }
pause
function pause(bool _state) public onlyOwner { paused = _state; }
// This pauses or unpauses sales. // If paused, no NFTs can be minted, including by whitelisted users. // Must be set to false for NFTs to be minted.
LineComment
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://763a4f36c2c223ff72c53e3c00d7bad788692853f811b911cf0ece4d394dca26
{ "func_code_index": [ 6075, 6151 ] }
5,117
DiamondDolphins
@openzeppelin/contracts/access/Ownable.sol
0x881018075d93573d581d129574cbff3c632daaea
Solidity
DiamondDolphins
contract DiamondDolphins is ERC721Enumerable, Ownable { using Strings for uint256; string public baseURI; string public baseExtension = ".json"; uint256 public cost = 0.10 ether; uint256 public maxSupply = 7777; uint256 public maxMintAmount = 50; bool public paused = false; bool public whitelistOnly = false; uint256 public walletLimit = 50; mapping(address => bool) public whitelisted; constructor( string memory _name, string memory _symbol, string memory _initBaseURI ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); // To change the amount of Reserved Owner Tokens, // change the x in the mint(msg.sender, x) method below // to any other number you want. mint(msg.sender, 50); // After setting a reserve mint, you can change the // maxMintAmount or walletLimit maxMintAmount = 10; walletLimit = 10; } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(address _to, uint256 _mintAmount) public payable { uint256 supply = totalSupply(); require(!paused); require(_mintAmount > 0); require(_mintAmount <= maxMintAmount); require(supply + _mintAmount <= maxSupply); require((balanceOf(msg.sender) + _mintAmount) <= walletLimit, 'Wallet limit is reached.'); if (whitelistOnly == false) { if (msg.sender != owner()) { if(whitelisted[msg.sender] != true) { require(msg.value >= cost * _mintAmount); } } for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } } else if (whitelistOnly == true) { require(whitelisted[msg.sender] == true, 'Address is not whitelisted.'); for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } } } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent NFT" ); string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } // // ONLY THE OWNER CAN CALL THE FUNCTIONS BELOW. // // This sets the minting price of each NFT. // Example: If you pass in 0.1, then you will need to pay 0.1 ETH + gas to mint 1 NFT. function setCost(uint256 _newCost) public onlyOwner() { cost = _newCost; } // This sets the amount users can mint at once. // Example: If you want your users to be able to mint 20 NFTs at once, // then you can set the setMaxMintAmount to 20. // // *THIS IS NOT A WALLET LIMIT. THERE IS ANOTHER FUNCTION FOR THAT BELOW* function setMaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner() { maxMintAmount = _newmaxMintAmount; } // This sets the wallet limit. // Example: If you set the setWalletLimit function to 5, then users can have AT MOST 5 NFTs in their wallet. // You can change this to adjust the pre-mint wallet limit vs. the main minting phase's wallet limit. function setWalletLimit(uint256 _newWalletLimit) public onlyOwner() { walletLimit = _newWalletLimit; } // If you want to save gas by setting the maxMintAmount and walletLimit // at the same time, you can use this function. // Simply pass in the new maxMintAmount first, and the newWalletLimit second. // Example: // If you want to set a pre-mint phase where users can only mint 3 NFTs at a time, // and have a wallet limit of 9 NFTs, you can pass in the arguments // 3 and 9 respectively. // Then, to activate full minting for your official launch phase, // simply pass in new arguments to change the maxMintAmount and walletLimit. // Example: // Now that you're fully launching, you can pass in 10 to the newMaxMintAmount argument // which would allow users to mint up to 10 at a time, and pass in 20 to the // newWalletLimit argument which would create a wallet limit of 20 NFTs. function setMaxMintAmountAndWalletLimit(uint256 _newmaxMintAmount, uint256 _newWalletLimit) public onlyOwner() { maxMintAmount = _newmaxMintAmount; walletLimit = _newWalletLimit; } // This sets the max supply. This will be set to 10,000 by default, although it is changable. function setMaxSupply(uint256 _newSupply) public onlyOwner() { maxSupply = _newSupply; } // This changes the baseURI. // Example: If you pass in "https://google.com/", then every new NFT that is minted // will have a URI corresponding to the baseURI you passed in. // The first NFT you mint would have a URI of "https://google.com/1", // The second NFT you mint would have a URI of "https://google.com/2", etc. function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } // This sets the baseURI extension. // Example: If your database requires that the URI of each NFT // must have a .json at the end of the URI // (like https://google.com/1.json instead of just https://google.com/1) // then you can use this function to set the base extension. // For the above example, you would pass in ".json" to add the .json extension. function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } // This pauses or unpauses sales. // If paused, no NFTs can be minted, including by whitelisted users. // Must be set to false for NFTs to be minted. function pause(bool _state) public onlyOwner { paused = _state; } // This activates or deactivates the whitelist. // set to false = anyone can mint // set to true = only whitelisted users can mint function activateWhitelist(bool _state) public onlyOwner { whitelistOnly = _state; } // This whitelists users. // You MUST use an array for this function, and put quotes around the addresses you would like to whitelist. // Example: // If you want to whitelist 0x000000000000000000000000000000000000, // then pass in the argument: // ["0x000000000000000000000000000000000000"] // // If you want to whitelist multiple users, then pass in the argument with commas // seperating the user's addresses. // Example: // ["0x000000000000000000000000000000000000","0x111111111111111111111111111111111", "0x222222222222222222222222222222222"] function whitelistUser(address[] memory _user) public onlyOwner { uint256 x = 0; for (x = 0; x < _user.length; x++) { whitelisted[_user[x]] = true; } } // This removes whitelisted users. // It's arguments are the same as for whitelisting users. // You MUST use an array, and put quotes around the addresses you would like to remove from the whitelist. function removeWhitelistUser(address[] memory _user) public onlyOwner { uint256 x = 0; for (x = 0; x < _user.length; x++) { whitelisted[_user[x]] = false; } } // This withdraws the contract's balance of ETH to the Owner's (whoever launched the contract) address. function withdraw() public payable onlyOwner { require(payable(msg.sender).send(address(this).balance)); } }
activateWhitelist
function activateWhitelist(bool _state) public onlyOwner { whitelistOnly = _state; }
// This activates or deactivates the whitelist. // set to false = anyone can mint // set to true = only whitelisted users can mint
LineComment
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://763a4f36c2c223ff72c53e3c00d7bad788692853f811b911cf0ece4d394dca26
{ "func_code_index": [ 6292, 6387 ] }
5,118
DiamondDolphins
@openzeppelin/contracts/access/Ownable.sol
0x881018075d93573d581d129574cbff3c632daaea
Solidity
DiamondDolphins
contract DiamondDolphins is ERC721Enumerable, Ownable { using Strings for uint256; string public baseURI; string public baseExtension = ".json"; uint256 public cost = 0.10 ether; uint256 public maxSupply = 7777; uint256 public maxMintAmount = 50; bool public paused = false; bool public whitelistOnly = false; uint256 public walletLimit = 50; mapping(address => bool) public whitelisted; constructor( string memory _name, string memory _symbol, string memory _initBaseURI ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); // To change the amount of Reserved Owner Tokens, // change the x in the mint(msg.sender, x) method below // to any other number you want. mint(msg.sender, 50); // After setting a reserve mint, you can change the // maxMintAmount or walletLimit maxMintAmount = 10; walletLimit = 10; } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(address _to, uint256 _mintAmount) public payable { uint256 supply = totalSupply(); require(!paused); require(_mintAmount > 0); require(_mintAmount <= maxMintAmount); require(supply + _mintAmount <= maxSupply); require((balanceOf(msg.sender) + _mintAmount) <= walletLimit, 'Wallet limit is reached.'); if (whitelistOnly == false) { if (msg.sender != owner()) { if(whitelisted[msg.sender] != true) { require(msg.value >= cost * _mintAmount); } } for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } } else if (whitelistOnly == true) { require(whitelisted[msg.sender] == true, 'Address is not whitelisted.'); for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } } } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent NFT" ); string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } // // ONLY THE OWNER CAN CALL THE FUNCTIONS BELOW. // // This sets the minting price of each NFT. // Example: If you pass in 0.1, then you will need to pay 0.1 ETH + gas to mint 1 NFT. function setCost(uint256 _newCost) public onlyOwner() { cost = _newCost; } // This sets the amount users can mint at once. // Example: If you want your users to be able to mint 20 NFTs at once, // then you can set the setMaxMintAmount to 20. // // *THIS IS NOT A WALLET LIMIT. THERE IS ANOTHER FUNCTION FOR THAT BELOW* function setMaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner() { maxMintAmount = _newmaxMintAmount; } // This sets the wallet limit. // Example: If you set the setWalletLimit function to 5, then users can have AT MOST 5 NFTs in their wallet. // You can change this to adjust the pre-mint wallet limit vs. the main minting phase's wallet limit. function setWalletLimit(uint256 _newWalletLimit) public onlyOwner() { walletLimit = _newWalletLimit; } // If you want to save gas by setting the maxMintAmount and walletLimit // at the same time, you can use this function. // Simply pass in the new maxMintAmount first, and the newWalletLimit second. // Example: // If you want to set a pre-mint phase where users can only mint 3 NFTs at a time, // and have a wallet limit of 9 NFTs, you can pass in the arguments // 3 and 9 respectively. // Then, to activate full minting for your official launch phase, // simply pass in new arguments to change the maxMintAmount and walletLimit. // Example: // Now that you're fully launching, you can pass in 10 to the newMaxMintAmount argument // which would allow users to mint up to 10 at a time, and pass in 20 to the // newWalletLimit argument which would create a wallet limit of 20 NFTs. function setMaxMintAmountAndWalletLimit(uint256 _newmaxMintAmount, uint256 _newWalletLimit) public onlyOwner() { maxMintAmount = _newmaxMintAmount; walletLimit = _newWalletLimit; } // This sets the max supply. This will be set to 10,000 by default, although it is changable. function setMaxSupply(uint256 _newSupply) public onlyOwner() { maxSupply = _newSupply; } // This changes the baseURI. // Example: If you pass in "https://google.com/", then every new NFT that is minted // will have a URI corresponding to the baseURI you passed in. // The first NFT you mint would have a URI of "https://google.com/1", // The second NFT you mint would have a URI of "https://google.com/2", etc. function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } // This sets the baseURI extension. // Example: If your database requires that the URI of each NFT // must have a .json at the end of the URI // (like https://google.com/1.json instead of just https://google.com/1) // then you can use this function to set the base extension. // For the above example, you would pass in ".json" to add the .json extension. function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } // This pauses or unpauses sales. // If paused, no NFTs can be minted, including by whitelisted users. // Must be set to false for NFTs to be minted. function pause(bool _state) public onlyOwner { paused = _state; } // This activates or deactivates the whitelist. // set to false = anyone can mint // set to true = only whitelisted users can mint function activateWhitelist(bool _state) public onlyOwner { whitelistOnly = _state; } // This whitelists users. // You MUST use an array for this function, and put quotes around the addresses you would like to whitelist. // Example: // If you want to whitelist 0x000000000000000000000000000000000000, // then pass in the argument: // ["0x000000000000000000000000000000000000"] // // If you want to whitelist multiple users, then pass in the argument with commas // seperating the user's addresses. // Example: // ["0x000000000000000000000000000000000000","0x111111111111111111111111111111111", "0x222222222222222222222222222222222"] function whitelistUser(address[] memory _user) public onlyOwner { uint256 x = 0; for (x = 0; x < _user.length; x++) { whitelisted[_user[x]] = true; } } // This removes whitelisted users. // It's arguments are the same as for whitelisting users. // You MUST use an array, and put quotes around the addresses you would like to remove from the whitelist. function removeWhitelistUser(address[] memory _user) public onlyOwner { uint256 x = 0; for (x = 0; x < _user.length; x++) { whitelisted[_user[x]] = false; } } // This withdraws the contract's balance of ETH to the Owner's (whoever launched the contract) address. function withdraw() public payable onlyOwner { require(payable(msg.sender).send(address(this).balance)); } }
whitelistUser
function whitelistUser(address[] memory _user) public onlyOwner { uint256 x = 0; for (x = 0; x < _user.length; x++) { whitelisted[_user[x]] = true; } }
// This whitelists users. // You MUST use an array for this function, and put quotes around the addresses you would like to whitelist. // Example: // If you want to whitelist 0x000000000000000000000000000000000000, // then pass in the argument: // ["0x000000000000000000000000000000000000"] // // If you want to whitelist multiple users, then pass in the argument with commas // seperating the user's addresses. // Example: // ["0x000000000000000000000000000000000000","0x111111111111111111111111111111111", "0x222222222222222222222222222222222"]
LineComment
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://763a4f36c2c223ff72c53e3c00d7bad788692853f811b911cf0ece4d394dca26
{ "func_code_index": [ 6961, 7145 ] }
5,119
DiamondDolphins
@openzeppelin/contracts/access/Ownable.sol
0x881018075d93573d581d129574cbff3c632daaea
Solidity
DiamondDolphins
contract DiamondDolphins is ERC721Enumerable, Ownable { using Strings for uint256; string public baseURI; string public baseExtension = ".json"; uint256 public cost = 0.10 ether; uint256 public maxSupply = 7777; uint256 public maxMintAmount = 50; bool public paused = false; bool public whitelistOnly = false; uint256 public walletLimit = 50; mapping(address => bool) public whitelisted; constructor( string memory _name, string memory _symbol, string memory _initBaseURI ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); // To change the amount of Reserved Owner Tokens, // change the x in the mint(msg.sender, x) method below // to any other number you want. mint(msg.sender, 50); // After setting a reserve mint, you can change the // maxMintAmount or walletLimit maxMintAmount = 10; walletLimit = 10; } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(address _to, uint256 _mintAmount) public payable { uint256 supply = totalSupply(); require(!paused); require(_mintAmount > 0); require(_mintAmount <= maxMintAmount); require(supply + _mintAmount <= maxSupply); require((balanceOf(msg.sender) + _mintAmount) <= walletLimit, 'Wallet limit is reached.'); if (whitelistOnly == false) { if (msg.sender != owner()) { if(whitelisted[msg.sender] != true) { require(msg.value >= cost * _mintAmount); } } for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } } else if (whitelistOnly == true) { require(whitelisted[msg.sender] == true, 'Address is not whitelisted.'); for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } } } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent NFT" ); string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } // // ONLY THE OWNER CAN CALL THE FUNCTIONS BELOW. // // This sets the minting price of each NFT. // Example: If you pass in 0.1, then you will need to pay 0.1 ETH + gas to mint 1 NFT. function setCost(uint256 _newCost) public onlyOwner() { cost = _newCost; } // This sets the amount users can mint at once. // Example: If you want your users to be able to mint 20 NFTs at once, // then you can set the setMaxMintAmount to 20. // // *THIS IS NOT A WALLET LIMIT. THERE IS ANOTHER FUNCTION FOR THAT BELOW* function setMaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner() { maxMintAmount = _newmaxMintAmount; } // This sets the wallet limit. // Example: If you set the setWalletLimit function to 5, then users can have AT MOST 5 NFTs in their wallet. // You can change this to adjust the pre-mint wallet limit vs. the main minting phase's wallet limit. function setWalletLimit(uint256 _newWalletLimit) public onlyOwner() { walletLimit = _newWalletLimit; } // If you want to save gas by setting the maxMintAmount and walletLimit // at the same time, you can use this function. // Simply pass in the new maxMintAmount first, and the newWalletLimit second. // Example: // If you want to set a pre-mint phase where users can only mint 3 NFTs at a time, // and have a wallet limit of 9 NFTs, you can pass in the arguments // 3 and 9 respectively. // Then, to activate full minting for your official launch phase, // simply pass in new arguments to change the maxMintAmount and walletLimit. // Example: // Now that you're fully launching, you can pass in 10 to the newMaxMintAmount argument // which would allow users to mint up to 10 at a time, and pass in 20 to the // newWalletLimit argument which would create a wallet limit of 20 NFTs. function setMaxMintAmountAndWalletLimit(uint256 _newmaxMintAmount, uint256 _newWalletLimit) public onlyOwner() { maxMintAmount = _newmaxMintAmount; walletLimit = _newWalletLimit; } // This sets the max supply. This will be set to 10,000 by default, although it is changable. function setMaxSupply(uint256 _newSupply) public onlyOwner() { maxSupply = _newSupply; } // This changes the baseURI. // Example: If you pass in "https://google.com/", then every new NFT that is minted // will have a URI corresponding to the baseURI you passed in. // The first NFT you mint would have a URI of "https://google.com/1", // The second NFT you mint would have a URI of "https://google.com/2", etc. function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } // This sets the baseURI extension. // Example: If your database requires that the URI of each NFT // must have a .json at the end of the URI // (like https://google.com/1.json instead of just https://google.com/1) // then you can use this function to set the base extension. // For the above example, you would pass in ".json" to add the .json extension. function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } // This pauses or unpauses sales. // If paused, no NFTs can be minted, including by whitelisted users. // Must be set to false for NFTs to be minted. function pause(bool _state) public onlyOwner { paused = _state; } // This activates or deactivates the whitelist. // set to false = anyone can mint // set to true = only whitelisted users can mint function activateWhitelist(bool _state) public onlyOwner { whitelistOnly = _state; } // This whitelists users. // You MUST use an array for this function, and put quotes around the addresses you would like to whitelist. // Example: // If you want to whitelist 0x000000000000000000000000000000000000, // then pass in the argument: // ["0x000000000000000000000000000000000000"] // // If you want to whitelist multiple users, then pass in the argument with commas // seperating the user's addresses. // Example: // ["0x000000000000000000000000000000000000","0x111111111111111111111111111111111", "0x222222222222222222222222222222222"] function whitelistUser(address[] memory _user) public onlyOwner { uint256 x = 0; for (x = 0; x < _user.length; x++) { whitelisted[_user[x]] = true; } } // This removes whitelisted users. // It's arguments are the same as for whitelisting users. // You MUST use an array, and put quotes around the addresses you would like to remove from the whitelist. function removeWhitelistUser(address[] memory _user) public onlyOwner { uint256 x = 0; for (x = 0; x < _user.length; x++) { whitelisted[_user[x]] = false; } } // This withdraws the contract's balance of ETH to the Owner's (whoever launched the contract) address. function withdraw() public payable onlyOwner { require(payable(msg.sender).send(address(this).balance)); } }
removeWhitelistUser
function removeWhitelistUser(address[] memory _user) public onlyOwner { uint256 x = 0; for (x = 0; x < _user.length; x++) { whitelisted[_user[x]] = false; } }
// This removes whitelisted users. // It's arguments are the same as for whitelisting users. // You MUST use an array, and put quotes around the addresses you would like to remove from the whitelist.
LineComment
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://763a4f36c2c223ff72c53e3c00d7bad788692853f811b911cf0ece4d394dca26
{ "func_code_index": [ 7355, 7547 ] }
5,120
DiamondDolphins
@openzeppelin/contracts/access/Ownable.sol
0x881018075d93573d581d129574cbff3c632daaea
Solidity
DiamondDolphins
contract DiamondDolphins is ERC721Enumerable, Ownable { using Strings for uint256; string public baseURI; string public baseExtension = ".json"; uint256 public cost = 0.10 ether; uint256 public maxSupply = 7777; uint256 public maxMintAmount = 50; bool public paused = false; bool public whitelistOnly = false; uint256 public walletLimit = 50; mapping(address => bool) public whitelisted; constructor( string memory _name, string memory _symbol, string memory _initBaseURI ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); // To change the amount of Reserved Owner Tokens, // change the x in the mint(msg.sender, x) method below // to any other number you want. mint(msg.sender, 50); // After setting a reserve mint, you can change the // maxMintAmount or walletLimit maxMintAmount = 10; walletLimit = 10; } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(address _to, uint256 _mintAmount) public payable { uint256 supply = totalSupply(); require(!paused); require(_mintAmount > 0); require(_mintAmount <= maxMintAmount); require(supply + _mintAmount <= maxSupply); require((balanceOf(msg.sender) + _mintAmount) <= walletLimit, 'Wallet limit is reached.'); if (whitelistOnly == false) { if (msg.sender != owner()) { if(whitelisted[msg.sender] != true) { require(msg.value >= cost * _mintAmount); } } for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } } else if (whitelistOnly == true) { require(whitelisted[msg.sender] == true, 'Address is not whitelisted.'); for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } } } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent NFT" ); string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } // // ONLY THE OWNER CAN CALL THE FUNCTIONS BELOW. // // This sets the minting price of each NFT. // Example: If you pass in 0.1, then you will need to pay 0.1 ETH + gas to mint 1 NFT. function setCost(uint256 _newCost) public onlyOwner() { cost = _newCost; } // This sets the amount users can mint at once. // Example: If you want your users to be able to mint 20 NFTs at once, // then you can set the setMaxMintAmount to 20. // // *THIS IS NOT A WALLET LIMIT. THERE IS ANOTHER FUNCTION FOR THAT BELOW* function setMaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner() { maxMintAmount = _newmaxMintAmount; } // This sets the wallet limit. // Example: If you set the setWalletLimit function to 5, then users can have AT MOST 5 NFTs in their wallet. // You can change this to adjust the pre-mint wallet limit vs. the main minting phase's wallet limit. function setWalletLimit(uint256 _newWalletLimit) public onlyOwner() { walletLimit = _newWalletLimit; } // If you want to save gas by setting the maxMintAmount and walletLimit // at the same time, you can use this function. // Simply pass in the new maxMintAmount first, and the newWalletLimit second. // Example: // If you want to set a pre-mint phase where users can only mint 3 NFTs at a time, // and have a wallet limit of 9 NFTs, you can pass in the arguments // 3 and 9 respectively. // Then, to activate full minting for your official launch phase, // simply pass in new arguments to change the maxMintAmount and walletLimit. // Example: // Now that you're fully launching, you can pass in 10 to the newMaxMintAmount argument // which would allow users to mint up to 10 at a time, and pass in 20 to the // newWalletLimit argument which would create a wallet limit of 20 NFTs. function setMaxMintAmountAndWalletLimit(uint256 _newmaxMintAmount, uint256 _newWalletLimit) public onlyOwner() { maxMintAmount = _newmaxMintAmount; walletLimit = _newWalletLimit; } // This sets the max supply. This will be set to 10,000 by default, although it is changable. function setMaxSupply(uint256 _newSupply) public onlyOwner() { maxSupply = _newSupply; } // This changes the baseURI. // Example: If you pass in "https://google.com/", then every new NFT that is minted // will have a URI corresponding to the baseURI you passed in. // The first NFT you mint would have a URI of "https://google.com/1", // The second NFT you mint would have a URI of "https://google.com/2", etc. function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } // This sets the baseURI extension. // Example: If your database requires that the URI of each NFT // must have a .json at the end of the URI // (like https://google.com/1.json instead of just https://google.com/1) // then you can use this function to set the base extension. // For the above example, you would pass in ".json" to add the .json extension. function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } // This pauses or unpauses sales. // If paused, no NFTs can be minted, including by whitelisted users. // Must be set to false for NFTs to be minted. function pause(bool _state) public onlyOwner { paused = _state; } // This activates or deactivates the whitelist. // set to false = anyone can mint // set to true = only whitelisted users can mint function activateWhitelist(bool _state) public onlyOwner { whitelistOnly = _state; } // This whitelists users. // You MUST use an array for this function, and put quotes around the addresses you would like to whitelist. // Example: // If you want to whitelist 0x000000000000000000000000000000000000, // then pass in the argument: // ["0x000000000000000000000000000000000000"] // // If you want to whitelist multiple users, then pass in the argument with commas // seperating the user's addresses. // Example: // ["0x000000000000000000000000000000000000","0x111111111111111111111111111111111", "0x222222222222222222222222222222222"] function whitelistUser(address[] memory _user) public onlyOwner { uint256 x = 0; for (x = 0; x < _user.length; x++) { whitelisted[_user[x]] = true; } } // This removes whitelisted users. // It's arguments are the same as for whitelisting users. // You MUST use an array, and put quotes around the addresses you would like to remove from the whitelist. function removeWhitelistUser(address[] memory _user) public onlyOwner { uint256 x = 0; for (x = 0; x < _user.length; x++) { whitelisted[_user[x]] = false; } } // This withdraws the contract's balance of ETH to the Owner's (whoever launched the contract) address. function withdraw() public payable onlyOwner { require(payable(msg.sender).send(address(this).balance)); } }
withdraw
function withdraw() public payable onlyOwner { require(payable(msg.sender).send(address(this).balance)); }
// This withdraws the contract's balance of ETH to the Owner's (whoever launched the contract) address.
LineComment
v0.8.7+commit.e28d00a7
GNU GPLv3
ipfs://763a4f36c2c223ff72c53e3c00d7bad788692853f811b911cf0ece4d394dca26
{ "func_code_index": [ 7658, 7775 ] }
5,121
TokenSale
TokenSale.sol
0x87b5ef63fa5579b40875b66c68cd485656b86259
Solidity
TokenSale
contract TokenSale is Owned{ IERC20Token public tokenContract; // the token being sold uint256 public price = 500; // 1eth = 500 tokens uint256 public decimals = 18; uint256 public tokensSold; uint256 public ethRaised; uint256 public MaxETHAmount; event Sold(address buyer, uint256 amount); constructor(IERC20Token _tokenContract, uint256 _maxEthAmount) { owner = msg.sender; tokenContract = _tokenContract; MaxETHAmount = _maxEthAmount; } fallback() external payable { buyTokensWithETH(msg.sender); } // Guards against integer overflows function safeMultiply(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } else { uint256 c = a * b; assert(c / a == b); return c; } } function multiply(uint x, uint y) internal pure returns (uint z) { require(y == 0 || (z = x * y) / y == x); } function setPrice(uint256 price_) external onlyOwner{ price = price_; } function buyTokensWithETH(address _receiver) public payable { require(ethRaised < MaxETHAmount, "Presale finished"); uint _amount = msg.value; require(_receiver != address(0), "Can't send to 0x00 address"); require(_amount > 0, "Can't buy with 0 eth"); uint tokensToBuy = multiply(_amount, price); require(owner.send(_amount), "Unable to transfer eth to owner"); require(tokenContract.transfer(_receiver, tokensToBuy), "Unable to transfer token to user"); tokensSold += tokensToBuy; ethRaised += _amount; emit Sold(msg.sender, tokensToBuy); } function endSale() public { require(msg.sender == owner); // Send unsold tokens to the owner. require(tokenContract.transfer(owner, tokenContract.balanceOf(address(this)))); msg.sender.transfer(address(this).balance); } }
safeMultiply
function safeMultiply(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } else { uint256 c = a * b; assert(c / a == b); return c; } }
// Guards against integer overflows
LineComment
v0.7.5+commit.eb77ed08
None
ipfs://82400d7531f8359be84648fa0d00a5541cc8998f3d24bcb2f1c4a97e02aabbd8
{ "func_code_index": [ 667, 919 ] }
5,122
TetoInu
/home/dimitris/Documents/Code/ApeNFTs/TetoInu/contracts/TetoInu.sol
0x09dc17ad20e864f91951789c80785ae1ca024230
Solidity
TetoInu
contract TetoInu is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; address payable public marketingAddress; address payable public devAddress; address payable public liquidityAddress; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; // Anti-bot and anti-whale mappings and variables mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch bool public transferDelayEnabled = true; bool public limitsInEffect = true; mapping(address => bool) private _isExcludedFromFee; mapping(address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1 * 1e15 * 1e9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private constant _name = "Teto Inu"; string private constant _symbol = "TetoInu"; uint8 private constant _decimals = 9; // these values are pretty much arbitrary since they get overwritten for every txn, but the placeholders make it easier to work with current contract. uint256 private _taxFee; uint256 private _previousTaxFee = _taxFee; uint256 private _marketingFee; uint256 private _liquidityFee; uint256 private _previousLiquidityFee = _liquidityFee; uint256 private constant BUY = 1; uint256 private constant SELL = 2; uint256 private constant TRANSFER = 3; uint256 private buyOrSellSwitch; uint256 public _buyTaxFee = 2; uint256 public _buyLiquidityFee = 1; uint256 public _buyMarketingFee = 7; uint256 public _sellTaxFee = 2; uint256 public _sellLiquidityFee = 1; uint256 public _sellMarketingFee = 7; uint256 public tradingActiveBlock = 0; // 0 means trading is not active mapping(address => bool) public boughtEarly; // mapping to track addresses that buy within the first 2 blocks pay a 3x tax for 24 hours to sell uint256 public earlyBuyPenaltyEnd; // determines when snipers/bots can sell without extra penalty uint256 public _liquidityTokensToSwap; uint256 public _marketingTokensToSwap; uint256 public maxTransactionAmount; mapping (address => bool) public _isExcludedMaxTransactionAmount; bool private gasLimitActive = true; uint256 private gasPriceLimit = 500 * 1 gwei; // do not allow over 500 gwei for launch // store addresses that a automatic market maker pairs. Any transfer *to* these addresses // could be subject to a maximum transfer amount mapping (address => bool) public automatedMarketMakerPairs; uint256 private minimumTokensBeforeSwap; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = false; bool public tradingActive = false; event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity ); event SwapETHForTokens(uint256 amountIn, address[] path); event SwapTokensForETH(uint256 amountIn, address[] path); event SetAutomatedMarketMakerPair(address pair, bool value); event ExcludeFromReward(address excludedAddress); event IncludeInReward(address includedAddress); event ExcludeFromFee(address excludedAddress); event IncludeInFee(address includedAddress); event SetBuyFee(uint256 marketingFee, uint256 liquidityFee, uint256 reflectFee); event SetSellFee(uint256 marketingFee, uint256 liquidityFee, uint256 reflectFee); event TransferForeignToken(address token, uint256 amount); event UpdatedMarketingAddress(address marketing); event UpdatedLiquidityAddress(address liquidity); event OwnerForcedSwapBack(uint256 timestamp); event BoughtEarly(address indexed sniper); event RemovedSniper(address indexed notsnipersupposedly); modifier lockTheSwap() { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor() payable { _rOwned[_msgSender()] = _rTotal / 1000 * 30; _rOwned[address(this)] = _rTotal / 1000 * 970; maxTransactionAmount = _tTotal * 5 / 1000; // 0.5% maxTransactionAmountTxn minimumTokensBeforeSwap = _tTotal * 5 / 10000; // 0.05% swap tokens amount marketingAddress = payable(0xC32d316238C5811441863D0F2961167C755397f9); // Marketing Address devAddress = payable(0x65029D6872DeDD7D5344c20d1fe4C23bb6D3059D); // Dev Address liquidityAddress = payable(owner()); // Liquidity Address (switches to dead address once launch happens) _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[marketingAddress] = true; _isExcludedFromFee[liquidityAddress] = true; excludeFromMaxTransaction(owner(), true); excludeFromMaxTransaction(address(this), true); excludeFromMaxTransaction(address(0xdead), true); emit Transfer(address(0), _msgSender(), _tTotal * 30 / 1000); emit Transfer(address(0), address(this), _tTotal * 970 / 1000); } function name() external pure returns (string memory) { return _name; } function symbol() external pure returns (string memory) { return _symbol; } function decimals() external pure returns (uint8) { return _decimals; } function totalSupply() external pure 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) external override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) external 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 ) external 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) external virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue) ); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) external virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender].sub( subtractedValue, "ERC20: decreased allowance below zero" ) ); return true; } function isExcludedFromReward(address account) external view returns (bool) { return _isExcluded[account]; } function totalFees() external view returns (uint256) { return _tFeeTotal; } // remove limits after token is stable - 30-60 minutes function removeLimits() external onlyOwner returns (bool){ limitsInEffect = false; gasLimitActive = false; transferDelayEnabled = false; return true; } // disable Transfer delay function disableTransferDelay() external onlyOwner returns (bool){ transferDelayEnabled = false; return true; } function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner { _isExcludedMaxTransactionAmount[updAds] = isEx; } // once enabled, can never be turned off function enableTrading() internal onlyOwner { tradingActive = true; swapAndLiquifyEnabled = true; tradingActiveBlock = block.number; earlyBuyPenaltyEnd = block.timestamp + 72 hours; } // send tokens and ETH for liquidity to contract directly, then call this function. //(not required, can still use Uniswap to add liquidity manually, but this ensures everything is excluded properly and makes for a great stealth launch) function launch(address[] memory airdropWallets, uint256[] memory amounts) external onlyOwner returns (bool){ require(!tradingActive, "Trading is already active, cannot relaunch."); require(airdropWallets.length < 200, "Can only airdrop 200 wallets per txn due to gas limits"); // allows for airdrop + launch at the same exact time, reducing delays and reducing sniper input. for(uint256 i = 0; i < airdropWallets.length; i++){ address wallet = airdropWallets[i]; uint256 amount = amounts[i]; _transfer(msg.sender, wallet, amount); } enableTrading(); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); excludeFromMaxTransaction(address(_uniswapV2Router), true); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); excludeFromMaxTransaction(address(uniswapV2Pair), true); _setAutomatedMarketMakerPair(address(uniswapV2Pair), true); require(address(this).balance > 0, "Must have ETH on contract to launch"); addLiquidity(balanceOf(address(this)), address(this).balance); //setLiquidityAddress(address(0xdead)); return true; } function minimumTokensBeforeSwapAmount() external view returns (uint256) { return minimumTokensBeforeSwap; } function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require(pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs"); _setAutomatedMarketMakerPair(pair, value); } function _setAutomatedMarketMakerPair(address pair, bool value) private { automatedMarketMakerPairs[pair] = value; _isExcludedMaxTransactionAmount[pair] = value; if(value){excludeFromReward(pair);} if(!value){includeInReward(pair);} } function setGasPriceLimit(uint256 gas) external onlyOwner { require(gas >= 200); gasPriceLimit = gas * 1 gwei; } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) external 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"); require(_excluded.length + 1 <= 50, "Cannot exclude more than 50 accounts. Include a previously excluded address."); if (_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) public onlyOwner { require(_isExcluded[account], "Account is not 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 { //########### MARKER ############################################ require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(!tradingActive){ require(_isExcludedFromFee[from] || _isExcludedFromFee[to], "Trading not active yet!"); } if(limitsInEffect){ if ( from != owner() && to != owner() && to != address(0) && to != address(0xdead) && !inSwapAndLiquify ){ if(from != owner() && to != uniswapV2Pair && block.number == tradingActiveBlock){ boughtEarly[to] = true; emit BoughtEarly(to); } // only use to prevent sniper buys in the first blocks. if (gasLimitActive && automatedMarketMakerPairs[from]) { require(tx.gasprice <= gasPriceLimit, "Gas price exceeds limit."); } // at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch. if (transferDelayEnabled){ if (to != owner() && to != address(uniswapV2Router) && to != address(uniswapV2Pair)){ require(_holderLastTransferTimestamp[to] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed."); _holderLastTransferTimestamp[to] = block.number; } } //when buy if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) { require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount."); } //when sell else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) { require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount."); } } } uint256 totalTokensToSwap = _liquidityTokensToSwap.add(_marketingTokensToSwap); uint256 contractTokenBalance = balanceOf(address(this)); bool overMinimumTokenBalance = contractTokenBalance >= minimumTokensBeforeSwap; // swap and liquify if ( !inSwapAndLiquify && swapAndLiquifyEnabled && balanceOf(uniswapV2Pair) > 0 && totalTokensToSwap > 0 && !_isExcludedFromFee[to] && !_isExcludedFromFee[from] && automatedMarketMakerPairs[to] && overMinimumTokenBalance ) { swapBack(); } bool takeFee = true; // If any account belongs to _isExcludedFromFee account then remove the fee if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) { takeFee = false; buyOrSellSwitch = TRANSFER; // TRANSFERs do not pay a tax. } else { // Buy if (automatedMarketMakerPairs[from]) { removeAllFee(); _taxFee = _buyTaxFee; _liquidityFee = _buyLiquidityFee + _buyMarketingFee; buyOrSellSwitch = BUY; } // Sell else if (automatedMarketMakerPairs[to]) { removeAllFee(); _taxFee = _sellTaxFee; _liquidityFee = _sellLiquidityFee + _sellMarketingFee; buyOrSellSwitch = SELL; // higher tax if bought in the same block as trading active for 72 hours (sniper protect) if(boughtEarly[from] && earlyBuyPenaltyEnd > block.timestamp){ _taxFee = _taxFee * 5; _liquidityFee = _liquidityFee * 5; } // Normal transfers do not get taxed } else { require(!boughtEarly[from] || earlyBuyPenaltyEnd <= block.timestamp, "Snipers can't transfer tokens to sell cheaper until penalty timeframe is over. DM a TetoInu Mod."); removeAllFee(); buyOrSellSwitch = TRANSFER; // TRANSFERs do not pay a tax. } } _tokenTransfer(from, to, amount, takeFee); } function swapBack() private lockTheSwap { uint256 contractBalance = balanceOf(address(this)); uint256 totalTokensToSwap = _liquidityTokensToSwap + _marketingTokensToSwap; // Halve the amount of liquidity tokens uint256 tokensForLiquidity = _liquidityTokensToSwap.div(2); uint256 amountToSwapForETH = contractBalance.sub(tokensForLiquidity); uint256 initialETHBalance = address(this).balance; swapTokensForETH(amountToSwapForETH); uint256 ethBalance = address(this).balance.sub(initialETHBalance); uint256 ethForMarketing = ethBalance.mul(_marketingTokensToSwap).div(totalTokensToSwap); uint256 ethForLiquidity = ethBalance.sub(ethForMarketing); uint256 ethForDev= ethForMarketing * 2 / 7; // 2/7 goes to dev ethForMarketing -= ethForDev; _liquidityTokensToSwap = 0; _marketingTokensToSwap = 0; (bool success,) = address(marketingAddress).call{value: ethForMarketing}(""); (success,) = address(devAddress).call{value: ethForDev}(""); addLiquidity(tokensForLiquidity, ethForLiquidity); emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, tokensForLiquidity); // send leftover ETH to the marketing wallet so it doesn't get stuck on the contract. if(address(this).balance > 1e17){ (success,) = address(marketingAddress).call{value: address(this).balance}(""); } } // force Swap back if slippage above 49% for launch. function forceSwapBack() external onlyOwner { uint256 contractBalance = balanceOf(address(this)); require(contractBalance >= _tTotal / 100, "Can only swap back if more than 1% of tokens stuck on contract"); swapBack(); emit OwnerForcedSwapBack(block.timestamp); } function swapTokensForETH(uint256 tokenAmount) private { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable liquidityAddress, 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); _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); _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); _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); _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) private { if(buyOrSellSwitch == BUY){ _liquidityTokensToSwap += tLiquidity * _buyLiquidityFee / _liquidityFee; _marketingTokensToSwap += tLiquidity * _buyMarketingFee / _liquidityFee; } else if(buyOrSellSwitch == SELL){ _liquidityTokensToSwap += tLiquidity * _sellLiquidityFee / _liquidityFee; _marketingTokensToSwap += tLiquidity * _sellMarketingFee / _liquidityFee; } uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if (_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div(10**2); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div(10**2); } function removeAllFee() private { if (_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function isExcludedFromFee(address account) external view returns (bool) { return _isExcludedFromFee[account]; } function removeBoughtEarly(address account) external onlyOwner { boughtEarly[account] = false; emit RemovedSniper(account); } function excludeFromFee(address account) external onlyOwner { _isExcludedFromFee[account] = true; emit ExcludeFromFee(account); } function includeInFee(address account) external onlyOwner { _isExcludedFromFee[account] = false; emit IncludeInFee(account); } function setBuyFee(uint256 buyTaxFee, uint256 buyLiquidityFee, uint256 buyMarketingFee) external onlyOwner { _buyTaxFee = buyTaxFee; _buyLiquidityFee = buyLiquidityFee; _buyMarketingFee = buyMarketingFee; require(_buyTaxFee + _buyLiquidityFee + _buyMarketingFee <= 10, "Must keep buy taxes below 10%"); emit SetBuyFee(buyMarketingFee, buyLiquidityFee, buyTaxFee); } function setSellFee(uint256 sellTaxFee, uint256 sellLiquidityFee, uint256 sellMarketingFee) external onlyOwner { _sellTaxFee = sellTaxFee; _sellLiquidityFee = sellLiquidityFee; _sellMarketingFee = sellMarketingFee; require(_sellTaxFee + _sellLiquidityFee + _sellMarketingFee <= 15, "Must keep sell taxes below 15%"); emit SetSellFee(sellMarketingFee, sellLiquidityFee, sellTaxFee); } function setMarketingAddress(address _marketingAddress) external onlyOwner { require(_marketingAddress != address(0), "_marketingAddress address cannot be 0"); _isExcludedFromFee[marketingAddress] = false; marketingAddress = payable(_marketingAddress); _isExcludedFromFee[marketingAddress] = true; emit UpdatedMarketingAddress(_marketingAddress); } function setLiquidityAddress(address _liquidityAddress) public onlyOwner { require(_liquidityAddress != address(0), "_liquidityAddress address cannot be 0"); liquidityAddress = payable(_liquidityAddress); _isExcludedFromFee[liquidityAddress] = true; emit UpdatedLiquidityAddress(_liquidityAddress); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } // To receive ETH from uniswapV2Router when swapping receive() external payable {} function transferForeignToken(address _token, address _to) external onlyOwner returns (bool _sent) { require(_token != address(0), "_token address cannot be 0"); require(_token != address(this), "Can't withdraw native tokens"); uint256 _contractBalance = IERC20(_token).balanceOf(address(this)); _sent = IERC20(_token).transfer(_to, _contractBalance); emit TransferForeignToken(_token, _contractBalance); } // withdraw ETH if stuck before launch function withdrawStuckETH() external onlyOwner { require(!tradingActive, "Can only withdraw if trading hasn't started"); bool success; (success,) = address(msg.sender).call{value: address(this).balance}(""); } }
removeLimits
function removeLimits() external onlyOwner returns (bool){ limitsInEffect = false; gasLimitActive = false; transferDelayEnabled = false; return true; }
// remove limits after token is stable - 30-60 minutes
LineComment
v0.8.9+commit.e5eed63a
{ "func_code_index": [ 8098, 8289 ] }
5,123
TetoInu
/home/dimitris/Documents/Code/ApeNFTs/TetoInu/contracts/TetoInu.sol
0x09dc17ad20e864f91951789c80785ae1ca024230
Solidity
TetoInu
contract TetoInu is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; address payable public marketingAddress; address payable public devAddress; address payable public liquidityAddress; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; // Anti-bot and anti-whale mappings and variables mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch bool public transferDelayEnabled = true; bool public limitsInEffect = true; mapping(address => bool) private _isExcludedFromFee; mapping(address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1 * 1e15 * 1e9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private constant _name = "Teto Inu"; string private constant _symbol = "TetoInu"; uint8 private constant _decimals = 9; // these values are pretty much arbitrary since they get overwritten for every txn, but the placeholders make it easier to work with current contract. uint256 private _taxFee; uint256 private _previousTaxFee = _taxFee; uint256 private _marketingFee; uint256 private _liquidityFee; uint256 private _previousLiquidityFee = _liquidityFee; uint256 private constant BUY = 1; uint256 private constant SELL = 2; uint256 private constant TRANSFER = 3; uint256 private buyOrSellSwitch; uint256 public _buyTaxFee = 2; uint256 public _buyLiquidityFee = 1; uint256 public _buyMarketingFee = 7; uint256 public _sellTaxFee = 2; uint256 public _sellLiquidityFee = 1; uint256 public _sellMarketingFee = 7; uint256 public tradingActiveBlock = 0; // 0 means trading is not active mapping(address => bool) public boughtEarly; // mapping to track addresses that buy within the first 2 blocks pay a 3x tax for 24 hours to sell uint256 public earlyBuyPenaltyEnd; // determines when snipers/bots can sell without extra penalty uint256 public _liquidityTokensToSwap; uint256 public _marketingTokensToSwap; uint256 public maxTransactionAmount; mapping (address => bool) public _isExcludedMaxTransactionAmount; bool private gasLimitActive = true; uint256 private gasPriceLimit = 500 * 1 gwei; // do not allow over 500 gwei for launch // store addresses that a automatic market maker pairs. Any transfer *to* these addresses // could be subject to a maximum transfer amount mapping (address => bool) public automatedMarketMakerPairs; uint256 private minimumTokensBeforeSwap; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = false; bool public tradingActive = false; event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity ); event SwapETHForTokens(uint256 amountIn, address[] path); event SwapTokensForETH(uint256 amountIn, address[] path); event SetAutomatedMarketMakerPair(address pair, bool value); event ExcludeFromReward(address excludedAddress); event IncludeInReward(address includedAddress); event ExcludeFromFee(address excludedAddress); event IncludeInFee(address includedAddress); event SetBuyFee(uint256 marketingFee, uint256 liquidityFee, uint256 reflectFee); event SetSellFee(uint256 marketingFee, uint256 liquidityFee, uint256 reflectFee); event TransferForeignToken(address token, uint256 amount); event UpdatedMarketingAddress(address marketing); event UpdatedLiquidityAddress(address liquidity); event OwnerForcedSwapBack(uint256 timestamp); event BoughtEarly(address indexed sniper); event RemovedSniper(address indexed notsnipersupposedly); modifier lockTheSwap() { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor() payable { _rOwned[_msgSender()] = _rTotal / 1000 * 30; _rOwned[address(this)] = _rTotal / 1000 * 970; maxTransactionAmount = _tTotal * 5 / 1000; // 0.5% maxTransactionAmountTxn minimumTokensBeforeSwap = _tTotal * 5 / 10000; // 0.05% swap tokens amount marketingAddress = payable(0xC32d316238C5811441863D0F2961167C755397f9); // Marketing Address devAddress = payable(0x65029D6872DeDD7D5344c20d1fe4C23bb6D3059D); // Dev Address liquidityAddress = payable(owner()); // Liquidity Address (switches to dead address once launch happens) _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[marketingAddress] = true; _isExcludedFromFee[liquidityAddress] = true; excludeFromMaxTransaction(owner(), true); excludeFromMaxTransaction(address(this), true); excludeFromMaxTransaction(address(0xdead), true); emit Transfer(address(0), _msgSender(), _tTotal * 30 / 1000); emit Transfer(address(0), address(this), _tTotal * 970 / 1000); } function name() external pure returns (string memory) { return _name; } function symbol() external pure returns (string memory) { return _symbol; } function decimals() external pure returns (uint8) { return _decimals; } function totalSupply() external pure 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) external override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) external 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 ) external 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) external virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue) ); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) external virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender].sub( subtractedValue, "ERC20: decreased allowance below zero" ) ); return true; } function isExcludedFromReward(address account) external view returns (bool) { return _isExcluded[account]; } function totalFees() external view returns (uint256) { return _tFeeTotal; } // remove limits after token is stable - 30-60 minutes function removeLimits() external onlyOwner returns (bool){ limitsInEffect = false; gasLimitActive = false; transferDelayEnabled = false; return true; } // disable Transfer delay function disableTransferDelay() external onlyOwner returns (bool){ transferDelayEnabled = false; return true; } function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner { _isExcludedMaxTransactionAmount[updAds] = isEx; } // once enabled, can never be turned off function enableTrading() internal onlyOwner { tradingActive = true; swapAndLiquifyEnabled = true; tradingActiveBlock = block.number; earlyBuyPenaltyEnd = block.timestamp + 72 hours; } // send tokens and ETH for liquidity to contract directly, then call this function. //(not required, can still use Uniswap to add liquidity manually, but this ensures everything is excluded properly and makes for a great stealth launch) function launch(address[] memory airdropWallets, uint256[] memory amounts) external onlyOwner returns (bool){ require(!tradingActive, "Trading is already active, cannot relaunch."); require(airdropWallets.length < 200, "Can only airdrop 200 wallets per txn due to gas limits"); // allows for airdrop + launch at the same exact time, reducing delays and reducing sniper input. for(uint256 i = 0; i < airdropWallets.length; i++){ address wallet = airdropWallets[i]; uint256 amount = amounts[i]; _transfer(msg.sender, wallet, amount); } enableTrading(); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); excludeFromMaxTransaction(address(_uniswapV2Router), true); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); excludeFromMaxTransaction(address(uniswapV2Pair), true); _setAutomatedMarketMakerPair(address(uniswapV2Pair), true); require(address(this).balance > 0, "Must have ETH on contract to launch"); addLiquidity(balanceOf(address(this)), address(this).balance); //setLiquidityAddress(address(0xdead)); return true; } function minimumTokensBeforeSwapAmount() external view returns (uint256) { return minimumTokensBeforeSwap; } function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require(pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs"); _setAutomatedMarketMakerPair(pair, value); } function _setAutomatedMarketMakerPair(address pair, bool value) private { automatedMarketMakerPairs[pair] = value; _isExcludedMaxTransactionAmount[pair] = value; if(value){excludeFromReward(pair);} if(!value){includeInReward(pair);} } function setGasPriceLimit(uint256 gas) external onlyOwner { require(gas >= 200); gasPriceLimit = gas * 1 gwei; } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) external 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"); require(_excluded.length + 1 <= 50, "Cannot exclude more than 50 accounts. Include a previously excluded address."); if (_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) public onlyOwner { require(_isExcluded[account], "Account is not 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 { //########### MARKER ############################################ require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(!tradingActive){ require(_isExcludedFromFee[from] || _isExcludedFromFee[to], "Trading not active yet!"); } if(limitsInEffect){ if ( from != owner() && to != owner() && to != address(0) && to != address(0xdead) && !inSwapAndLiquify ){ if(from != owner() && to != uniswapV2Pair && block.number == tradingActiveBlock){ boughtEarly[to] = true; emit BoughtEarly(to); } // only use to prevent sniper buys in the first blocks. if (gasLimitActive && automatedMarketMakerPairs[from]) { require(tx.gasprice <= gasPriceLimit, "Gas price exceeds limit."); } // at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch. if (transferDelayEnabled){ if (to != owner() && to != address(uniswapV2Router) && to != address(uniswapV2Pair)){ require(_holderLastTransferTimestamp[to] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed."); _holderLastTransferTimestamp[to] = block.number; } } //when buy if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) { require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount."); } //when sell else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) { require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount."); } } } uint256 totalTokensToSwap = _liquidityTokensToSwap.add(_marketingTokensToSwap); uint256 contractTokenBalance = balanceOf(address(this)); bool overMinimumTokenBalance = contractTokenBalance >= minimumTokensBeforeSwap; // swap and liquify if ( !inSwapAndLiquify && swapAndLiquifyEnabled && balanceOf(uniswapV2Pair) > 0 && totalTokensToSwap > 0 && !_isExcludedFromFee[to] && !_isExcludedFromFee[from] && automatedMarketMakerPairs[to] && overMinimumTokenBalance ) { swapBack(); } bool takeFee = true; // If any account belongs to _isExcludedFromFee account then remove the fee if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) { takeFee = false; buyOrSellSwitch = TRANSFER; // TRANSFERs do not pay a tax. } else { // Buy if (automatedMarketMakerPairs[from]) { removeAllFee(); _taxFee = _buyTaxFee; _liquidityFee = _buyLiquidityFee + _buyMarketingFee; buyOrSellSwitch = BUY; } // Sell else if (automatedMarketMakerPairs[to]) { removeAllFee(); _taxFee = _sellTaxFee; _liquidityFee = _sellLiquidityFee + _sellMarketingFee; buyOrSellSwitch = SELL; // higher tax if bought in the same block as trading active for 72 hours (sniper protect) if(boughtEarly[from] && earlyBuyPenaltyEnd > block.timestamp){ _taxFee = _taxFee * 5; _liquidityFee = _liquidityFee * 5; } // Normal transfers do not get taxed } else { require(!boughtEarly[from] || earlyBuyPenaltyEnd <= block.timestamp, "Snipers can't transfer tokens to sell cheaper until penalty timeframe is over. DM a TetoInu Mod."); removeAllFee(); buyOrSellSwitch = TRANSFER; // TRANSFERs do not pay a tax. } } _tokenTransfer(from, to, amount, takeFee); } function swapBack() private lockTheSwap { uint256 contractBalance = balanceOf(address(this)); uint256 totalTokensToSwap = _liquidityTokensToSwap + _marketingTokensToSwap; // Halve the amount of liquidity tokens uint256 tokensForLiquidity = _liquidityTokensToSwap.div(2); uint256 amountToSwapForETH = contractBalance.sub(tokensForLiquidity); uint256 initialETHBalance = address(this).balance; swapTokensForETH(amountToSwapForETH); uint256 ethBalance = address(this).balance.sub(initialETHBalance); uint256 ethForMarketing = ethBalance.mul(_marketingTokensToSwap).div(totalTokensToSwap); uint256 ethForLiquidity = ethBalance.sub(ethForMarketing); uint256 ethForDev= ethForMarketing * 2 / 7; // 2/7 goes to dev ethForMarketing -= ethForDev; _liquidityTokensToSwap = 0; _marketingTokensToSwap = 0; (bool success,) = address(marketingAddress).call{value: ethForMarketing}(""); (success,) = address(devAddress).call{value: ethForDev}(""); addLiquidity(tokensForLiquidity, ethForLiquidity); emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, tokensForLiquidity); // send leftover ETH to the marketing wallet so it doesn't get stuck on the contract. if(address(this).balance > 1e17){ (success,) = address(marketingAddress).call{value: address(this).balance}(""); } } // force Swap back if slippage above 49% for launch. function forceSwapBack() external onlyOwner { uint256 contractBalance = balanceOf(address(this)); require(contractBalance >= _tTotal / 100, "Can only swap back if more than 1% of tokens stuck on contract"); swapBack(); emit OwnerForcedSwapBack(block.timestamp); } function swapTokensForETH(uint256 tokenAmount) private { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable liquidityAddress, 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); _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); _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); _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); _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) private { if(buyOrSellSwitch == BUY){ _liquidityTokensToSwap += tLiquidity * _buyLiquidityFee / _liquidityFee; _marketingTokensToSwap += tLiquidity * _buyMarketingFee / _liquidityFee; } else if(buyOrSellSwitch == SELL){ _liquidityTokensToSwap += tLiquidity * _sellLiquidityFee / _liquidityFee; _marketingTokensToSwap += tLiquidity * _sellMarketingFee / _liquidityFee; } uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if (_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div(10**2); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div(10**2); } function removeAllFee() private { if (_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function isExcludedFromFee(address account) external view returns (bool) { return _isExcludedFromFee[account]; } function removeBoughtEarly(address account) external onlyOwner { boughtEarly[account] = false; emit RemovedSniper(account); } function excludeFromFee(address account) external onlyOwner { _isExcludedFromFee[account] = true; emit ExcludeFromFee(account); } function includeInFee(address account) external onlyOwner { _isExcludedFromFee[account] = false; emit IncludeInFee(account); } function setBuyFee(uint256 buyTaxFee, uint256 buyLiquidityFee, uint256 buyMarketingFee) external onlyOwner { _buyTaxFee = buyTaxFee; _buyLiquidityFee = buyLiquidityFee; _buyMarketingFee = buyMarketingFee; require(_buyTaxFee + _buyLiquidityFee + _buyMarketingFee <= 10, "Must keep buy taxes below 10%"); emit SetBuyFee(buyMarketingFee, buyLiquidityFee, buyTaxFee); } function setSellFee(uint256 sellTaxFee, uint256 sellLiquidityFee, uint256 sellMarketingFee) external onlyOwner { _sellTaxFee = sellTaxFee; _sellLiquidityFee = sellLiquidityFee; _sellMarketingFee = sellMarketingFee; require(_sellTaxFee + _sellLiquidityFee + _sellMarketingFee <= 15, "Must keep sell taxes below 15%"); emit SetSellFee(sellMarketingFee, sellLiquidityFee, sellTaxFee); } function setMarketingAddress(address _marketingAddress) external onlyOwner { require(_marketingAddress != address(0), "_marketingAddress address cannot be 0"); _isExcludedFromFee[marketingAddress] = false; marketingAddress = payable(_marketingAddress); _isExcludedFromFee[marketingAddress] = true; emit UpdatedMarketingAddress(_marketingAddress); } function setLiquidityAddress(address _liquidityAddress) public onlyOwner { require(_liquidityAddress != address(0), "_liquidityAddress address cannot be 0"); liquidityAddress = payable(_liquidityAddress); _isExcludedFromFee[liquidityAddress] = true; emit UpdatedLiquidityAddress(_liquidityAddress); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } // To receive ETH from uniswapV2Router when swapping receive() external payable {} function transferForeignToken(address _token, address _to) external onlyOwner returns (bool _sent) { require(_token != address(0), "_token address cannot be 0"); require(_token != address(this), "Can't withdraw native tokens"); uint256 _contractBalance = IERC20(_token).balanceOf(address(this)); _sent = IERC20(_token).transfer(_to, _contractBalance); emit TransferForeignToken(_token, _contractBalance); } // withdraw ETH if stuck before launch function withdrawStuckETH() external onlyOwner { require(!tradingActive, "Can only withdraw if trading hasn't started"); bool success; (success,) = address(msg.sender).call{value: address(this).balance}(""); } }
disableTransferDelay
function disableTransferDelay() external onlyOwner returns (bool){ transferDelayEnabled = false; return true; }
// disable Transfer delay
LineComment
v0.8.9+commit.e5eed63a
{ "func_code_index": [ 8325, 8460 ] }
5,124
TetoInu
/home/dimitris/Documents/Code/ApeNFTs/TetoInu/contracts/TetoInu.sol
0x09dc17ad20e864f91951789c80785ae1ca024230
Solidity
TetoInu
contract TetoInu is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; address payable public marketingAddress; address payable public devAddress; address payable public liquidityAddress; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; // Anti-bot and anti-whale mappings and variables mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch bool public transferDelayEnabled = true; bool public limitsInEffect = true; mapping(address => bool) private _isExcludedFromFee; mapping(address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1 * 1e15 * 1e9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private constant _name = "Teto Inu"; string private constant _symbol = "TetoInu"; uint8 private constant _decimals = 9; // these values are pretty much arbitrary since they get overwritten for every txn, but the placeholders make it easier to work with current contract. uint256 private _taxFee; uint256 private _previousTaxFee = _taxFee; uint256 private _marketingFee; uint256 private _liquidityFee; uint256 private _previousLiquidityFee = _liquidityFee; uint256 private constant BUY = 1; uint256 private constant SELL = 2; uint256 private constant TRANSFER = 3; uint256 private buyOrSellSwitch; uint256 public _buyTaxFee = 2; uint256 public _buyLiquidityFee = 1; uint256 public _buyMarketingFee = 7; uint256 public _sellTaxFee = 2; uint256 public _sellLiquidityFee = 1; uint256 public _sellMarketingFee = 7; uint256 public tradingActiveBlock = 0; // 0 means trading is not active mapping(address => bool) public boughtEarly; // mapping to track addresses that buy within the first 2 blocks pay a 3x tax for 24 hours to sell uint256 public earlyBuyPenaltyEnd; // determines when snipers/bots can sell without extra penalty uint256 public _liquidityTokensToSwap; uint256 public _marketingTokensToSwap; uint256 public maxTransactionAmount; mapping (address => bool) public _isExcludedMaxTransactionAmount; bool private gasLimitActive = true; uint256 private gasPriceLimit = 500 * 1 gwei; // do not allow over 500 gwei for launch // store addresses that a automatic market maker pairs. Any transfer *to* these addresses // could be subject to a maximum transfer amount mapping (address => bool) public automatedMarketMakerPairs; uint256 private minimumTokensBeforeSwap; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = false; bool public tradingActive = false; event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity ); event SwapETHForTokens(uint256 amountIn, address[] path); event SwapTokensForETH(uint256 amountIn, address[] path); event SetAutomatedMarketMakerPair(address pair, bool value); event ExcludeFromReward(address excludedAddress); event IncludeInReward(address includedAddress); event ExcludeFromFee(address excludedAddress); event IncludeInFee(address includedAddress); event SetBuyFee(uint256 marketingFee, uint256 liquidityFee, uint256 reflectFee); event SetSellFee(uint256 marketingFee, uint256 liquidityFee, uint256 reflectFee); event TransferForeignToken(address token, uint256 amount); event UpdatedMarketingAddress(address marketing); event UpdatedLiquidityAddress(address liquidity); event OwnerForcedSwapBack(uint256 timestamp); event BoughtEarly(address indexed sniper); event RemovedSniper(address indexed notsnipersupposedly); modifier lockTheSwap() { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor() payable { _rOwned[_msgSender()] = _rTotal / 1000 * 30; _rOwned[address(this)] = _rTotal / 1000 * 970; maxTransactionAmount = _tTotal * 5 / 1000; // 0.5% maxTransactionAmountTxn minimumTokensBeforeSwap = _tTotal * 5 / 10000; // 0.05% swap tokens amount marketingAddress = payable(0xC32d316238C5811441863D0F2961167C755397f9); // Marketing Address devAddress = payable(0x65029D6872DeDD7D5344c20d1fe4C23bb6D3059D); // Dev Address liquidityAddress = payable(owner()); // Liquidity Address (switches to dead address once launch happens) _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[marketingAddress] = true; _isExcludedFromFee[liquidityAddress] = true; excludeFromMaxTransaction(owner(), true); excludeFromMaxTransaction(address(this), true); excludeFromMaxTransaction(address(0xdead), true); emit Transfer(address(0), _msgSender(), _tTotal * 30 / 1000); emit Transfer(address(0), address(this), _tTotal * 970 / 1000); } function name() external pure returns (string memory) { return _name; } function symbol() external pure returns (string memory) { return _symbol; } function decimals() external pure returns (uint8) { return _decimals; } function totalSupply() external pure 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) external override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) external 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 ) external 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) external virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue) ); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) external virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender].sub( subtractedValue, "ERC20: decreased allowance below zero" ) ); return true; } function isExcludedFromReward(address account) external view returns (bool) { return _isExcluded[account]; } function totalFees() external view returns (uint256) { return _tFeeTotal; } // remove limits after token is stable - 30-60 minutes function removeLimits() external onlyOwner returns (bool){ limitsInEffect = false; gasLimitActive = false; transferDelayEnabled = false; return true; } // disable Transfer delay function disableTransferDelay() external onlyOwner returns (bool){ transferDelayEnabled = false; return true; } function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner { _isExcludedMaxTransactionAmount[updAds] = isEx; } // once enabled, can never be turned off function enableTrading() internal onlyOwner { tradingActive = true; swapAndLiquifyEnabled = true; tradingActiveBlock = block.number; earlyBuyPenaltyEnd = block.timestamp + 72 hours; } // send tokens and ETH for liquidity to contract directly, then call this function. //(not required, can still use Uniswap to add liquidity manually, but this ensures everything is excluded properly and makes for a great stealth launch) function launch(address[] memory airdropWallets, uint256[] memory amounts) external onlyOwner returns (bool){ require(!tradingActive, "Trading is already active, cannot relaunch."); require(airdropWallets.length < 200, "Can only airdrop 200 wallets per txn due to gas limits"); // allows for airdrop + launch at the same exact time, reducing delays and reducing sniper input. for(uint256 i = 0; i < airdropWallets.length; i++){ address wallet = airdropWallets[i]; uint256 amount = amounts[i]; _transfer(msg.sender, wallet, amount); } enableTrading(); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); excludeFromMaxTransaction(address(_uniswapV2Router), true); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); excludeFromMaxTransaction(address(uniswapV2Pair), true); _setAutomatedMarketMakerPair(address(uniswapV2Pair), true); require(address(this).balance > 0, "Must have ETH on contract to launch"); addLiquidity(balanceOf(address(this)), address(this).balance); //setLiquidityAddress(address(0xdead)); return true; } function minimumTokensBeforeSwapAmount() external view returns (uint256) { return minimumTokensBeforeSwap; } function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require(pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs"); _setAutomatedMarketMakerPair(pair, value); } function _setAutomatedMarketMakerPair(address pair, bool value) private { automatedMarketMakerPairs[pair] = value; _isExcludedMaxTransactionAmount[pair] = value; if(value){excludeFromReward(pair);} if(!value){includeInReward(pair);} } function setGasPriceLimit(uint256 gas) external onlyOwner { require(gas >= 200); gasPriceLimit = gas * 1 gwei; } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) external 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"); require(_excluded.length + 1 <= 50, "Cannot exclude more than 50 accounts. Include a previously excluded address."); if (_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) public onlyOwner { require(_isExcluded[account], "Account is not 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 { //########### MARKER ############################################ require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(!tradingActive){ require(_isExcludedFromFee[from] || _isExcludedFromFee[to], "Trading not active yet!"); } if(limitsInEffect){ if ( from != owner() && to != owner() && to != address(0) && to != address(0xdead) && !inSwapAndLiquify ){ if(from != owner() && to != uniswapV2Pair && block.number == tradingActiveBlock){ boughtEarly[to] = true; emit BoughtEarly(to); } // only use to prevent sniper buys in the first blocks. if (gasLimitActive && automatedMarketMakerPairs[from]) { require(tx.gasprice <= gasPriceLimit, "Gas price exceeds limit."); } // at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch. if (transferDelayEnabled){ if (to != owner() && to != address(uniswapV2Router) && to != address(uniswapV2Pair)){ require(_holderLastTransferTimestamp[to] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed."); _holderLastTransferTimestamp[to] = block.number; } } //when buy if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) { require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount."); } //when sell else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) { require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount."); } } } uint256 totalTokensToSwap = _liquidityTokensToSwap.add(_marketingTokensToSwap); uint256 contractTokenBalance = balanceOf(address(this)); bool overMinimumTokenBalance = contractTokenBalance >= minimumTokensBeforeSwap; // swap and liquify if ( !inSwapAndLiquify && swapAndLiquifyEnabled && balanceOf(uniswapV2Pair) > 0 && totalTokensToSwap > 0 && !_isExcludedFromFee[to] && !_isExcludedFromFee[from] && automatedMarketMakerPairs[to] && overMinimumTokenBalance ) { swapBack(); } bool takeFee = true; // If any account belongs to _isExcludedFromFee account then remove the fee if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) { takeFee = false; buyOrSellSwitch = TRANSFER; // TRANSFERs do not pay a tax. } else { // Buy if (automatedMarketMakerPairs[from]) { removeAllFee(); _taxFee = _buyTaxFee; _liquidityFee = _buyLiquidityFee + _buyMarketingFee; buyOrSellSwitch = BUY; } // Sell else if (automatedMarketMakerPairs[to]) { removeAllFee(); _taxFee = _sellTaxFee; _liquidityFee = _sellLiquidityFee + _sellMarketingFee; buyOrSellSwitch = SELL; // higher tax if bought in the same block as trading active for 72 hours (sniper protect) if(boughtEarly[from] && earlyBuyPenaltyEnd > block.timestamp){ _taxFee = _taxFee * 5; _liquidityFee = _liquidityFee * 5; } // Normal transfers do not get taxed } else { require(!boughtEarly[from] || earlyBuyPenaltyEnd <= block.timestamp, "Snipers can't transfer tokens to sell cheaper until penalty timeframe is over. DM a TetoInu Mod."); removeAllFee(); buyOrSellSwitch = TRANSFER; // TRANSFERs do not pay a tax. } } _tokenTransfer(from, to, amount, takeFee); } function swapBack() private lockTheSwap { uint256 contractBalance = balanceOf(address(this)); uint256 totalTokensToSwap = _liquidityTokensToSwap + _marketingTokensToSwap; // Halve the amount of liquidity tokens uint256 tokensForLiquidity = _liquidityTokensToSwap.div(2); uint256 amountToSwapForETH = contractBalance.sub(tokensForLiquidity); uint256 initialETHBalance = address(this).balance; swapTokensForETH(amountToSwapForETH); uint256 ethBalance = address(this).balance.sub(initialETHBalance); uint256 ethForMarketing = ethBalance.mul(_marketingTokensToSwap).div(totalTokensToSwap); uint256 ethForLiquidity = ethBalance.sub(ethForMarketing); uint256 ethForDev= ethForMarketing * 2 / 7; // 2/7 goes to dev ethForMarketing -= ethForDev; _liquidityTokensToSwap = 0; _marketingTokensToSwap = 0; (bool success,) = address(marketingAddress).call{value: ethForMarketing}(""); (success,) = address(devAddress).call{value: ethForDev}(""); addLiquidity(tokensForLiquidity, ethForLiquidity); emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, tokensForLiquidity); // send leftover ETH to the marketing wallet so it doesn't get stuck on the contract. if(address(this).balance > 1e17){ (success,) = address(marketingAddress).call{value: address(this).balance}(""); } } // force Swap back if slippage above 49% for launch. function forceSwapBack() external onlyOwner { uint256 contractBalance = balanceOf(address(this)); require(contractBalance >= _tTotal / 100, "Can only swap back if more than 1% of tokens stuck on contract"); swapBack(); emit OwnerForcedSwapBack(block.timestamp); } function swapTokensForETH(uint256 tokenAmount) private { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable liquidityAddress, 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); _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); _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); _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); _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) private { if(buyOrSellSwitch == BUY){ _liquidityTokensToSwap += tLiquidity * _buyLiquidityFee / _liquidityFee; _marketingTokensToSwap += tLiquidity * _buyMarketingFee / _liquidityFee; } else if(buyOrSellSwitch == SELL){ _liquidityTokensToSwap += tLiquidity * _sellLiquidityFee / _liquidityFee; _marketingTokensToSwap += tLiquidity * _sellMarketingFee / _liquidityFee; } uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if (_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div(10**2); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div(10**2); } function removeAllFee() private { if (_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function isExcludedFromFee(address account) external view returns (bool) { return _isExcludedFromFee[account]; } function removeBoughtEarly(address account) external onlyOwner { boughtEarly[account] = false; emit RemovedSniper(account); } function excludeFromFee(address account) external onlyOwner { _isExcludedFromFee[account] = true; emit ExcludeFromFee(account); } function includeInFee(address account) external onlyOwner { _isExcludedFromFee[account] = false; emit IncludeInFee(account); } function setBuyFee(uint256 buyTaxFee, uint256 buyLiquidityFee, uint256 buyMarketingFee) external onlyOwner { _buyTaxFee = buyTaxFee; _buyLiquidityFee = buyLiquidityFee; _buyMarketingFee = buyMarketingFee; require(_buyTaxFee + _buyLiquidityFee + _buyMarketingFee <= 10, "Must keep buy taxes below 10%"); emit SetBuyFee(buyMarketingFee, buyLiquidityFee, buyTaxFee); } function setSellFee(uint256 sellTaxFee, uint256 sellLiquidityFee, uint256 sellMarketingFee) external onlyOwner { _sellTaxFee = sellTaxFee; _sellLiquidityFee = sellLiquidityFee; _sellMarketingFee = sellMarketingFee; require(_sellTaxFee + _sellLiquidityFee + _sellMarketingFee <= 15, "Must keep sell taxes below 15%"); emit SetSellFee(sellMarketingFee, sellLiquidityFee, sellTaxFee); } function setMarketingAddress(address _marketingAddress) external onlyOwner { require(_marketingAddress != address(0), "_marketingAddress address cannot be 0"); _isExcludedFromFee[marketingAddress] = false; marketingAddress = payable(_marketingAddress); _isExcludedFromFee[marketingAddress] = true; emit UpdatedMarketingAddress(_marketingAddress); } function setLiquidityAddress(address _liquidityAddress) public onlyOwner { require(_liquidityAddress != address(0), "_liquidityAddress address cannot be 0"); liquidityAddress = payable(_liquidityAddress); _isExcludedFromFee[liquidityAddress] = true; emit UpdatedLiquidityAddress(_liquidityAddress); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } // To receive ETH from uniswapV2Router when swapping receive() external payable {} function transferForeignToken(address _token, address _to) external onlyOwner returns (bool _sent) { require(_token != address(0), "_token address cannot be 0"); require(_token != address(this), "Can't withdraw native tokens"); uint256 _contractBalance = IERC20(_token).balanceOf(address(this)); _sent = IERC20(_token).transfer(_to, _contractBalance); emit TransferForeignToken(_token, _contractBalance); } // withdraw ETH if stuck before launch function withdrawStuckETH() external onlyOwner { require(!tradingActive, "Can only withdraw if trading hasn't started"); bool success; (success,) = address(msg.sender).call{value: address(this).balance}(""); } }
enableTrading
function enableTrading() internal onlyOwner { tradingActive = true; swapAndLiquifyEnabled = true; tradingActiveBlock = block.number; earlyBuyPenaltyEnd = block.timestamp + 72 hours; }
// once enabled, can never be turned off
LineComment
v0.8.9+commit.e5eed63a
{ "func_code_index": [ 8663, 8886 ] }
5,125
TetoInu
/home/dimitris/Documents/Code/ApeNFTs/TetoInu/contracts/TetoInu.sol
0x09dc17ad20e864f91951789c80785ae1ca024230
Solidity
TetoInu
contract TetoInu is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; address payable public marketingAddress; address payable public devAddress; address payable public liquidityAddress; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; // Anti-bot and anti-whale mappings and variables mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch bool public transferDelayEnabled = true; bool public limitsInEffect = true; mapping(address => bool) private _isExcludedFromFee; mapping(address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1 * 1e15 * 1e9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private constant _name = "Teto Inu"; string private constant _symbol = "TetoInu"; uint8 private constant _decimals = 9; // these values are pretty much arbitrary since they get overwritten for every txn, but the placeholders make it easier to work with current contract. uint256 private _taxFee; uint256 private _previousTaxFee = _taxFee; uint256 private _marketingFee; uint256 private _liquidityFee; uint256 private _previousLiquidityFee = _liquidityFee; uint256 private constant BUY = 1; uint256 private constant SELL = 2; uint256 private constant TRANSFER = 3; uint256 private buyOrSellSwitch; uint256 public _buyTaxFee = 2; uint256 public _buyLiquidityFee = 1; uint256 public _buyMarketingFee = 7; uint256 public _sellTaxFee = 2; uint256 public _sellLiquidityFee = 1; uint256 public _sellMarketingFee = 7; uint256 public tradingActiveBlock = 0; // 0 means trading is not active mapping(address => bool) public boughtEarly; // mapping to track addresses that buy within the first 2 blocks pay a 3x tax for 24 hours to sell uint256 public earlyBuyPenaltyEnd; // determines when snipers/bots can sell without extra penalty uint256 public _liquidityTokensToSwap; uint256 public _marketingTokensToSwap; uint256 public maxTransactionAmount; mapping (address => bool) public _isExcludedMaxTransactionAmount; bool private gasLimitActive = true; uint256 private gasPriceLimit = 500 * 1 gwei; // do not allow over 500 gwei for launch // store addresses that a automatic market maker pairs. Any transfer *to* these addresses // could be subject to a maximum transfer amount mapping (address => bool) public automatedMarketMakerPairs; uint256 private minimumTokensBeforeSwap; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = false; bool public tradingActive = false; event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity ); event SwapETHForTokens(uint256 amountIn, address[] path); event SwapTokensForETH(uint256 amountIn, address[] path); event SetAutomatedMarketMakerPair(address pair, bool value); event ExcludeFromReward(address excludedAddress); event IncludeInReward(address includedAddress); event ExcludeFromFee(address excludedAddress); event IncludeInFee(address includedAddress); event SetBuyFee(uint256 marketingFee, uint256 liquidityFee, uint256 reflectFee); event SetSellFee(uint256 marketingFee, uint256 liquidityFee, uint256 reflectFee); event TransferForeignToken(address token, uint256 amount); event UpdatedMarketingAddress(address marketing); event UpdatedLiquidityAddress(address liquidity); event OwnerForcedSwapBack(uint256 timestamp); event BoughtEarly(address indexed sniper); event RemovedSniper(address indexed notsnipersupposedly); modifier lockTheSwap() { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor() payable { _rOwned[_msgSender()] = _rTotal / 1000 * 30; _rOwned[address(this)] = _rTotal / 1000 * 970; maxTransactionAmount = _tTotal * 5 / 1000; // 0.5% maxTransactionAmountTxn minimumTokensBeforeSwap = _tTotal * 5 / 10000; // 0.05% swap tokens amount marketingAddress = payable(0xC32d316238C5811441863D0F2961167C755397f9); // Marketing Address devAddress = payable(0x65029D6872DeDD7D5344c20d1fe4C23bb6D3059D); // Dev Address liquidityAddress = payable(owner()); // Liquidity Address (switches to dead address once launch happens) _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[marketingAddress] = true; _isExcludedFromFee[liquidityAddress] = true; excludeFromMaxTransaction(owner(), true); excludeFromMaxTransaction(address(this), true); excludeFromMaxTransaction(address(0xdead), true); emit Transfer(address(0), _msgSender(), _tTotal * 30 / 1000); emit Transfer(address(0), address(this), _tTotal * 970 / 1000); } function name() external pure returns (string memory) { return _name; } function symbol() external pure returns (string memory) { return _symbol; } function decimals() external pure returns (uint8) { return _decimals; } function totalSupply() external pure 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) external override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) external 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 ) external 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) external virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue) ); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) external virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender].sub( subtractedValue, "ERC20: decreased allowance below zero" ) ); return true; } function isExcludedFromReward(address account) external view returns (bool) { return _isExcluded[account]; } function totalFees() external view returns (uint256) { return _tFeeTotal; } // remove limits after token is stable - 30-60 minutes function removeLimits() external onlyOwner returns (bool){ limitsInEffect = false; gasLimitActive = false; transferDelayEnabled = false; return true; } // disable Transfer delay function disableTransferDelay() external onlyOwner returns (bool){ transferDelayEnabled = false; return true; } function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner { _isExcludedMaxTransactionAmount[updAds] = isEx; } // once enabled, can never be turned off function enableTrading() internal onlyOwner { tradingActive = true; swapAndLiquifyEnabled = true; tradingActiveBlock = block.number; earlyBuyPenaltyEnd = block.timestamp + 72 hours; } // send tokens and ETH for liquidity to contract directly, then call this function. //(not required, can still use Uniswap to add liquidity manually, but this ensures everything is excluded properly and makes for a great stealth launch) function launch(address[] memory airdropWallets, uint256[] memory amounts) external onlyOwner returns (bool){ require(!tradingActive, "Trading is already active, cannot relaunch."); require(airdropWallets.length < 200, "Can only airdrop 200 wallets per txn due to gas limits"); // allows for airdrop + launch at the same exact time, reducing delays and reducing sniper input. for(uint256 i = 0; i < airdropWallets.length; i++){ address wallet = airdropWallets[i]; uint256 amount = amounts[i]; _transfer(msg.sender, wallet, amount); } enableTrading(); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); excludeFromMaxTransaction(address(_uniswapV2Router), true); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); excludeFromMaxTransaction(address(uniswapV2Pair), true); _setAutomatedMarketMakerPair(address(uniswapV2Pair), true); require(address(this).balance > 0, "Must have ETH on contract to launch"); addLiquidity(balanceOf(address(this)), address(this).balance); //setLiquidityAddress(address(0xdead)); return true; } function minimumTokensBeforeSwapAmount() external view returns (uint256) { return minimumTokensBeforeSwap; } function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require(pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs"); _setAutomatedMarketMakerPair(pair, value); } function _setAutomatedMarketMakerPair(address pair, bool value) private { automatedMarketMakerPairs[pair] = value; _isExcludedMaxTransactionAmount[pair] = value; if(value){excludeFromReward(pair);} if(!value){includeInReward(pair);} } function setGasPriceLimit(uint256 gas) external onlyOwner { require(gas >= 200); gasPriceLimit = gas * 1 gwei; } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) external 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"); require(_excluded.length + 1 <= 50, "Cannot exclude more than 50 accounts. Include a previously excluded address."); if (_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) public onlyOwner { require(_isExcluded[account], "Account is not 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 { //########### MARKER ############################################ require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(!tradingActive){ require(_isExcludedFromFee[from] || _isExcludedFromFee[to], "Trading not active yet!"); } if(limitsInEffect){ if ( from != owner() && to != owner() && to != address(0) && to != address(0xdead) && !inSwapAndLiquify ){ if(from != owner() && to != uniswapV2Pair && block.number == tradingActiveBlock){ boughtEarly[to] = true; emit BoughtEarly(to); } // only use to prevent sniper buys in the first blocks. if (gasLimitActive && automatedMarketMakerPairs[from]) { require(tx.gasprice <= gasPriceLimit, "Gas price exceeds limit."); } // at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch. if (transferDelayEnabled){ if (to != owner() && to != address(uniswapV2Router) && to != address(uniswapV2Pair)){ require(_holderLastTransferTimestamp[to] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed."); _holderLastTransferTimestamp[to] = block.number; } } //when buy if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) { require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount."); } //when sell else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) { require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount."); } } } uint256 totalTokensToSwap = _liquidityTokensToSwap.add(_marketingTokensToSwap); uint256 contractTokenBalance = balanceOf(address(this)); bool overMinimumTokenBalance = contractTokenBalance >= minimumTokensBeforeSwap; // swap and liquify if ( !inSwapAndLiquify && swapAndLiquifyEnabled && balanceOf(uniswapV2Pair) > 0 && totalTokensToSwap > 0 && !_isExcludedFromFee[to] && !_isExcludedFromFee[from] && automatedMarketMakerPairs[to] && overMinimumTokenBalance ) { swapBack(); } bool takeFee = true; // If any account belongs to _isExcludedFromFee account then remove the fee if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) { takeFee = false; buyOrSellSwitch = TRANSFER; // TRANSFERs do not pay a tax. } else { // Buy if (automatedMarketMakerPairs[from]) { removeAllFee(); _taxFee = _buyTaxFee; _liquidityFee = _buyLiquidityFee + _buyMarketingFee; buyOrSellSwitch = BUY; } // Sell else if (automatedMarketMakerPairs[to]) { removeAllFee(); _taxFee = _sellTaxFee; _liquidityFee = _sellLiquidityFee + _sellMarketingFee; buyOrSellSwitch = SELL; // higher tax if bought in the same block as trading active for 72 hours (sniper protect) if(boughtEarly[from] && earlyBuyPenaltyEnd > block.timestamp){ _taxFee = _taxFee * 5; _liquidityFee = _liquidityFee * 5; } // Normal transfers do not get taxed } else { require(!boughtEarly[from] || earlyBuyPenaltyEnd <= block.timestamp, "Snipers can't transfer tokens to sell cheaper until penalty timeframe is over. DM a TetoInu Mod."); removeAllFee(); buyOrSellSwitch = TRANSFER; // TRANSFERs do not pay a tax. } } _tokenTransfer(from, to, amount, takeFee); } function swapBack() private lockTheSwap { uint256 contractBalance = balanceOf(address(this)); uint256 totalTokensToSwap = _liquidityTokensToSwap + _marketingTokensToSwap; // Halve the amount of liquidity tokens uint256 tokensForLiquidity = _liquidityTokensToSwap.div(2); uint256 amountToSwapForETH = contractBalance.sub(tokensForLiquidity); uint256 initialETHBalance = address(this).balance; swapTokensForETH(amountToSwapForETH); uint256 ethBalance = address(this).balance.sub(initialETHBalance); uint256 ethForMarketing = ethBalance.mul(_marketingTokensToSwap).div(totalTokensToSwap); uint256 ethForLiquidity = ethBalance.sub(ethForMarketing); uint256 ethForDev= ethForMarketing * 2 / 7; // 2/7 goes to dev ethForMarketing -= ethForDev; _liquidityTokensToSwap = 0; _marketingTokensToSwap = 0; (bool success,) = address(marketingAddress).call{value: ethForMarketing}(""); (success,) = address(devAddress).call{value: ethForDev}(""); addLiquidity(tokensForLiquidity, ethForLiquidity); emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, tokensForLiquidity); // send leftover ETH to the marketing wallet so it doesn't get stuck on the contract. if(address(this).balance > 1e17){ (success,) = address(marketingAddress).call{value: address(this).balance}(""); } } // force Swap back if slippage above 49% for launch. function forceSwapBack() external onlyOwner { uint256 contractBalance = balanceOf(address(this)); require(contractBalance >= _tTotal / 100, "Can only swap back if more than 1% of tokens stuck on contract"); swapBack(); emit OwnerForcedSwapBack(block.timestamp); } function swapTokensForETH(uint256 tokenAmount) private { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable liquidityAddress, 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); _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); _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); _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); _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) private { if(buyOrSellSwitch == BUY){ _liquidityTokensToSwap += tLiquidity * _buyLiquidityFee / _liquidityFee; _marketingTokensToSwap += tLiquidity * _buyMarketingFee / _liquidityFee; } else if(buyOrSellSwitch == SELL){ _liquidityTokensToSwap += tLiquidity * _sellLiquidityFee / _liquidityFee; _marketingTokensToSwap += tLiquidity * _sellMarketingFee / _liquidityFee; } uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if (_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div(10**2); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div(10**2); } function removeAllFee() private { if (_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function isExcludedFromFee(address account) external view returns (bool) { return _isExcludedFromFee[account]; } function removeBoughtEarly(address account) external onlyOwner { boughtEarly[account] = false; emit RemovedSniper(account); } function excludeFromFee(address account) external onlyOwner { _isExcludedFromFee[account] = true; emit ExcludeFromFee(account); } function includeInFee(address account) external onlyOwner { _isExcludedFromFee[account] = false; emit IncludeInFee(account); } function setBuyFee(uint256 buyTaxFee, uint256 buyLiquidityFee, uint256 buyMarketingFee) external onlyOwner { _buyTaxFee = buyTaxFee; _buyLiquidityFee = buyLiquidityFee; _buyMarketingFee = buyMarketingFee; require(_buyTaxFee + _buyLiquidityFee + _buyMarketingFee <= 10, "Must keep buy taxes below 10%"); emit SetBuyFee(buyMarketingFee, buyLiquidityFee, buyTaxFee); } function setSellFee(uint256 sellTaxFee, uint256 sellLiquidityFee, uint256 sellMarketingFee) external onlyOwner { _sellTaxFee = sellTaxFee; _sellLiquidityFee = sellLiquidityFee; _sellMarketingFee = sellMarketingFee; require(_sellTaxFee + _sellLiquidityFee + _sellMarketingFee <= 15, "Must keep sell taxes below 15%"); emit SetSellFee(sellMarketingFee, sellLiquidityFee, sellTaxFee); } function setMarketingAddress(address _marketingAddress) external onlyOwner { require(_marketingAddress != address(0), "_marketingAddress address cannot be 0"); _isExcludedFromFee[marketingAddress] = false; marketingAddress = payable(_marketingAddress); _isExcludedFromFee[marketingAddress] = true; emit UpdatedMarketingAddress(_marketingAddress); } function setLiquidityAddress(address _liquidityAddress) public onlyOwner { require(_liquidityAddress != address(0), "_liquidityAddress address cannot be 0"); liquidityAddress = payable(_liquidityAddress); _isExcludedFromFee[liquidityAddress] = true; emit UpdatedLiquidityAddress(_liquidityAddress); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } // To receive ETH from uniswapV2Router when swapping receive() external payable {} function transferForeignToken(address _token, address _to) external onlyOwner returns (bool _sent) { require(_token != address(0), "_token address cannot be 0"); require(_token != address(this), "Can't withdraw native tokens"); uint256 _contractBalance = IERC20(_token).balanceOf(address(this)); _sent = IERC20(_token).transfer(_to, _contractBalance); emit TransferForeignToken(_token, _contractBalance); } // withdraw ETH if stuck before launch function withdrawStuckETH() external onlyOwner { require(!tradingActive, "Can only withdraw if trading hasn't started"); bool success; (success,) = address(msg.sender).call{value: address(this).balance}(""); } }
launch
function launch(address[] memory airdropWallets, uint256[] memory amounts) external onlyOwner returns (bool){ require(!tradingActive, "Trading is already active, cannot relaunch."); require(airdropWallets.length < 200, "Can only airdrop 200 wallets per txn due to gas limits"); // allows for airdrop + launch at the same exact time, reducing delays and reducing sniper input. for(uint256 i = 0; i < airdropWallets.length; i++){ address wallet = airdropWallets[i]; uint256 amount = amounts[i]; _transfer(msg.sender, wallet, amount); } enableTrading(); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); excludeFromMaxTransaction(address(_uniswapV2Router), true); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); excludeFromMaxTransaction(address(uniswapV2Pair), true); _setAutomatedMarketMakerPair(address(uniswapV2Pair), true); require(address(this).balance > 0, "Must have ETH on contract to launch"); addLiquidity(balanceOf(address(this)), address(this).balance); //setLiquidityAddress(address(0xdead)); return true; }
// send tokens and ETH for liquidity to contract directly, then call this function. //(not required, can still use Uniswap to add liquidity manually, but this ensures everything is excluded properly and makes for a great stealth launch)
LineComment
v0.8.9+commit.e5eed63a
{ "func_code_index": [ 9137, 10541 ] }
5,126
TetoInu
/home/dimitris/Documents/Code/ApeNFTs/TetoInu/contracts/TetoInu.sol
0x09dc17ad20e864f91951789c80785ae1ca024230
Solidity
TetoInu
contract TetoInu is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; address payable public marketingAddress; address payable public devAddress; address payable public liquidityAddress; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; // Anti-bot and anti-whale mappings and variables mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch bool public transferDelayEnabled = true; bool public limitsInEffect = true; mapping(address => bool) private _isExcludedFromFee; mapping(address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1 * 1e15 * 1e9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private constant _name = "Teto Inu"; string private constant _symbol = "TetoInu"; uint8 private constant _decimals = 9; // these values are pretty much arbitrary since they get overwritten for every txn, but the placeholders make it easier to work with current contract. uint256 private _taxFee; uint256 private _previousTaxFee = _taxFee; uint256 private _marketingFee; uint256 private _liquidityFee; uint256 private _previousLiquidityFee = _liquidityFee; uint256 private constant BUY = 1; uint256 private constant SELL = 2; uint256 private constant TRANSFER = 3; uint256 private buyOrSellSwitch; uint256 public _buyTaxFee = 2; uint256 public _buyLiquidityFee = 1; uint256 public _buyMarketingFee = 7; uint256 public _sellTaxFee = 2; uint256 public _sellLiquidityFee = 1; uint256 public _sellMarketingFee = 7; uint256 public tradingActiveBlock = 0; // 0 means trading is not active mapping(address => bool) public boughtEarly; // mapping to track addresses that buy within the first 2 blocks pay a 3x tax for 24 hours to sell uint256 public earlyBuyPenaltyEnd; // determines when snipers/bots can sell without extra penalty uint256 public _liquidityTokensToSwap; uint256 public _marketingTokensToSwap; uint256 public maxTransactionAmount; mapping (address => bool) public _isExcludedMaxTransactionAmount; bool private gasLimitActive = true; uint256 private gasPriceLimit = 500 * 1 gwei; // do not allow over 500 gwei for launch // store addresses that a automatic market maker pairs. Any transfer *to* these addresses // could be subject to a maximum transfer amount mapping (address => bool) public automatedMarketMakerPairs; uint256 private minimumTokensBeforeSwap; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = false; bool public tradingActive = false; event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity ); event SwapETHForTokens(uint256 amountIn, address[] path); event SwapTokensForETH(uint256 amountIn, address[] path); event SetAutomatedMarketMakerPair(address pair, bool value); event ExcludeFromReward(address excludedAddress); event IncludeInReward(address includedAddress); event ExcludeFromFee(address excludedAddress); event IncludeInFee(address includedAddress); event SetBuyFee(uint256 marketingFee, uint256 liquidityFee, uint256 reflectFee); event SetSellFee(uint256 marketingFee, uint256 liquidityFee, uint256 reflectFee); event TransferForeignToken(address token, uint256 amount); event UpdatedMarketingAddress(address marketing); event UpdatedLiquidityAddress(address liquidity); event OwnerForcedSwapBack(uint256 timestamp); event BoughtEarly(address indexed sniper); event RemovedSniper(address indexed notsnipersupposedly); modifier lockTheSwap() { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor() payable { _rOwned[_msgSender()] = _rTotal / 1000 * 30; _rOwned[address(this)] = _rTotal / 1000 * 970; maxTransactionAmount = _tTotal * 5 / 1000; // 0.5% maxTransactionAmountTxn minimumTokensBeforeSwap = _tTotal * 5 / 10000; // 0.05% swap tokens amount marketingAddress = payable(0xC32d316238C5811441863D0F2961167C755397f9); // Marketing Address devAddress = payable(0x65029D6872DeDD7D5344c20d1fe4C23bb6D3059D); // Dev Address liquidityAddress = payable(owner()); // Liquidity Address (switches to dead address once launch happens) _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[marketingAddress] = true; _isExcludedFromFee[liquidityAddress] = true; excludeFromMaxTransaction(owner(), true); excludeFromMaxTransaction(address(this), true); excludeFromMaxTransaction(address(0xdead), true); emit Transfer(address(0), _msgSender(), _tTotal * 30 / 1000); emit Transfer(address(0), address(this), _tTotal * 970 / 1000); } function name() external pure returns (string memory) { return _name; } function symbol() external pure returns (string memory) { return _symbol; } function decimals() external pure returns (uint8) { return _decimals; } function totalSupply() external pure 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) external override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) external 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 ) external 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) external virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue) ); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) external virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender].sub( subtractedValue, "ERC20: decreased allowance below zero" ) ); return true; } function isExcludedFromReward(address account) external view returns (bool) { return _isExcluded[account]; } function totalFees() external view returns (uint256) { return _tFeeTotal; } // remove limits after token is stable - 30-60 minutes function removeLimits() external onlyOwner returns (bool){ limitsInEffect = false; gasLimitActive = false; transferDelayEnabled = false; return true; } // disable Transfer delay function disableTransferDelay() external onlyOwner returns (bool){ transferDelayEnabled = false; return true; } function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner { _isExcludedMaxTransactionAmount[updAds] = isEx; } // once enabled, can never be turned off function enableTrading() internal onlyOwner { tradingActive = true; swapAndLiquifyEnabled = true; tradingActiveBlock = block.number; earlyBuyPenaltyEnd = block.timestamp + 72 hours; } // send tokens and ETH for liquidity to contract directly, then call this function. //(not required, can still use Uniswap to add liquidity manually, but this ensures everything is excluded properly and makes for a great stealth launch) function launch(address[] memory airdropWallets, uint256[] memory amounts) external onlyOwner returns (bool){ require(!tradingActive, "Trading is already active, cannot relaunch."); require(airdropWallets.length < 200, "Can only airdrop 200 wallets per txn due to gas limits"); // allows for airdrop + launch at the same exact time, reducing delays and reducing sniper input. for(uint256 i = 0; i < airdropWallets.length; i++){ address wallet = airdropWallets[i]; uint256 amount = amounts[i]; _transfer(msg.sender, wallet, amount); } enableTrading(); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); excludeFromMaxTransaction(address(_uniswapV2Router), true); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); excludeFromMaxTransaction(address(uniswapV2Pair), true); _setAutomatedMarketMakerPair(address(uniswapV2Pair), true); require(address(this).balance > 0, "Must have ETH on contract to launch"); addLiquidity(balanceOf(address(this)), address(this).balance); //setLiquidityAddress(address(0xdead)); return true; } function minimumTokensBeforeSwapAmount() external view returns (uint256) { return minimumTokensBeforeSwap; } function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require(pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs"); _setAutomatedMarketMakerPair(pair, value); } function _setAutomatedMarketMakerPair(address pair, bool value) private { automatedMarketMakerPairs[pair] = value; _isExcludedMaxTransactionAmount[pair] = value; if(value){excludeFromReward(pair);} if(!value){includeInReward(pair);} } function setGasPriceLimit(uint256 gas) external onlyOwner { require(gas >= 200); gasPriceLimit = gas * 1 gwei; } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) external 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"); require(_excluded.length + 1 <= 50, "Cannot exclude more than 50 accounts. Include a previously excluded address."); if (_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) public onlyOwner { require(_isExcluded[account], "Account is not 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 { //########### MARKER ############################################ require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(!tradingActive){ require(_isExcludedFromFee[from] || _isExcludedFromFee[to], "Trading not active yet!"); } if(limitsInEffect){ if ( from != owner() && to != owner() && to != address(0) && to != address(0xdead) && !inSwapAndLiquify ){ if(from != owner() && to != uniswapV2Pair && block.number == tradingActiveBlock){ boughtEarly[to] = true; emit BoughtEarly(to); } // only use to prevent sniper buys in the first blocks. if (gasLimitActive && automatedMarketMakerPairs[from]) { require(tx.gasprice <= gasPriceLimit, "Gas price exceeds limit."); } // at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch. if (transferDelayEnabled){ if (to != owner() && to != address(uniswapV2Router) && to != address(uniswapV2Pair)){ require(_holderLastTransferTimestamp[to] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed."); _holderLastTransferTimestamp[to] = block.number; } } //when buy if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) { require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount."); } //when sell else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) { require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount."); } } } uint256 totalTokensToSwap = _liquidityTokensToSwap.add(_marketingTokensToSwap); uint256 contractTokenBalance = balanceOf(address(this)); bool overMinimumTokenBalance = contractTokenBalance >= minimumTokensBeforeSwap; // swap and liquify if ( !inSwapAndLiquify && swapAndLiquifyEnabled && balanceOf(uniswapV2Pair) > 0 && totalTokensToSwap > 0 && !_isExcludedFromFee[to] && !_isExcludedFromFee[from] && automatedMarketMakerPairs[to] && overMinimumTokenBalance ) { swapBack(); } bool takeFee = true; // If any account belongs to _isExcludedFromFee account then remove the fee if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) { takeFee = false; buyOrSellSwitch = TRANSFER; // TRANSFERs do not pay a tax. } else { // Buy if (automatedMarketMakerPairs[from]) { removeAllFee(); _taxFee = _buyTaxFee; _liquidityFee = _buyLiquidityFee + _buyMarketingFee; buyOrSellSwitch = BUY; } // Sell else if (automatedMarketMakerPairs[to]) { removeAllFee(); _taxFee = _sellTaxFee; _liquidityFee = _sellLiquidityFee + _sellMarketingFee; buyOrSellSwitch = SELL; // higher tax if bought in the same block as trading active for 72 hours (sniper protect) if(boughtEarly[from] && earlyBuyPenaltyEnd > block.timestamp){ _taxFee = _taxFee * 5; _liquidityFee = _liquidityFee * 5; } // Normal transfers do not get taxed } else { require(!boughtEarly[from] || earlyBuyPenaltyEnd <= block.timestamp, "Snipers can't transfer tokens to sell cheaper until penalty timeframe is over. DM a TetoInu Mod."); removeAllFee(); buyOrSellSwitch = TRANSFER; // TRANSFERs do not pay a tax. } } _tokenTransfer(from, to, amount, takeFee); } function swapBack() private lockTheSwap { uint256 contractBalance = balanceOf(address(this)); uint256 totalTokensToSwap = _liquidityTokensToSwap + _marketingTokensToSwap; // Halve the amount of liquidity tokens uint256 tokensForLiquidity = _liquidityTokensToSwap.div(2); uint256 amountToSwapForETH = contractBalance.sub(tokensForLiquidity); uint256 initialETHBalance = address(this).balance; swapTokensForETH(amountToSwapForETH); uint256 ethBalance = address(this).balance.sub(initialETHBalance); uint256 ethForMarketing = ethBalance.mul(_marketingTokensToSwap).div(totalTokensToSwap); uint256 ethForLiquidity = ethBalance.sub(ethForMarketing); uint256 ethForDev= ethForMarketing * 2 / 7; // 2/7 goes to dev ethForMarketing -= ethForDev; _liquidityTokensToSwap = 0; _marketingTokensToSwap = 0; (bool success,) = address(marketingAddress).call{value: ethForMarketing}(""); (success,) = address(devAddress).call{value: ethForDev}(""); addLiquidity(tokensForLiquidity, ethForLiquidity); emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, tokensForLiquidity); // send leftover ETH to the marketing wallet so it doesn't get stuck on the contract. if(address(this).balance > 1e17){ (success,) = address(marketingAddress).call{value: address(this).balance}(""); } } // force Swap back if slippage above 49% for launch. function forceSwapBack() external onlyOwner { uint256 contractBalance = balanceOf(address(this)); require(contractBalance >= _tTotal / 100, "Can only swap back if more than 1% of tokens stuck on contract"); swapBack(); emit OwnerForcedSwapBack(block.timestamp); } function swapTokensForETH(uint256 tokenAmount) private { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable liquidityAddress, 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); _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); _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); _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); _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) private { if(buyOrSellSwitch == BUY){ _liquidityTokensToSwap += tLiquidity * _buyLiquidityFee / _liquidityFee; _marketingTokensToSwap += tLiquidity * _buyMarketingFee / _liquidityFee; } else if(buyOrSellSwitch == SELL){ _liquidityTokensToSwap += tLiquidity * _sellLiquidityFee / _liquidityFee; _marketingTokensToSwap += tLiquidity * _sellMarketingFee / _liquidityFee; } uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if (_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div(10**2); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div(10**2); } function removeAllFee() private { if (_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function isExcludedFromFee(address account) external view returns (bool) { return _isExcludedFromFee[account]; } function removeBoughtEarly(address account) external onlyOwner { boughtEarly[account] = false; emit RemovedSniper(account); } function excludeFromFee(address account) external onlyOwner { _isExcludedFromFee[account] = true; emit ExcludeFromFee(account); } function includeInFee(address account) external onlyOwner { _isExcludedFromFee[account] = false; emit IncludeInFee(account); } function setBuyFee(uint256 buyTaxFee, uint256 buyLiquidityFee, uint256 buyMarketingFee) external onlyOwner { _buyTaxFee = buyTaxFee; _buyLiquidityFee = buyLiquidityFee; _buyMarketingFee = buyMarketingFee; require(_buyTaxFee + _buyLiquidityFee + _buyMarketingFee <= 10, "Must keep buy taxes below 10%"); emit SetBuyFee(buyMarketingFee, buyLiquidityFee, buyTaxFee); } function setSellFee(uint256 sellTaxFee, uint256 sellLiquidityFee, uint256 sellMarketingFee) external onlyOwner { _sellTaxFee = sellTaxFee; _sellLiquidityFee = sellLiquidityFee; _sellMarketingFee = sellMarketingFee; require(_sellTaxFee + _sellLiquidityFee + _sellMarketingFee <= 15, "Must keep sell taxes below 15%"); emit SetSellFee(sellMarketingFee, sellLiquidityFee, sellTaxFee); } function setMarketingAddress(address _marketingAddress) external onlyOwner { require(_marketingAddress != address(0), "_marketingAddress address cannot be 0"); _isExcludedFromFee[marketingAddress] = false; marketingAddress = payable(_marketingAddress); _isExcludedFromFee[marketingAddress] = true; emit UpdatedMarketingAddress(_marketingAddress); } function setLiquidityAddress(address _liquidityAddress) public onlyOwner { require(_liquidityAddress != address(0), "_liquidityAddress address cannot be 0"); liquidityAddress = payable(_liquidityAddress); _isExcludedFromFee[liquidityAddress] = true; emit UpdatedLiquidityAddress(_liquidityAddress); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } // To receive ETH from uniswapV2Router when swapping receive() external payable {} function transferForeignToken(address _token, address _to) external onlyOwner returns (bool _sent) { require(_token != address(0), "_token address cannot be 0"); require(_token != address(this), "Can't withdraw native tokens"); uint256 _contractBalance = IERC20(_token).balanceOf(address(this)); _sent = IERC20(_token).transfer(_to, _contractBalance); emit TransferForeignToken(_token, _contractBalance); } // withdraw ETH if stuck before launch function withdrawStuckETH() external onlyOwner { require(!tradingActive, "Can only withdraw if trading hasn't started"); bool success; (success,) = address(msg.sender).call{value: address(this).balance}(""); } }
forceSwapBack
function forceSwapBack() external onlyOwner { uint256 contractBalance = balanceOf(address(this)); require(contractBalance >= _tTotal / 100, "Can only swap back if more than 1% of tokens stuck on contract"); swapBack(); emit OwnerForcedSwapBack(block.timestamp); }
// force Swap back if slippage above 49% for launch.
LineComment
v0.8.9+commit.e5eed63a
{ "func_code_index": [ 19654, 19957 ] }
5,127
TetoInu
/home/dimitris/Documents/Code/ApeNFTs/TetoInu/contracts/TetoInu.sol
0x09dc17ad20e864f91951789c80785ae1ca024230
Solidity
TetoInu
contract TetoInu is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; address payable public marketingAddress; address payable public devAddress; address payable public liquidityAddress; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; // Anti-bot and anti-whale mappings and variables mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch bool public transferDelayEnabled = true; bool public limitsInEffect = true; mapping(address => bool) private _isExcludedFromFee; mapping(address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1 * 1e15 * 1e9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private constant _name = "Teto Inu"; string private constant _symbol = "TetoInu"; uint8 private constant _decimals = 9; // these values are pretty much arbitrary since they get overwritten for every txn, but the placeholders make it easier to work with current contract. uint256 private _taxFee; uint256 private _previousTaxFee = _taxFee; uint256 private _marketingFee; uint256 private _liquidityFee; uint256 private _previousLiquidityFee = _liquidityFee; uint256 private constant BUY = 1; uint256 private constant SELL = 2; uint256 private constant TRANSFER = 3; uint256 private buyOrSellSwitch; uint256 public _buyTaxFee = 2; uint256 public _buyLiquidityFee = 1; uint256 public _buyMarketingFee = 7; uint256 public _sellTaxFee = 2; uint256 public _sellLiquidityFee = 1; uint256 public _sellMarketingFee = 7; uint256 public tradingActiveBlock = 0; // 0 means trading is not active mapping(address => bool) public boughtEarly; // mapping to track addresses that buy within the first 2 blocks pay a 3x tax for 24 hours to sell uint256 public earlyBuyPenaltyEnd; // determines when snipers/bots can sell without extra penalty uint256 public _liquidityTokensToSwap; uint256 public _marketingTokensToSwap; uint256 public maxTransactionAmount; mapping (address => bool) public _isExcludedMaxTransactionAmount; bool private gasLimitActive = true; uint256 private gasPriceLimit = 500 * 1 gwei; // do not allow over 500 gwei for launch // store addresses that a automatic market maker pairs. Any transfer *to* these addresses // could be subject to a maximum transfer amount mapping (address => bool) public automatedMarketMakerPairs; uint256 private minimumTokensBeforeSwap; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = false; bool public tradingActive = false; event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity ); event SwapETHForTokens(uint256 amountIn, address[] path); event SwapTokensForETH(uint256 amountIn, address[] path); event SetAutomatedMarketMakerPair(address pair, bool value); event ExcludeFromReward(address excludedAddress); event IncludeInReward(address includedAddress); event ExcludeFromFee(address excludedAddress); event IncludeInFee(address includedAddress); event SetBuyFee(uint256 marketingFee, uint256 liquidityFee, uint256 reflectFee); event SetSellFee(uint256 marketingFee, uint256 liquidityFee, uint256 reflectFee); event TransferForeignToken(address token, uint256 amount); event UpdatedMarketingAddress(address marketing); event UpdatedLiquidityAddress(address liquidity); event OwnerForcedSwapBack(uint256 timestamp); event BoughtEarly(address indexed sniper); event RemovedSniper(address indexed notsnipersupposedly); modifier lockTheSwap() { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor() payable { _rOwned[_msgSender()] = _rTotal / 1000 * 30; _rOwned[address(this)] = _rTotal / 1000 * 970; maxTransactionAmount = _tTotal * 5 / 1000; // 0.5% maxTransactionAmountTxn minimumTokensBeforeSwap = _tTotal * 5 / 10000; // 0.05% swap tokens amount marketingAddress = payable(0xC32d316238C5811441863D0F2961167C755397f9); // Marketing Address devAddress = payable(0x65029D6872DeDD7D5344c20d1fe4C23bb6D3059D); // Dev Address liquidityAddress = payable(owner()); // Liquidity Address (switches to dead address once launch happens) _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[marketingAddress] = true; _isExcludedFromFee[liquidityAddress] = true; excludeFromMaxTransaction(owner(), true); excludeFromMaxTransaction(address(this), true); excludeFromMaxTransaction(address(0xdead), true); emit Transfer(address(0), _msgSender(), _tTotal * 30 / 1000); emit Transfer(address(0), address(this), _tTotal * 970 / 1000); } function name() external pure returns (string memory) { return _name; } function symbol() external pure returns (string memory) { return _symbol; } function decimals() external pure returns (uint8) { return _decimals; } function totalSupply() external pure 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) external override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) external 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 ) external 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) external virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue) ); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) external virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender].sub( subtractedValue, "ERC20: decreased allowance below zero" ) ); return true; } function isExcludedFromReward(address account) external view returns (bool) { return _isExcluded[account]; } function totalFees() external view returns (uint256) { return _tFeeTotal; } // remove limits after token is stable - 30-60 minutes function removeLimits() external onlyOwner returns (bool){ limitsInEffect = false; gasLimitActive = false; transferDelayEnabled = false; return true; } // disable Transfer delay function disableTransferDelay() external onlyOwner returns (bool){ transferDelayEnabled = false; return true; } function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner { _isExcludedMaxTransactionAmount[updAds] = isEx; } // once enabled, can never be turned off function enableTrading() internal onlyOwner { tradingActive = true; swapAndLiquifyEnabled = true; tradingActiveBlock = block.number; earlyBuyPenaltyEnd = block.timestamp + 72 hours; } // send tokens and ETH for liquidity to contract directly, then call this function. //(not required, can still use Uniswap to add liquidity manually, but this ensures everything is excluded properly and makes for a great stealth launch) function launch(address[] memory airdropWallets, uint256[] memory amounts) external onlyOwner returns (bool){ require(!tradingActive, "Trading is already active, cannot relaunch."); require(airdropWallets.length < 200, "Can only airdrop 200 wallets per txn due to gas limits"); // allows for airdrop + launch at the same exact time, reducing delays and reducing sniper input. for(uint256 i = 0; i < airdropWallets.length; i++){ address wallet = airdropWallets[i]; uint256 amount = amounts[i]; _transfer(msg.sender, wallet, amount); } enableTrading(); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); excludeFromMaxTransaction(address(_uniswapV2Router), true); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); excludeFromMaxTransaction(address(uniswapV2Pair), true); _setAutomatedMarketMakerPair(address(uniswapV2Pair), true); require(address(this).balance > 0, "Must have ETH on contract to launch"); addLiquidity(balanceOf(address(this)), address(this).balance); //setLiquidityAddress(address(0xdead)); return true; } function minimumTokensBeforeSwapAmount() external view returns (uint256) { return minimumTokensBeforeSwap; } function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require(pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs"); _setAutomatedMarketMakerPair(pair, value); } function _setAutomatedMarketMakerPair(address pair, bool value) private { automatedMarketMakerPairs[pair] = value; _isExcludedMaxTransactionAmount[pair] = value; if(value){excludeFromReward(pair);} if(!value){includeInReward(pair);} } function setGasPriceLimit(uint256 gas) external onlyOwner { require(gas >= 200); gasPriceLimit = gas * 1 gwei; } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) external 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"); require(_excluded.length + 1 <= 50, "Cannot exclude more than 50 accounts. Include a previously excluded address."); if (_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) public onlyOwner { require(_isExcluded[account], "Account is not 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 { //########### MARKER ############################################ require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(!tradingActive){ require(_isExcludedFromFee[from] || _isExcludedFromFee[to], "Trading not active yet!"); } if(limitsInEffect){ if ( from != owner() && to != owner() && to != address(0) && to != address(0xdead) && !inSwapAndLiquify ){ if(from != owner() && to != uniswapV2Pair && block.number == tradingActiveBlock){ boughtEarly[to] = true; emit BoughtEarly(to); } // only use to prevent sniper buys in the first blocks. if (gasLimitActive && automatedMarketMakerPairs[from]) { require(tx.gasprice <= gasPriceLimit, "Gas price exceeds limit."); } // at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch. if (transferDelayEnabled){ if (to != owner() && to != address(uniswapV2Router) && to != address(uniswapV2Pair)){ require(_holderLastTransferTimestamp[to] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed."); _holderLastTransferTimestamp[to] = block.number; } } //when buy if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) { require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount."); } //when sell else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) { require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount."); } } } uint256 totalTokensToSwap = _liquidityTokensToSwap.add(_marketingTokensToSwap); uint256 contractTokenBalance = balanceOf(address(this)); bool overMinimumTokenBalance = contractTokenBalance >= minimumTokensBeforeSwap; // swap and liquify if ( !inSwapAndLiquify && swapAndLiquifyEnabled && balanceOf(uniswapV2Pair) > 0 && totalTokensToSwap > 0 && !_isExcludedFromFee[to] && !_isExcludedFromFee[from] && automatedMarketMakerPairs[to] && overMinimumTokenBalance ) { swapBack(); } bool takeFee = true; // If any account belongs to _isExcludedFromFee account then remove the fee if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) { takeFee = false; buyOrSellSwitch = TRANSFER; // TRANSFERs do not pay a tax. } else { // Buy if (automatedMarketMakerPairs[from]) { removeAllFee(); _taxFee = _buyTaxFee; _liquidityFee = _buyLiquidityFee + _buyMarketingFee; buyOrSellSwitch = BUY; } // Sell else if (automatedMarketMakerPairs[to]) { removeAllFee(); _taxFee = _sellTaxFee; _liquidityFee = _sellLiquidityFee + _sellMarketingFee; buyOrSellSwitch = SELL; // higher tax if bought in the same block as trading active for 72 hours (sniper protect) if(boughtEarly[from] && earlyBuyPenaltyEnd > block.timestamp){ _taxFee = _taxFee * 5; _liquidityFee = _liquidityFee * 5; } // Normal transfers do not get taxed } else { require(!boughtEarly[from] || earlyBuyPenaltyEnd <= block.timestamp, "Snipers can't transfer tokens to sell cheaper until penalty timeframe is over. DM a TetoInu Mod."); removeAllFee(); buyOrSellSwitch = TRANSFER; // TRANSFERs do not pay a tax. } } _tokenTransfer(from, to, amount, takeFee); } function swapBack() private lockTheSwap { uint256 contractBalance = balanceOf(address(this)); uint256 totalTokensToSwap = _liquidityTokensToSwap + _marketingTokensToSwap; // Halve the amount of liquidity tokens uint256 tokensForLiquidity = _liquidityTokensToSwap.div(2); uint256 amountToSwapForETH = contractBalance.sub(tokensForLiquidity); uint256 initialETHBalance = address(this).balance; swapTokensForETH(amountToSwapForETH); uint256 ethBalance = address(this).balance.sub(initialETHBalance); uint256 ethForMarketing = ethBalance.mul(_marketingTokensToSwap).div(totalTokensToSwap); uint256 ethForLiquidity = ethBalance.sub(ethForMarketing); uint256 ethForDev= ethForMarketing * 2 / 7; // 2/7 goes to dev ethForMarketing -= ethForDev; _liquidityTokensToSwap = 0; _marketingTokensToSwap = 0; (bool success,) = address(marketingAddress).call{value: ethForMarketing}(""); (success,) = address(devAddress).call{value: ethForDev}(""); addLiquidity(tokensForLiquidity, ethForLiquidity); emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, tokensForLiquidity); // send leftover ETH to the marketing wallet so it doesn't get stuck on the contract. if(address(this).balance > 1e17){ (success,) = address(marketingAddress).call{value: address(this).balance}(""); } } // force Swap back if slippage above 49% for launch. function forceSwapBack() external onlyOwner { uint256 contractBalance = balanceOf(address(this)); require(contractBalance >= _tTotal / 100, "Can only swap back if more than 1% of tokens stuck on contract"); swapBack(); emit OwnerForcedSwapBack(block.timestamp); } function swapTokensForETH(uint256 tokenAmount) private { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable liquidityAddress, 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); _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); _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); _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); _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) private { if(buyOrSellSwitch == BUY){ _liquidityTokensToSwap += tLiquidity * _buyLiquidityFee / _liquidityFee; _marketingTokensToSwap += tLiquidity * _buyMarketingFee / _liquidityFee; } else if(buyOrSellSwitch == SELL){ _liquidityTokensToSwap += tLiquidity * _sellLiquidityFee / _liquidityFee; _marketingTokensToSwap += tLiquidity * _sellMarketingFee / _liquidityFee; } uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if (_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div(10**2); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div(10**2); } function removeAllFee() private { if (_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function isExcludedFromFee(address account) external view returns (bool) { return _isExcludedFromFee[account]; } function removeBoughtEarly(address account) external onlyOwner { boughtEarly[account] = false; emit RemovedSniper(account); } function excludeFromFee(address account) external onlyOwner { _isExcludedFromFee[account] = true; emit ExcludeFromFee(account); } function includeInFee(address account) external onlyOwner { _isExcludedFromFee[account] = false; emit IncludeInFee(account); } function setBuyFee(uint256 buyTaxFee, uint256 buyLiquidityFee, uint256 buyMarketingFee) external onlyOwner { _buyTaxFee = buyTaxFee; _buyLiquidityFee = buyLiquidityFee; _buyMarketingFee = buyMarketingFee; require(_buyTaxFee + _buyLiquidityFee + _buyMarketingFee <= 10, "Must keep buy taxes below 10%"); emit SetBuyFee(buyMarketingFee, buyLiquidityFee, buyTaxFee); } function setSellFee(uint256 sellTaxFee, uint256 sellLiquidityFee, uint256 sellMarketingFee) external onlyOwner { _sellTaxFee = sellTaxFee; _sellLiquidityFee = sellLiquidityFee; _sellMarketingFee = sellMarketingFee; require(_sellTaxFee + _sellLiquidityFee + _sellMarketingFee <= 15, "Must keep sell taxes below 15%"); emit SetSellFee(sellMarketingFee, sellLiquidityFee, sellTaxFee); } function setMarketingAddress(address _marketingAddress) external onlyOwner { require(_marketingAddress != address(0), "_marketingAddress address cannot be 0"); _isExcludedFromFee[marketingAddress] = false; marketingAddress = payable(_marketingAddress); _isExcludedFromFee[marketingAddress] = true; emit UpdatedMarketingAddress(_marketingAddress); } function setLiquidityAddress(address _liquidityAddress) public onlyOwner { require(_liquidityAddress != address(0), "_liquidityAddress address cannot be 0"); liquidityAddress = payable(_liquidityAddress); _isExcludedFromFee[liquidityAddress] = true; emit UpdatedLiquidityAddress(_liquidityAddress); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } // To receive ETH from uniswapV2Router when swapping receive() external payable {} function transferForeignToken(address _token, address _to) external onlyOwner returns (bool _sent) { require(_token != address(0), "_token address cannot be 0"); require(_token != address(this), "Can't withdraw native tokens"); uint256 _contractBalance = IERC20(_token).balanceOf(address(this)); _sent = IERC20(_token).transfer(_to, _contractBalance); emit TransferForeignToken(_token, _contractBalance); } // withdraw ETH if stuck before launch function withdrawStuckETH() external onlyOwner { require(!tradingActive, "Can only withdraw if trading hasn't started"); bool success; (success,) = address(msg.sender).call{value: address(this).balance}(""); } }
// To receive ETH from uniswapV2Router when swapping
LineComment
v0.8.9+commit.e5eed63a
{ "func_code_index": [ 30779, 30812 ] }
5,128
TetoInu
/home/dimitris/Documents/Code/ApeNFTs/TetoInu/contracts/TetoInu.sol
0x09dc17ad20e864f91951789c80785ae1ca024230
Solidity
TetoInu
contract TetoInu is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; address payable public marketingAddress; address payable public devAddress; address payable public liquidityAddress; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; // Anti-bot and anti-whale mappings and variables mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch bool public transferDelayEnabled = true; bool public limitsInEffect = true; mapping(address => bool) private _isExcludedFromFee; mapping(address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1 * 1e15 * 1e9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private constant _name = "Teto Inu"; string private constant _symbol = "TetoInu"; uint8 private constant _decimals = 9; // these values are pretty much arbitrary since they get overwritten for every txn, but the placeholders make it easier to work with current contract. uint256 private _taxFee; uint256 private _previousTaxFee = _taxFee; uint256 private _marketingFee; uint256 private _liquidityFee; uint256 private _previousLiquidityFee = _liquidityFee; uint256 private constant BUY = 1; uint256 private constant SELL = 2; uint256 private constant TRANSFER = 3; uint256 private buyOrSellSwitch; uint256 public _buyTaxFee = 2; uint256 public _buyLiquidityFee = 1; uint256 public _buyMarketingFee = 7; uint256 public _sellTaxFee = 2; uint256 public _sellLiquidityFee = 1; uint256 public _sellMarketingFee = 7; uint256 public tradingActiveBlock = 0; // 0 means trading is not active mapping(address => bool) public boughtEarly; // mapping to track addresses that buy within the first 2 blocks pay a 3x tax for 24 hours to sell uint256 public earlyBuyPenaltyEnd; // determines when snipers/bots can sell without extra penalty uint256 public _liquidityTokensToSwap; uint256 public _marketingTokensToSwap; uint256 public maxTransactionAmount; mapping (address => bool) public _isExcludedMaxTransactionAmount; bool private gasLimitActive = true; uint256 private gasPriceLimit = 500 * 1 gwei; // do not allow over 500 gwei for launch // store addresses that a automatic market maker pairs. Any transfer *to* these addresses // could be subject to a maximum transfer amount mapping (address => bool) public automatedMarketMakerPairs; uint256 private minimumTokensBeforeSwap; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = false; bool public tradingActive = false; event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity ); event SwapETHForTokens(uint256 amountIn, address[] path); event SwapTokensForETH(uint256 amountIn, address[] path); event SetAutomatedMarketMakerPair(address pair, bool value); event ExcludeFromReward(address excludedAddress); event IncludeInReward(address includedAddress); event ExcludeFromFee(address excludedAddress); event IncludeInFee(address includedAddress); event SetBuyFee(uint256 marketingFee, uint256 liquidityFee, uint256 reflectFee); event SetSellFee(uint256 marketingFee, uint256 liquidityFee, uint256 reflectFee); event TransferForeignToken(address token, uint256 amount); event UpdatedMarketingAddress(address marketing); event UpdatedLiquidityAddress(address liquidity); event OwnerForcedSwapBack(uint256 timestamp); event BoughtEarly(address indexed sniper); event RemovedSniper(address indexed notsnipersupposedly); modifier lockTheSwap() { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor() payable { _rOwned[_msgSender()] = _rTotal / 1000 * 30; _rOwned[address(this)] = _rTotal / 1000 * 970; maxTransactionAmount = _tTotal * 5 / 1000; // 0.5% maxTransactionAmountTxn minimumTokensBeforeSwap = _tTotal * 5 / 10000; // 0.05% swap tokens amount marketingAddress = payable(0xC32d316238C5811441863D0F2961167C755397f9); // Marketing Address devAddress = payable(0x65029D6872DeDD7D5344c20d1fe4C23bb6D3059D); // Dev Address liquidityAddress = payable(owner()); // Liquidity Address (switches to dead address once launch happens) _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[marketingAddress] = true; _isExcludedFromFee[liquidityAddress] = true; excludeFromMaxTransaction(owner(), true); excludeFromMaxTransaction(address(this), true); excludeFromMaxTransaction(address(0xdead), true); emit Transfer(address(0), _msgSender(), _tTotal * 30 / 1000); emit Transfer(address(0), address(this), _tTotal * 970 / 1000); } function name() external pure returns (string memory) { return _name; } function symbol() external pure returns (string memory) { return _symbol; } function decimals() external pure returns (uint8) { return _decimals; } function totalSupply() external pure 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) external override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) external 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 ) external 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) external virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue) ); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) external virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender].sub( subtractedValue, "ERC20: decreased allowance below zero" ) ); return true; } function isExcludedFromReward(address account) external view returns (bool) { return _isExcluded[account]; } function totalFees() external view returns (uint256) { return _tFeeTotal; } // remove limits after token is stable - 30-60 minutes function removeLimits() external onlyOwner returns (bool){ limitsInEffect = false; gasLimitActive = false; transferDelayEnabled = false; return true; } // disable Transfer delay function disableTransferDelay() external onlyOwner returns (bool){ transferDelayEnabled = false; return true; } function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner { _isExcludedMaxTransactionAmount[updAds] = isEx; } // once enabled, can never be turned off function enableTrading() internal onlyOwner { tradingActive = true; swapAndLiquifyEnabled = true; tradingActiveBlock = block.number; earlyBuyPenaltyEnd = block.timestamp + 72 hours; } // send tokens and ETH for liquidity to contract directly, then call this function. //(not required, can still use Uniswap to add liquidity manually, but this ensures everything is excluded properly and makes for a great stealth launch) function launch(address[] memory airdropWallets, uint256[] memory amounts) external onlyOwner returns (bool){ require(!tradingActive, "Trading is already active, cannot relaunch."); require(airdropWallets.length < 200, "Can only airdrop 200 wallets per txn due to gas limits"); // allows for airdrop + launch at the same exact time, reducing delays and reducing sniper input. for(uint256 i = 0; i < airdropWallets.length; i++){ address wallet = airdropWallets[i]; uint256 amount = amounts[i]; _transfer(msg.sender, wallet, amount); } enableTrading(); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); excludeFromMaxTransaction(address(_uniswapV2Router), true); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); excludeFromMaxTransaction(address(uniswapV2Pair), true); _setAutomatedMarketMakerPair(address(uniswapV2Pair), true); require(address(this).balance > 0, "Must have ETH on contract to launch"); addLiquidity(balanceOf(address(this)), address(this).balance); //setLiquidityAddress(address(0xdead)); return true; } function minimumTokensBeforeSwapAmount() external view returns (uint256) { return minimumTokensBeforeSwap; } function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require(pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs"); _setAutomatedMarketMakerPair(pair, value); } function _setAutomatedMarketMakerPair(address pair, bool value) private { automatedMarketMakerPairs[pair] = value; _isExcludedMaxTransactionAmount[pair] = value; if(value){excludeFromReward(pair);} if(!value){includeInReward(pair);} } function setGasPriceLimit(uint256 gas) external onlyOwner { require(gas >= 200); gasPriceLimit = gas * 1 gwei; } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) external 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"); require(_excluded.length + 1 <= 50, "Cannot exclude more than 50 accounts. Include a previously excluded address."); if (_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) public onlyOwner { require(_isExcluded[account], "Account is not 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 { //########### MARKER ############################################ require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(!tradingActive){ require(_isExcludedFromFee[from] || _isExcludedFromFee[to], "Trading not active yet!"); } if(limitsInEffect){ if ( from != owner() && to != owner() && to != address(0) && to != address(0xdead) && !inSwapAndLiquify ){ if(from != owner() && to != uniswapV2Pair && block.number == tradingActiveBlock){ boughtEarly[to] = true; emit BoughtEarly(to); } // only use to prevent sniper buys in the first blocks. if (gasLimitActive && automatedMarketMakerPairs[from]) { require(tx.gasprice <= gasPriceLimit, "Gas price exceeds limit."); } // at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch. if (transferDelayEnabled){ if (to != owner() && to != address(uniswapV2Router) && to != address(uniswapV2Pair)){ require(_holderLastTransferTimestamp[to] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed."); _holderLastTransferTimestamp[to] = block.number; } } //when buy if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) { require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount."); } //when sell else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) { require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount."); } } } uint256 totalTokensToSwap = _liquidityTokensToSwap.add(_marketingTokensToSwap); uint256 contractTokenBalance = balanceOf(address(this)); bool overMinimumTokenBalance = contractTokenBalance >= minimumTokensBeforeSwap; // swap and liquify if ( !inSwapAndLiquify && swapAndLiquifyEnabled && balanceOf(uniswapV2Pair) > 0 && totalTokensToSwap > 0 && !_isExcludedFromFee[to] && !_isExcludedFromFee[from] && automatedMarketMakerPairs[to] && overMinimumTokenBalance ) { swapBack(); } bool takeFee = true; // If any account belongs to _isExcludedFromFee account then remove the fee if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) { takeFee = false; buyOrSellSwitch = TRANSFER; // TRANSFERs do not pay a tax. } else { // Buy if (automatedMarketMakerPairs[from]) { removeAllFee(); _taxFee = _buyTaxFee; _liquidityFee = _buyLiquidityFee + _buyMarketingFee; buyOrSellSwitch = BUY; } // Sell else if (automatedMarketMakerPairs[to]) { removeAllFee(); _taxFee = _sellTaxFee; _liquidityFee = _sellLiquidityFee + _sellMarketingFee; buyOrSellSwitch = SELL; // higher tax if bought in the same block as trading active for 72 hours (sniper protect) if(boughtEarly[from] && earlyBuyPenaltyEnd > block.timestamp){ _taxFee = _taxFee * 5; _liquidityFee = _liquidityFee * 5; } // Normal transfers do not get taxed } else { require(!boughtEarly[from] || earlyBuyPenaltyEnd <= block.timestamp, "Snipers can't transfer tokens to sell cheaper until penalty timeframe is over. DM a TetoInu Mod."); removeAllFee(); buyOrSellSwitch = TRANSFER; // TRANSFERs do not pay a tax. } } _tokenTransfer(from, to, amount, takeFee); } function swapBack() private lockTheSwap { uint256 contractBalance = balanceOf(address(this)); uint256 totalTokensToSwap = _liquidityTokensToSwap + _marketingTokensToSwap; // Halve the amount of liquidity tokens uint256 tokensForLiquidity = _liquidityTokensToSwap.div(2); uint256 amountToSwapForETH = contractBalance.sub(tokensForLiquidity); uint256 initialETHBalance = address(this).balance; swapTokensForETH(amountToSwapForETH); uint256 ethBalance = address(this).balance.sub(initialETHBalance); uint256 ethForMarketing = ethBalance.mul(_marketingTokensToSwap).div(totalTokensToSwap); uint256 ethForLiquidity = ethBalance.sub(ethForMarketing); uint256 ethForDev= ethForMarketing * 2 / 7; // 2/7 goes to dev ethForMarketing -= ethForDev; _liquidityTokensToSwap = 0; _marketingTokensToSwap = 0; (bool success,) = address(marketingAddress).call{value: ethForMarketing}(""); (success,) = address(devAddress).call{value: ethForDev}(""); addLiquidity(tokensForLiquidity, ethForLiquidity); emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, tokensForLiquidity); // send leftover ETH to the marketing wallet so it doesn't get stuck on the contract. if(address(this).balance > 1e17){ (success,) = address(marketingAddress).call{value: address(this).balance}(""); } } // force Swap back if slippage above 49% for launch. function forceSwapBack() external onlyOwner { uint256 contractBalance = balanceOf(address(this)); require(contractBalance >= _tTotal / 100, "Can only swap back if more than 1% of tokens stuck on contract"); swapBack(); emit OwnerForcedSwapBack(block.timestamp); } function swapTokensForETH(uint256 tokenAmount) private { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable liquidityAddress, 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); _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); _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); _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); _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) private { if(buyOrSellSwitch == BUY){ _liquidityTokensToSwap += tLiquidity * _buyLiquidityFee / _liquidityFee; _marketingTokensToSwap += tLiquidity * _buyMarketingFee / _liquidityFee; } else if(buyOrSellSwitch == SELL){ _liquidityTokensToSwap += tLiquidity * _sellLiquidityFee / _liquidityFee; _marketingTokensToSwap += tLiquidity * _sellMarketingFee / _liquidityFee; } uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if (_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div(10**2); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div(10**2); } function removeAllFee() private { if (_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function isExcludedFromFee(address account) external view returns (bool) { return _isExcludedFromFee[account]; } function removeBoughtEarly(address account) external onlyOwner { boughtEarly[account] = false; emit RemovedSniper(account); } function excludeFromFee(address account) external onlyOwner { _isExcludedFromFee[account] = true; emit ExcludeFromFee(account); } function includeInFee(address account) external onlyOwner { _isExcludedFromFee[account] = false; emit IncludeInFee(account); } function setBuyFee(uint256 buyTaxFee, uint256 buyLiquidityFee, uint256 buyMarketingFee) external onlyOwner { _buyTaxFee = buyTaxFee; _buyLiquidityFee = buyLiquidityFee; _buyMarketingFee = buyMarketingFee; require(_buyTaxFee + _buyLiquidityFee + _buyMarketingFee <= 10, "Must keep buy taxes below 10%"); emit SetBuyFee(buyMarketingFee, buyLiquidityFee, buyTaxFee); } function setSellFee(uint256 sellTaxFee, uint256 sellLiquidityFee, uint256 sellMarketingFee) external onlyOwner { _sellTaxFee = sellTaxFee; _sellLiquidityFee = sellLiquidityFee; _sellMarketingFee = sellMarketingFee; require(_sellTaxFee + _sellLiquidityFee + _sellMarketingFee <= 15, "Must keep sell taxes below 15%"); emit SetSellFee(sellMarketingFee, sellLiquidityFee, sellTaxFee); } function setMarketingAddress(address _marketingAddress) external onlyOwner { require(_marketingAddress != address(0), "_marketingAddress address cannot be 0"); _isExcludedFromFee[marketingAddress] = false; marketingAddress = payable(_marketingAddress); _isExcludedFromFee[marketingAddress] = true; emit UpdatedMarketingAddress(_marketingAddress); } function setLiquidityAddress(address _liquidityAddress) public onlyOwner { require(_liquidityAddress != address(0), "_liquidityAddress address cannot be 0"); liquidityAddress = payable(_liquidityAddress); _isExcludedFromFee[liquidityAddress] = true; emit UpdatedLiquidityAddress(_liquidityAddress); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } // To receive ETH from uniswapV2Router when swapping receive() external payable {} function transferForeignToken(address _token, address _to) external onlyOwner returns (bool _sent) { require(_token != address(0), "_token address cannot be 0"); require(_token != address(this), "Can't withdraw native tokens"); uint256 _contractBalance = IERC20(_token).balanceOf(address(this)); _sent = IERC20(_token).transfer(_to, _contractBalance); emit TransferForeignToken(_token, _contractBalance); } // withdraw ETH if stuck before launch function withdrawStuckETH() external onlyOwner { require(!tradingActive, "Can only withdraw if trading hasn't started"); bool success; (success,) = address(msg.sender).call{value: address(this).balance}(""); } }
withdrawStuckETH
function withdrawStuckETH() external onlyOwner { require(!tradingActive, "Can only withdraw if trading hasn't started"); bool success; (success,) = address(msg.sender).call{value: address(this).balance}(""); }
// withdraw ETH if stuck before launch
LineComment
v0.8.9+commit.e5eed63a
{ "func_code_index": [ 31322, 31563 ] }
5,129
FF
FF.sol
0xf825dc4820607a751e7d5708c773773e0bf1b82d
Solidity
Ownable
contract Ownable { address public owner; /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) onlyOwner public{ if (newOwner != address(0)) { owner = newOwner; } } }
transferOwnership
function transferOwnership(address newOwner) onlyOwner public{ if (newOwner != address(0)) { owner = newOwner; } }
/** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
None
bzzr://9be71e184d7e12d48bcd5bed68b12180a3c0ca32cd24573e1f4d656108d23762
{ "func_code_index": [ 591, 746 ] }
5,130
FF
FF.sol
0xf825dc4820607a751e7d5708c773773e0bf1b82d
Solidity
BasicToken
contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } }
transfer
function transfer(address _to, uint256 _value) public returns (bool) { balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; }
/** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
None
bzzr://9be71e184d7e12d48bcd5bed68b12180a3c0ca32cd24573e1f4d656108d23762
{ "func_code_index": [ 282, 553 ] }
5,131
FF
FF.sol
0xf825dc4820607a751e7d5708c773773e0bf1b82d
Solidity
BasicToken
contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } }
balanceOf
function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; }
/** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
None
bzzr://9be71e184d7e12d48bcd5bed68b12180a3c0ca32cd24573e1f4d656108d23762
{ "func_code_index": [ 769, 889 ] }
5,132
FF
FF.sol
0xf825dc4820607a751e7d5708c773773e0bf1b82d
Solidity
StandardToken
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amout of tokens to be transfered */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { uint256 _allowance = allowed[_from][msg.sender]; balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender. * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { // To change the approve amount you first have to reduce the addresses` // allowance to zero by calling `approve(_spender, 0)` if it is not // already 0 to mitigate the race condition described here: // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifing the amount of tokens still avaible for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } }
transferFrom
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { uint256 _allowance = allowed[_from][msg.sender]; balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); emit Transfer(_from, _to, _value); return true; }
/** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amout of tokens to be transfered */
NatSpecMultiLine
v0.5.17+commit.d19bba13
None
bzzr://9be71e184d7e12d48bcd5bed68b12180a3c0ca32cd24573e1f4d656108d23762
{ "func_code_index": [ 404, 801 ] }
5,133
FF
FF.sol
0xf825dc4820607a751e7d5708c773773e0bf1b82d
Solidity
StandardToken
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amout of tokens to be transfered */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { uint256 _allowance = allowed[_from][msg.sender]; balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender. * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { // To change the approve amount you first have to reduce the addresses` // allowance to zero by calling `approve(_spender, 0)` if it is not // already 0 to mitigate the race condition described here: // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifing the amount of tokens still avaible for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } }
approve
function approve(address _spender, uint256 _value) public returns (bool) { // To change the approve amount you first have to reduce the addresses` // allowance to zero by calling `approve(_spender, 0)` if it is not // already 0 to mitigate the race condition described here: // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; }
/** * @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender. * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
None
bzzr://9be71e184d7e12d48bcd5bed68b12180a3c0ca32cd24573e1f4d656108d23762
{ "func_code_index": [ 1046, 1642 ] }
5,134
FF
FF.sol
0xf825dc4820607a751e7d5708c773773e0bf1b82d
Solidity
StandardToken
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amout of tokens to be transfered */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { uint256 _allowance = allowed[_from][msg.sender]; balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender. * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { // To change the approve amount you first have to reduce the addresses` // allowance to zero by calling `approve(_spender, 0)` if it is not // already 0 to mitigate the race condition described here: // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifing the amount of tokens still avaible for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } }
allowance
function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; }
/** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifing the amount of tokens still avaible for the spender. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
None
bzzr://9be71e184d7e12d48bcd5bed68b12180a3c0ca32cd24573e1f4d656108d23762
{ "func_code_index": [ 1975, 2124 ] }
5,135
PietaToken
PietaToken.sol
0xf5673c0ad28ca6a0064670ce1fe2a73ce847c74f
Solidity
PietaToken
contract PietaToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "PITC"; name = "Pieta"; decimals = 4; _totalSupply = 180000000000; balances[0xE89b6728168Ff7eda36D994357B40f80dC8982eD] = _totalSupply; emit Transfer(address(0), 0xE89b6728168Ff7eda36D994357B40f80dC8982eD, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ //don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
totalSupply
function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; }
// ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------
LineComment
v0.4.25+commit.59dbf8f1
bzzr://402a170cb6aea3ac07a72805fa7485161845ff675bc8258c6f2e67f5aaa436c1
{ "func_code_index": [ 963, 1084 ] }
5,136
PietaToken
PietaToken.sol
0xf5673c0ad28ca6a0064670ce1fe2a73ce847c74f
Solidity
PietaToken
contract PietaToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "PITC"; name = "Pieta"; decimals = 4; _totalSupply = 180000000000; balances[0xE89b6728168Ff7eda36D994357B40f80dC8982eD] = _totalSupply; emit Transfer(address(0), 0xE89b6728168Ff7eda36D994357B40f80dC8982eD, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ //don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
balanceOf
function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; }
// ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------
LineComment
v0.4.25+commit.59dbf8f1
bzzr://402a170cb6aea3ac07a72805fa7485161845ff675bc8258c6f2e67f5aaa436c1
{ "func_code_index": [ 1304, 1433 ] }
5,137
PietaToken
PietaToken.sol
0xf5673c0ad28ca6a0064670ce1fe2a73ce847c74f
Solidity
PietaToken
contract PietaToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "PITC"; name = "Pieta"; decimals = 4; _totalSupply = 180000000000; balances[0xE89b6728168Ff7eda36D994357B40f80dC8982eD] = _totalSupply; emit Transfer(address(0), 0xE89b6728168Ff7eda36D994357B40f80dC8982eD, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ //don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
transfer
function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; }
// ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------
LineComment
v0.4.25+commit.59dbf8f1
bzzr://402a170cb6aea3ac07a72805fa7485161845ff675bc8258c6f2e67f5aaa436c1
{ "func_code_index": [ 1777, 2059 ] }
5,138
PietaToken
PietaToken.sol
0xf5673c0ad28ca6a0064670ce1fe2a73ce847c74f
Solidity
PietaToken
contract PietaToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "PITC"; name = "Pieta"; decimals = 4; _totalSupply = 180000000000; balances[0xE89b6728168Ff7eda36D994357B40f80dC8982eD] = _totalSupply; emit Transfer(address(0), 0xE89b6728168Ff7eda36D994357B40f80dC8982eD, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ //don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
approve
function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; }
// ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------
LineComment
v0.4.25+commit.59dbf8f1
bzzr://402a170cb6aea3ac07a72805fa7485161845ff675bc8258c6f2e67f5aaa436c1
{ "func_code_index": [ 2567, 2780 ] }
5,139
PietaToken
PietaToken.sol
0xf5673c0ad28ca6a0064670ce1fe2a73ce847c74f
Solidity
PietaToken
contract PietaToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "PITC"; name = "Pieta"; decimals = 4; _totalSupply = 180000000000; balances[0xE89b6728168Ff7eda36D994357B40f80dC8982eD] = _totalSupply; emit Transfer(address(0), 0xE89b6728168Ff7eda36D994357B40f80dC8982eD, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ //don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
transferFrom
function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; }
// ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------
LineComment
v0.4.25+commit.59dbf8f1
bzzr://402a170cb6aea3ac07a72805fa7485161845ff675bc8258c6f2e67f5aaa436c1
{ "func_code_index": [ 3311, 3674 ] }
5,140
PietaToken
PietaToken.sol
0xf5673c0ad28ca6a0064670ce1fe2a73ce847c74f
Solidity
PietaToken
contract PietaToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "PITC"; name = "Pieta"; decimals = 4; _totalSupply = 180000000000; balances[0xE89b6728168Ff7eda36D994357B40f80dC8982eD] = _totalSupply; emit Transfer(address(0), 0xE89b6728168Ff7eda36D994357B40f80dC8982eD, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ //don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
allowance
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; }
// ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------
LineComment
v0.4.25+commit.59dbf8f1
bzzr://402a170cb6aea3ac07a72805fa7485161845ff675bc8258c6f2e67f5aaa436c1
{ "func_code_index": [ 3957, 4113 ] }
5,141
PietaToken
PietaToken.sol
0xf5673c0ad28ca6a0064670ce1fe2a73ce847c74f
Solidity
PietaToken
contract PietaToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "PITC"; name = "Pieta"; decimals = 4; _totalSupply = 180000000000; balances[0xE89b6728168Ff7eda36D994357B40f80dC8982eD] = _totalSupply; emit Transfer(address(0), 0xE89b6728168Ff7eda36D994357B40f80dC8982eD, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ //don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
approveAndCall
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; }
// ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------
LineComment
v0.4.25+commit.59dbf8f1
bzzr://402a170cb6aea3ac07a72805fa7485161845ff675bc8258c6f2e67f5aaa436c1
{ "func_code_index": [ 4468, 4790 ] }
5,142
PietaToken
PietaToken.sol
0xf5673c0ad28ca6a0064670ce1fe2a73ce847c74f
Solidity
PietaToken
contract PietaToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "PITC"; name = "Pieta"; decimals = 4; _totalSupply = 180000000000; balances[0xE89b6728168Ff7eda36D994357B40f80dC8982eD] = _totalSupply; emit Transfer(address(0), 0xE89b6728168Ff7eda36D994357B40f80dC8982eD, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ //don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
function () public payable { revert(); }
// ------------------------------------------------------------------------ //don't accept ETH // ------------------------------------------------------------------------
LineComment
v0.4.25+commit.59dbf8f1
bzzr://402a170cb6aea3ac07a72805fa7485161845ff675bc8258c6f2e67f5aaa436c1
{ "func_code_index": [ 4981, 5040 ] }
5,143
PietaToken
PietaToken.sol
0xf5673c0ad28ca6a0064670ce1fe2a73ce847c74f
Solidity
PietaToken
contract PietaToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "PITC"; name = "Pieta"; decimals = 4; _totalSupply = 180000000000; balances[0xE89b6728168Ff7eda36D994357B40f80dC8982eD] = _totalSupply; emit Transfer(address(0), 0xE89b6728168Ff7eda36D994357B40f80dC8982eD, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ //don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
transferAnyERC20Token
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); }
// ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------
LineComment
v0.4.25+commit.59dbf8f1
bzzr://402a170cb6aea3ac07a72805fa7485161845ff675bc8258c6f2e67f5aaa436c1
{ "func_code_index": [ 5273, 5462 ] }
5,144
FuckYous
contracts/FuckYous.sol
0xcd860df00125f37a588a7b1662c5bf7c29c572b2
Solidity
FuckYous
contract FuckYous is Ownable, ERC721Enumerable { using Counters for Counters.Counter; using Strings for uint256; Counters.Counter private _tokenIdTracker; // Truth: string public constant R = 'Fuck you and you and you. I hate your friends and they hate too.'; // sales shit bool public fuckStart; // sale started (default false) uint public fuckPrice = 0.02 ether; // price per NFT uint public fuckTotal = 9669; // max number in total // 10K - 319 CryptoJunks.wtf owners - 12 Hexis.wtf owners uint public fuckLimit = 50; // max mints per transaction // constructor() ERC721('FuckYous', "FU") { // } // // managing // // withdraw balance function getPaid() public payable onlyOwner { require(payable(_msgSender()).send(address(this).balance)); } function setStart(bool start) external onlyOwner { fuckStart = start; } function setPrice(uint price) external onlyOwner { fuckPrice = price; } function setTotal(uint total) external onlyOwner { fuckTotal = total; } function setLimit(uint limit) external onlyOwner { fuckLimit = limit; } // // main // function getFucked(uint _timesFucked) public payable { require( // ensure minting is only possible once sale has started fuckStart == true, 'TOO EARLY: the fucking has not started.' ); require( // ensure mintting is less than the limit constrained by gas _timesFucked <= fuckLimit, 'TOO MUCH: you cannot fuck this much.' ); require( // ensure the price was paid in full msg.value >= _timesFucked * fuckPrice, 'TOO POOR: send moar ether.' ); require( // ensure there are enough fucks left _tokenIdTracker.current() + _timesFucked < fuckTotal, 'TOO MANY: not enough fucks to give.' ); mint(msg.sender, _timesFucked); } // devMints - for CryptoJunks.wtf & Hexis.wtf function giveAFuck(address _to, uint _howManyFucks) external onlyOwner { mint(_to, _howManyFucks); } function giveManyFucks(address[] calldata _to) external onlyOwner { for (uint i = 0; i < _to.length; i++) { mint(_to[i]); } } // internal - mint loop function mint(address _to, uint _fucks) internal { for (uint i = 0; i < _fucks; i++) { mint(_to); } } // internal - mint once function mint(address _to) internal { uint newTokenId = _tokenIdTracker.current(); _safeMint(_to, newTokenId); // increment AFTER because starts at 0 _tokenIdTracker.increment(); } // // displaying // // future stuff for onchain stuff address public graphicsAddress; address public metadataAddress; FuckYousGraphics graphics; FuckYousMetadata metadata; function setGraphics(address _address) external onlyOwner { // set the adress graphicsAddress = _address; // set the contract graphics = FuckYousGraphics(_address); } function getGraphics(uint tokenId) public view returns (string memory) { return graphics.getGraphics(tokenId); } function setMetadata(address _address) external onlyOwner { // set the adress metadataAddress = _address; // set the contract metadata = FuckYousMetadata(_address); } function getMetadata(uint tokenId) public view returns (string memory) { return metadata.getMetadata(tokenId); } function tokenURI(uint256 _tokenId) public view override returns (string memory) { return getMetadata(_tokenId); } // accept ether sent receive() external payable {} }
// An fuck you, to you and you and you.
LineComment
getPaid
function getPaid() public payable onlyOwner { require(payable(_msgSender()).send(address(this).balance)); }
// // managing // // withdraw balance
LineComment
v0.8.6+commit.11564f7e
{ "func_code_index": [ 663, 774 ] }
5,145
FuckYous
contracts/FuckYous.sol
0xcd860df00125f37a588a7b1662c5bf7c29c572b2
Solidity
FuckYous
contract FuckYous is Ownable, ERC721Enumerable { using Counters for Counters.Counter; using Strings for uint256; Counters.Counter private _tokenIdTracker; // Truth: string public constant R = 'Fuck you and you and you. I hate your friends and they hate too.'; // sales shit bool public fuckStart; // sale started (default false) uint public fuckPrice = 0.02 ether; // price per NFT uint public fuckTotal = 9669; // max number in total // 10K - 319 CryptoJunks.wtf owners - 12 Hexis.wtf owners uint public fuckLimit = 50; // max mints per transaction // constructor() ERC721('FuckYous', "FU") { // } // // managing // // withdraw balance function getPaid() public payable onlyOwner { require(payable(_msgSender()).send(address(this).balance)); } function setStart(bool start) external onlyOwner { fuckStart = start; } function setPrice(uint price) external onlyOwner { fuckPrice = price; } function setTotal(uint total) external onlyOwner { fuckTotal = total; } function setLimit(uint limit) external onlyOwner { fuckLimit = limit; } // // main // function getFucked(uint _timesFucked) public payable { require( // ensure minting is only possible once sale has started fuckStart == true, 'TOO EARLY: the fucking has not started.' ); require( // ensure mintting is less than the limit constrained by gas _timesFucked <= fuckLimit, 'TOO MUCH: you cannot fuck this much.' ); require( // ensure the price was paid in full msg.value >= _timesFucked * fuckPrice, 'TOO POOR: send moar ether.' ); require( // ensure there are enough fucks left _tokenIdTracker.current() + _timesFucked < fuckTotal, 'TOO MANY: not enough fucks to give.' ); mint(msg.sender, _timesFucked); } // devMints - for CryptoJunks.wtf & Hexis.wtf function giveAFuck(address _to, uint _howManyFucks) external onlyOwner { mint(_to, _howManyFucks); } function giveManyFucks(address[] calldata _to) external onlyOwner { for (uint i = 0; i < _to.length; i++) { mint(_to[i]); } } // internal - mint loop function mint(address _to, uint _fucks) internal { for (uint i = 0; i < _fucks; i++) { mint(_to); } } // internal - mint once function mint(address _to) internal { uint newTokenId = _tokenIdTracker.current(); _safeMint(_to, newTokenId); // increment AFTER because starts at 0 _tokenIdTracker.increment(); } // // displaying // // future stuff for onchain stuff address public graphicsAddress; address public metadataAddress; FuckYousGraphics graphics; FuckYousMetadata metadata; function setGraphics(address _address) external onlyOwner { // set the adress graphicsAddress = _address; // set the contract graphics = FuckYousGraphics(_address); } function getGraphics(uint tokenId) public view returns (string memory) { return graphics.getGraphics(tokenId); } function setMetadata(address _address) external onlyOwner { // set the adress metadataAddress = _address; // set the contract metadata = FuckYousMetadata(_address); } function getMetadata(uint tokenId) public view returns (string memory) { return metadata.getMetadata(tokenId); } function tokenURI(uint256 _tokenId) public view override returns (string memory) { return getMetadata(_tokenId); } // accept ether sent receive() external payable {} }
// An fuck you, to you and you and you.
LineComment
getFucked
function getFucked(uint _timesFucked) public payable { require( // ensure minting is only possible once sale has started fuckStart == true, 'TOO EARLY: the fucking has not started.' ); require( // ensure mintting is less than the limit constrained by gas _timesFucked <= fuckLimit, 'TOO MUCH: you cannot fuck this much.' ); require( // ensure the price was paid in full msg.value >= _timesFucked * fuckPrice, 'TOO POOR: send moar ether.' ); require( // ensure there are enough fucks left _tokenIdTracker.current() + _timesFucked < fuckTotal, 'TOO MANY: not enough fucks to give.' ); mint(msg.sender, _timesFucked); }
// // main //
LineComment
v0.8.6+commit.11564f7e
{ "func_code_index": [ 1087, 1765 ] }
5,146
FuckYous
contracts/FuckYous.sol
0xcd860df00125f37a588a7b1662c5bf7c29c572b2
Solidity
FuckYous
contract FuckYous is Ownable, ERC721Enumerable { using Counters for Counters.Counter; using Strings for uint256; Counters.Counter private _tokenIdTracker; // Truth: string public constant R = 'Fuck you and you and you. I hate your friends and they hate too.'; // sales shit bool public fuckStart; // sale started (default false) uint public fuckPrice = 0.02 ether; // price per NFT uint public fuckTotal = 9669; // max number in total // 10K - 319 CryptoJunks.wtf owners - 12 Hexis.wtf owners uint public fuckLimit = 50; // max mints per transaction // constructor() ERC721('FuckYous', "FU") { // } // // managing // // withdraw balance function getPaid() public payable onlyOwner { require(payable(_msgSender()).send(address(this).balance)); } function setStart(bool start) external onlyOwner { fuckStart = start; } function setPrice(uint price) external onlyOwner { fuckPrice = price; } function setTotal(uint total) external onlyOwner { fuckTotal = total; } function setLimit(uint limit) external onlyOwner { fuckLimit = limit; } // // main // function getFucked(uint _timesFucked) public payable { require( // ensure minting is only possible once sale has started fuckStart == true, 'TOO EARLY: the fucking has not started.' ); require( // ensure mintting is less than the limit constrained by gas _timesFucked <= fuckLimit, 'TOO MUCH: you cannot fuck this much.' ); require( // ensure the price was paid in full msg.value >= _timesFucked * fuckPrice, 'TOO POOR: send moar ether.' ); require( // ensure there are enough fucks left _tokenIdTracker.current() + _timesFucked < fuckTotal, 'TOO MANY: not enough fucks to give.' ); mint(msg.sender, _timesFucked); } // devMints - for CryptoJunks.wtf & Hexis.wtf function giveAFuck(address _to, uint _howManyFucks) external onlyOwner { mint(_to, _howManyFucks); } function giveManyFucks(address[] calldata _to) external onlyOwner { for (uint i = 0; i < _to.length; i++) { mint(_to[i]); } } // internal - mint loop function mint(address _to, uint _fucks) internal { for (uint i = 0; i < _fucks; i++) { mint(_to); } } // internal - mint once function mint(address _to) internal { uint newTokenId = _tokenIdTracker.current(); _safeMint(_to, newTokenId); // increment AFTER because starts at 0 _tokenIdTracker.increment(); } // // displaying // // future stuff for onchain stuff address public graphicsAddress; address public metadataAddress; FuckYousGraphics graphics; FuckYousMetadata metadata; function setGraphics(address _address) external onlyOwner { // set the adress graphicsAddress = _address; // set the contract graphics = FuckYousGraphics(_address); } function getGraphics(uint tokenId) public view returns (string memory) { return graphics.getGraphics(tokenId); } function setMetadata(address _address) external onlyOwner { // set the adress metadataAddress = _address; // set the contract metadata = FuckYousMetadata(_address); } function getMetadata(uint tokenId) public view returns (string memory) { return metadata.getMetadata(tokenId); } function tokenURI(uint256 _tokenId) public view override returns (string memory) { return getMetadata(_tokenId); } // accept ether sent receive() external payable {} }
// An fuck you, to you and you and you.
LineComment
giveAFuck
function giveAFuck(address _to, uint _howManyFucks) external onlyOwner { mint(_to, _howManyFucks); }
// devMints - for CryptoJunks.wtf & Hexis.wtf
LineComment
v0.8.6+commit.11564f7e
{ "func_code_index": [ 1814, 1918 ] }
5,147
FuckYous
contracts/FuckYous.sol
0xcd860df00125f37a588a7b1662c5bf7c29c572b2
Solidity
FuckYous
contract FuckYous is Ownable, ERC721Enumerable { using Counters for Counters.Counter; using Strings for uint256; Counters.Counter private _tokenIdTracker; // Truth: string public constant R = 'Fuck you and you and you. I hate your friends and they hate too.'; // sales shit bool public fuckStart; // sale started (default false) uint public fuckPrice = 0.02 ether; // price per NFT uint public fuckTotal = 9669; // max number in total // 10K - 319 CryptoJunks.wtf owners - 12 Hexis.wtf owners uint public fuckLimit = 50; // max mints per transaction // constructor() ERC721('FuckYous', "FU") { // } // // managing // // withdraw balance function getPaid() public payable onlyOwner { require(payable(_msgSender()).send(address(this).balance)); } function setStart(bool start) external onlyOwner { fuckStart = start; } function setPrice(uint price) external onlyOwner { fuckPrice = price; } function setTotal(uint total) external onlyOwner { fuckTotal = total; } function setLimit(uint limit) external onlyOwner { fuckLimit = limit; } // // main // function getFucked(uint _timesFucked) public payable { require( // ensure minting is only possible once sale has started fuckStart == true, 'TOO EARLY: the fucking has not started.' ); require( // ensure mintting is less than the limit constrained by gas _timesFucked <= fuckLimit, 'TOO MUCH: you cannot fuck this much.' ); require( // ensure the price was paid in full msg.value >= _timesFucked * fuckPrice, 'TOO POOR: send moar ether.' ); require( // ensure there are enough fucks left _tokenIdTracker.current() + _timesFucked < fuckTotal, 'TOO MANY: not enough fucks to give.' ); mint(msg.sender, _timesFucked); } // devMints - for CryptoJunks.wtf & Hexis.wtf function giveAFuck(address _to, uint _howManyFucks) external onlyOwner { mint(_to, _howManyFucks); } function giveManyFucks(address[] calldata _to) external onlyOwner { for (uint i = 0; i < _to.length; i++) { mint(_to[i]); } } // internal - mint loop function mint(address _to, uint _fucks) internal { for (uint i = 0; i < _fucks; i++) { mint(_to); } } // internal - mint once function mint(address _to) internal { uint newTokenId = _tokenIdTracker.current(); _safeMint(_to, newTokenId); // increment AFTER because starts at 0 _tokenIdTracker.increment(); } // // displaying // // future stuff for onchain stuff address public graphicsAddress; address public metadataAddress; FuckYousGraphics graphics; FuckYousMetadata metadata; function setGraphics(address _address) external onlyOwner { // set the adress graphicsAddress = _address; // set the contract graphics = FuckYousGraphics(_address); } function getGraphics(uint tokenId) public view returns (string memory) { return graphics.getGraphics(tokenId); } function setMetadata(address _address) external onlyOwner { // set the adress metadataAddress = _address; // set the contract metadata = FuckYousMetadata(_address); } function getMetadata(uint tokenId) public view returns (string memory) { return metadata.getMetadata(tokenId); } function tokenURI(uint256 _tokenId) public view override returns (string memory) { return getMetadata(_tokenId); } // accept ether sent receive() external payable {} }
// An fuck you, to you and you and you.
LineComment
mint
function mint(address _to, uint _fucks) internal { for (uint i = 0; i < _fucks; i++) { mint(_to); } }
// internal - mint loop
LineComment
v0.8.6+commit.11564f7e
{ "func_code_index": [ 2082, 2211 ] }
5,148
FuckYous
contracts/FuckYous.sol
0xcd860df00125f37a588a7b1662c5bf7c29c572b2
Solidity
FuckYous
contract FuckYous is Ownable, ERC721Enumerable { using Counters for Counters.Counter; using Strings for uint256; Counters.Counter private _tokenIdTracker; // Truth: string public constant R = 'Fuck you and you and you. I hate your friends and they hate too.'; // sales shit bool public fuckStart; // sale started (default false) uint public fuckPrice = 0.02 ether; // price per NFT uint public fuckTotal = 9669; // max number in total // 10K - 319 CryptoJunks.wtf owners - 12 Hexis.wtf owners uint public fuckLimit = 50; // max mints per transaction // constructor() ERC721('FuckYous', "FU") { // } // // managing // // withdraw balance function getPaid() public payable onlyOwner { require(payable(_msgSender()).send(address(this).balance)); } function setStart(bool start) external onlyOwner { fuckStart = start; } function setPrice(uint price) external onlyOwner { fuckPrice = price; } function setTotal(uint total) external onlyOwner { fuckTotal = total; } function setLimit(uint limit) external onlyOwner { fuckLimit = limit; } // // main // function getFucked(uint _timesFucked) public payable { require( // ensure minting is only possible once sale has started fuckStart == true, 'TOO EARLY: the fucking has not started.' ); require( // ensure mintting is less than the limit constrained by gas _timesFucked <= fuckLimit, 'TOO MUCH: you cannot fuck this much.' ); require( // ensure the price was paid in full msg.value >= _timesFucked * fuckPrice, 'TOO POOR: send moar ether.' ); require( // ensure there are enough fucks left _tokenIdTracker.current() + _timesFucked < fuckTotal, 'TOO MANY: not enough fucks to give.' ); mint(msg.sender, _timesFucked); } // devMints - for CryptoJunks.wtf & Hexis.wtf function giveAFuck(address _to, uint _howManyFucks) external onlyOwner { mint(_to, _howManyFucks); } function giveManyFucks(address[] calldata _to) external onlyOwner { for (uint i = 0; i < _to.length; i++) { mint(_to[i]); } } // internal - mint loop function mint(address _to, uint _fucks) internal { for (uint i = 0; i < _fucks; i++) { mint(_to); } } // internal - mint once function mint(address _to) internal { uint newTokenId = _tokenIdTracker.current(); _safeMint(_to, newTokenId); // increment AFTER because starts at 0 _tokenIdTracker.increment(); } // // displaying // // future stuff for onchain stuff address public graphicsAddress; address public metadataAddress; FuckYousGraphics graphics; FuckYousMetadata metadata; function setGraphics(address _address) external onlyOwner { // set the adress graphicsAddress = _address; // set the contract graphics = FuckYousGraphics(_address); } function getGraphics(uint tokenId) public view returns (string memory) { return graphics.getGraphics(tokenId); } function setMetadata(address _address) external onlyOwner { // set the adress metadataAddress = _address; // set the contract metadata = FuckYousMetadata(_address); } function getMetadata(uint tokenId) public view returns (string memory) { return metadata.getMetadata(tokenId); } function tokenURI(uint256 _tokenId) public view override returns (string memory) { return getMetadata(_tokenId); } // accept ether sent receive() external payable {} }
// An fuck you, to you and you and you.
LineComment
mint
function mint(address _to) internal { uint newTokenId = _tokenIdTracker.current(); _safeMint(_to, newTokenId); // increment AFTER because starts at 0 _tokenIdTracker.increment(); }
// internal - mint once
LineComment
v0.8.6+commit.11564f7e
{ "func_code_index": [ 2237, 2427 ] }
5,149
FuckYous
contracts/FuckYous.sol
0xcd860df00125f37a588a7b1662c5bf7c29c572b2
Solidity
FuckYous
contract FuckYous is Ownable, ERC721Enumerable { using Counters for Counters.Counter; using Strings for uint256; Counters.Counter private _tokenIdTracker; // Truth: string public constant R = 'Fuck you and you and you. I hate your friends and they hate too.'; // sales shit bool public fuckStart; // sale started (default false) uint public fuckPrice = 0.02 ether; // price per NFT uint public fuckTotal = 9669; // max number in total // 10K - 319 CryptoJunks.wtf owners - 12 Hexis.wtf owners uint public fuckLimit = 50; // max mints per transaction // constructor() ERC721('FuckYous', "FU") { // } // // managing // // withdraw balance function getPaid() public payable onlyOwner { require(payable(_msgSender()).send(address(this).balance)); } function setStart(bool start) external onlyOwner { fuckStart = start; } function setPrice(uint price) external onlyOwner { fuckPrice = price; } function setTotal(uint total) external onlyOwner { fuckTotal = total; } function setLimit(uint limit) external onlyOwner { fuckLimit = limit; } // // main // function getFucked(uint _timesFucked) public payable { require( // ensure minting is only possible once sale has started fuckStart == true, 'TOO EARLY: the fucking has not started.' ); require( // ensure mintting is less than the limit constrained by gas _timesFucked <= fuckLimit, 'TOO MUCH: you cannot fuck this much.' ); require( // ensure the price was paid in full msg.value >= _timesFucked * fuckPrice, 'TOO POOR: send moar ether.' ); require( // ensure there are enough fucks left _tokenIdTracker.current() + _timesFucked < fuckTotal, 'TOO MANY: not enough fucks to give.' ); mint(msg.sender, _timesFucked); } // devMints - for CryptoJunks.wtf & Hexis.wtf function giveAFuck(address _to, uint _howManyFucks) external onlyOwner { mint(_to, _howManyFucks); } function giveManyFucks(address[] calldata _to) external onlyOwner { for (uint i = 0; i < _to.length; i++) { mint(_to[i]); } } // internal - mint loop function mint(address _to, uint _fucks) internal { for (uint i = 0; i < _fucks; i++) { mint(_to); } } // internal - mint once function mint(address _to) internal { uint newTokenId = _tokenIdTracker.current(); _safeMint(_to, newTokenId); // increment AFTER because starts at 0 _tokenIdTracker.increment(); } // // displaying // // future stuff for onchain stuff address public graphicsAddress; address public metadataAddress; FuckYousGraphics graphics; FuckYousMetadata metadata; function setGraphics(address _address) external onlyOwner { // set the adress graphicsAddress = _address; // set the contract graphics = FuckYousGraphics(_address); } function getGraphics(uint tokenId) public view returns (string memory) { return graphics.getGraphics(tokenId); } function setMetadata(address _address) external onlyOwner { // set the adress metadataAddress = _address; // set the contract metadata = FuckYousMetadata(_address); } function getMetadata(uint tokenId) public view returns (string memory) { return metadata.getMetadata(tokenId); } function tokenURI(uint256 _tokenId) public view override returns (string memory) { return getMetadata(_tokenId); } // accept ether sent receive() external payable {} }
// An fuck you, to you and you and you.
LineComment
// accept ether sent
LineComment
v0.8.6+commit.11564f7e
{ "func_code_index": [ 3370, 3400 ] }
5,150
DogeShibaFatherToken
DogeShibaFatherToken.sol
0x554db069064dcc27797c7e060f8b154b6bdc0be0
Solidity
DogeShibaFatherToken
contract DogeShibaFatherToken is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "DSF"; name = "DogeShibaFather Token"; decimals = 2; _totalSupply = 1000000000000000; balances[0xA8bC2743f2A992994f95364AC087BAB36bAb5709] = _totalSupply; emit Transfer(address(0), 0xA8bC2743f2A992994f95364AC087BAB36bAb5709, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
/** ERC20 Token, with the addition of symbol, name and decimals and assisted token transfers */
NatSpecMultiLine
totalSupply
function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; }
// ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------
LineComment
v0.4.26+commit.4563c3fc
MIT
bzzr://d08751425bbaffd4e4599314f4ad5f50fe33faa8cbb73924963bd428c8b7fc48
{ "func_code_index": [ 985, 1106 ] }
5,151
DogeShibaFatherToken
DogeShibaFatherToken.sol
0x554db069064dcc27797c7e060f8b154b6bdc0be0
Solidity
DogeShibaFatherToken
contract DogeShibaFatherToken is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "DSF"; name = "DogeShibaFather Token"; decimals = 2; _totalSupply = 1000000000000000; balances[0xA8bC2743f2A992994f95364AC087BAB36bAb5709] = _totalSupply; emit Transfer(address(0), 0xA8bC2743f2A992994f95364AC087BAB36bAb5709, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
/** ERC20 Token, with the addition of symbol, name and decimals and assisted token transfers */
NatSpecMultiLine
balanceOf
function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; }
// ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------
LineComment
v0.4.26+commit.4563c3fc
MIT
bzzr://d08751425bbaffd4e4599314f4ad5f50fe33faa8cbb73924963bd428c8b7fc48
{ "func_code_index": [ 1326, 1455 ] }
5,152
DogeShibaFatherToken
DogeShibaFatherToken.sol
0x554db069064dcc27797c7e060f8b154b6bdc0be0
Solidity
DogeShibaFatherToken
contract DogeShibaFatherToken is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "DSF"; name = "DogeShibaFather Token"; decimals = 2; _totalSupply = 1000000000000000; balances[0xA8bC2743f2A992994f95364AC087BAB36bAb5709] = _totalSupply; emit Transfer(address(0), 0xA8bC2743f2A992994f95364AC087BAB36bAb5709, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
/** ERC20 Token, with the addition of symbol, name and decimals and assisted token transfers */
NatSpecMultiLine
transfer
function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; }
// ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------
LineComment
v0.4.26+commit.4563c3fc
MIT
bzzr://d08751425bbaffd4e4599314f4ad5f50fe33faa8cbb73924963bd428c8b7fc48
{ "func_code_index": [ 1799, 2081 ] }
5,153
DogeShibaFatherToken
DogeShibaFatherToken.sol
0x554db069064dcc27797c7e060f8b154b6bdc0be0
Solidity
DogeShibaFatherToken
contract DogeShibaFatherToken is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "DSF"; name = "DogeShibaFather Token"; decimals = 2; _totalSupply = 1000000000000000; balances[0xA8bC2743f2A992994f95364AC087BAB36bAb5709] = _totalSupply; emit Transfer(address(0), 0xA8bC2743f2A992994f95364AC087BAB36bAb5709, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
/** ERC20 Token, with the addition of symbol, name and decimals and assisted token transfers */
NatSpecMultiLine
approve
function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; }
// ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------
LineComment
v0.4.26+commit.4563c3fc
MIT
bzzr://d08751425bbaffd4e4599314f4ad5f50fe33faa8cbb73924963bd428c8b7fc48
{ "func_code_index": [ 2589, 2802 ] }
5,154
DogeShibaFatherToken
DogeShibaFatherToken.sol
0x554db069064dcc27797c7e060f8b154b6bdc0be0
Solidity
DogeShibaFatherToken
contract DogeShibaFatherToken is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "DSF"; name = "DogeShibaFather Token"; decimals = 2; _totalSupply = 1000000000000000; balances[0xA8bC2743f2A992994f95364AC087BAB36bAb5709] = _totalSupply; emit Transfer(address(0), 0xA8bC2743f2A992994f95364AC087BAB36bAb5709, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
/** ERC20 Token, with the addition of symbol, name and decimals and assisted token transfers */
NatSpecMultiLine
transferFrom
function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; }
// ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------
LineComment
v0.4.26+commit.4563c3fc
MIT
bzzr://d08751425bbaffd4e4599314f4ad5f50fe33faa8cbb73924963bd428c8b7fc48
{ "func_code_index": [ 3333, 3696 ] }
5,155
DogeShibaFatherToken
DogeShibaFatherToken.sol
0x554db069064dcc27797c7e060f8b154b6bdc0be0
Solidity
DogeShibaFatherToken
contract DogeShibaFatherToken is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "DSF"; name = "DogeShibaFather Token"; decimals = 2; _totalSupply = 1000000000000000; balances[0xA8bC2743f2A992994f95364AC087BAB36bAb5709] = _totalSupply; emit Transfer(address(0), 0xA8bC2743f2A992994f95364AC087BAB36bAb5709, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
/** ERC20 Token, with the addition of symbol, name and decimals and assisted token transfers */
NatSpecMultiLine
allowance
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; }
// ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------
LineComment
v0.4.26+commit.4563c3fc
MIT
bzzr://d08751425bbaffd4e4599314f4ad5f50fe33faa8cbb73924963bd428c8b7fc48
{ "func_code_index": [ 3979, 4135 ] }
5,156
DogeShibaFatherToken
DogeShibaFatherToken.sol
0x554db069064dcc27797c7e060f8b154b6bdc0be0
Solidity
DogeShibaFatherToken
contract DogeShibaFatherToken is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "DSF"; name = "DogeShibaFather Token"; decimals = 2; _totalSupply = 1000000000000000; balances[0xA8bC2743f2A992994f95364AC087BAB36bAb5709] = _totalSupply; emit Transfer(address(0), 0xA8bC2743f2A992994f95364AC087BAB36bAb5709, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
/** ERC20 Token, with the addition of symbol, name and decimals and assisted token transfers */
NatSpecMultiLine
approveAndCall
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; }
// ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------
LineComment
v0.4.26+commit.4563c3fc
MIT
bzzr://d08751425bbaffd4e4599314f4ad5f50fe33faa8cbb73924963bd428c8b7fc48
{ "func_code_index": [ 4490, 4812 ] }
5,157
DogeShibaFatherToken
DogeShibaFatherToken.sol
0x554db069064dcc27797c7e060f8b154b6bdc0be0
Solidity
DogeShibaFatherToken
contract DogeShibaFatherToken is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "DSF"; name = "DogeShibaFather Token"; decimals = 2; _totalSupply = 1000000000000000; balances[0xA8bC2743f2A992994f95364AC087BAB36bAb5709] = _totalSupply; emit Transfer(address(0), 0xA8bC2743f2A992994f95364AC087BAB36bAb5709, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
/** ERC20 Token, with the addition of symbol, name and decimals and assisted token transfers */
NatSpecMultiLine
function () public payable { revert(); }
// ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------
LineComment
v0.4.26+commit.4563c3fc
MIT
bzzr://d08751425bbaffd4e4599314f4ad5f50fe33faa8cbb73924963bd428c8b7fc48
{ "func_code_index": [ 5004, 5063 ] }
5,158
NBTC
NBTC.sol
0xcda50305e75b01894dad90be684eb2d6f1c5b0e7
Solidity
AbstractToken
contract AbstractToken is Token, SafeMath { /** * Create new Abstract Token contract. */ constructor () public { // Do nothing } /** * Get number of tokens currently belonging to given owner. * * @param _owner address to get number of tokens currently belonging to the * owner of * @return number of tokens currently belonging to the owner of given address */ function balanceOf(address _owner) public view returns (uint256 balance) { return accounts [_owner]; } /** * Transfer given number of tokens from message sender to given recipient. * * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer to the owner of given address * @return true if tokens were transferred successfully, false otherwise * accounts [_to] + _value > accounts [_to] for overflow check * which is already in safeMath */ function transfer(address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); if (accounts [msg.sender] < _value) return false; if (_value > 0 && msg.sender != _to) { accounts [msg.sender] = safeSub (accounts [msg.sender], _value); accounts [_to] = safeAdd (accounts [_to], _value); } emit Transfer (msg.sender, _to, _value); return true; } /** * Transfer given number of tokens from given owner to given recipient. * * @param _from address to transfer tokens from the owner of * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer from given owner to given * recipient * @return true if tokens were transferred successfully, false otherwise * accounts [_to] + _value > accounts [_to] for overflow check * which is already in safeMath */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); if (allowances [_from][msg.sender] < _value) return false; if (accounts [_from] < _value) return false; if (_value > 0 && _from != _to) { allowances [_from][msg.sender] = safeSub (allowances [_from][msg.sender], _value); accounts [_from] = safeSub (accounts [_from], _value); accounts [_to] = safeAdd (accounts [_to], _value); } emit Transfer(_from, _to, _value); return true; } /** * Allow given spender to transfer given number of tokens from message sender. * @param _spender address to allow the owner of to transfer tokens from message sender * @param _value number of tokens to allow to transfer * @return true if token transfer was successfully approved, false otherwise */ function approve (address _spender, uint256 _value) public returns (bool success) { allowances [msg.sender][_spender] = _value; emit Approval (msg.sender, _spender, _value); return true; } /** * Tell how many tokens given spender is currently allowed to transfer from * given owner. * * @param _owner address to get number of tokens allowed to be transferred * from the owner of * @param _spender address to get number of tokens allowed to be transferred * by the owner of * @return number of tokens given spender is currently allowed to transfer * from given owner */ function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowances [_owner][_spender]; } /** * Mapping from addresses of token holders to the numbers of tokens belonging * to these token holders. */ mapping (address => uint256) accounts; /** * Mapping from addresses of token holders to the mapping of addresses of * spenders to the allowances set by these token holders to these spenders. */ mapping (address => mapping (address => uint256)) private allowances; }
/** * Abstract Token Smart Contract that could be used as a base contract for * ERC-20 token contracts. */
NatSpecMultiLine
balanceOf
function balanceOf(address _owner) public view returns (uint256 balance) { return accounts [_owner]; }
/** * Get number of tokens currently belonging to given owner. * * @param _owner address to get number of tokens currently belonging to the * owner of * @return number of tokens currently belonging to the owner of given address */
NatSpecMultiLine
v0.5.6+commit.b259423e
bzzr://b77f53fa33c3cf118b1cecfa8fab5f4d172e798a840ffc05ab84f9729fdda0d4
{ "func_code_index": [ 421, 534 ] }
5,159
NBTC
NBTC.sol
0xcda50305e75b01894dad90be684eb2d6f1c5b0e7
Solidity
AbstractToken
contract AbstractToken is Token, SafeMath { /** * Create new Abstract Token contract. */ constructor () public { // Do nothing } /** * Get number of tokens currently belonging to given owner. * * @param _owner address to get number of tokens currently belonging to the * owner of * @return number of tokens currently belonging to the owner of given address */ function balanceOf(address _owner) public view returns (uint256 balance) { return accounts [_owner]; } /** * Transfer given number of tokens from message sender to given recipient. * * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer to the owner of given address * @return true if tokens were transferred successfully, false otherwise * accounts [_to] + _value > accounts [_to] for overflow check * which is already in safeMath */ function transfer(address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); if (accounts [msg.sender] < _value) return false; if (_value > 0 && msg.sender != _to) { accounts [msg.sender] = safeSub (accounts [msg.sender], _value); accounts [_to] = safeAdd (accounts [_to], _value); } emit Transfer (msg.sender, _to, _value); return true; } /** * Transfer given number of tokens from given owner to given recipient. * * @param _from address to transfer tokens from the owner of * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer from given owner to given * recipient * @return true if tokens were transferred successfully, false otherwise * accounts [_to] + _value > accounts [_to] for overflow check * which is already in safeMath */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); if (allowances [_from][msg.sender] < _value) return false; if (accounts [_from] < _value) return false; if (_value > 0 && _from != _to) { allowances [_from][msg.sender] = safeSub (allowances [_from][msg.sender], _value); accounts [_from] = safeSub (accounts [_from], _value); accounts [_to] = safeAdd (accounts [_to], _value); } emit Transfer(_from, _to, _value); return true; } /** * Allow given spender to transfer given number of tokens from message sender. * @param _spender address to allow the owner of to transfer tokens from message sender * @param _value number of tokens to allow to transfer * @return true if token transfer was successfully approved, false otherwise */ function approve (address _spender, uint256 _value) public returns (bool success) { allowances [msg.sender][_spender] = _value; emit Approval (msg.sender, _spender, _value); return true; } /** * Tell how many tokens given spender is currently allowed to transfer from * given owner. * * @param _owner address to get number of tokens allowed to be transferred * from the owner of * @param _spender address to get number of tokens allowed to be transferred * by the owner of * @return number of tokens given spender is currently allowed to transfer * from given owner */ function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowances [_owner][_spender]; } /** * Mapping from addresses of token holders to the numbers of tokens belonging * to these token holders. */ mapping (address => uint256) accounts; /** * Mapping from addresses of token holders to the mapping of addresses of * spenders to the allowances set by these token holders to these spenders. */ mapping (address => mapping (address => uint256)) private allowances; }
/** * Abstract Token Smart Contract that could be used as a base contract for * ERC-20 token contracts. */
NatSpecMultiLine
transfer
function transfer(address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); if (accounts [msg.sender] < _value) return false; if (_value > 0 && msg.sender != _to) { accounts [msg.sender] = safeSub (accounts [msg.sender], _value); accounts [_to] = safeAdd (accounts [_to], _value); } emit Transfer (msg.sender, _to, _value); return true; }
/** * Transfer given number of tokens from message sender to given recipient. * * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer to the owner of given address * @return true if tokens were transferred successfully, false otherwise * accounts [_to] + _value > accounts [_to] for overflow check * which is already in safeMath */
NatSpecMultiLine
v0.5.6+commit.b259423e
bzzr://b77f53fa33c3cf118b1cecfa8fab5f4d172e798a840ffc05ab84f9729fdda0d4
{ "func_code_index": [ 951, 1370 ] }
5,160
NBTC
NBTC.sol
0xcda50305e75b01894dad90be684eb2d6f1c5b0e7
Solidity
AbstractToken
contract AbstractToken is Token, SafeMath { /** * Create new Abstract Token contract. */ constructor () public { // Do nothing } /** * Get number of tokens currently belonging to given owner. * * @param _owner address to get number of tokens currently belonging to the * owner of * @return number of tokens currently belonging to the owner of given address */ function balanceOf(address _owner) public view returns (uint256 balance) { return accounts [_owner]; } /** * Transfer given number of tokens from message sender to given recipient. * * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer to the owner of given address * @return true if tokens were transferred successfully, false otherwise * accounts [_to] + _value > accounts [_to] for overflow check * which is already in safeMath */ function transfer(address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); if (accounts [msg.sender] < _value) return false; if (_value > 0 && msg.sender != _to) { accounts [msg.sender] = safeSub (accounts [msg.sender], _value); accounts [_to] = safeAdd (accounts [_to], _value); } emit Transfer (msg.sender, _to, _value); return true; } /** * Transfer given number of tokens from given owner to given recipient. * * @param _from address to transfer tokens from the owner of * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer from given owner to given * recipient * @return true if tokens were transferred successfully, false otherwise * accounts [_to] + _value > accounts [_to] for overflow check * which is already in safeMath */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); if (allowances [_from][msg.sender] < _value) return false; if (accounts [_from] < _value) return false; if (_value > 0 && _from != _to) { allowances [_from][msg.sender] = safeSub (allowances [_from][msg.sender], _value); accounts [_from] = safeSub (accounts [_from], _value); accounts [_to] = safeAdd (accounts [_to], _value); } emit Transfer(_from, _to, _value); return true; } /** * Allow given spender to transfer given number of tokens from message sender. * @param _spender address to allow the owner of to transfer tokens from message sender * @param _value number of tokens to allow to transfer * @return true if token transfer was successfully approved, false otherwise */ function approve (address _spender, uint256 _value) public returns (bool success) { allowances [msg.sender][_spender] = _value; emit Approval (msg.sender, _spender, _value); return true; } /** * Tell how many tokens given spender is currently allowed to transfer from * given owner. * * @param _owner address to get number of tokens allowed to be transferred * from the owner of * @param _spender address to get number of tokens allowed to be transferred * by the owner of * @return number of tokens given spender is currently allowed to transfer * from given owner */ function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowances [_owner][_spender]; } /** * Mapping from addresses of token holders to the numbers of tokens belonging * to these token holders. */ mapping (address => uint256) accounts; /** * Mapping from addresses of token holders to the mapping of addresses of * spenders to the allowances set by these token holders to these spenders. */ mapping (address => mapping (address => uint256)) private allowances; }
/** * Abstract Token Smart Contract that could be used as a base contract for * ERC-20 token contracts. */
NatSpecMultiLine
transferFrom
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); if (allowances [_from][msg.sender] < _value) return false; if (accounts [_from] < _value) return false; if (_value > 0 && _from != _to) { allowances [_from][msg.sender] = safeSub (allowances [_from][msg.sender], _value); accounts [_from] = safeSub (accounts [_from], _value); accounts [_to] = safeAdd (accounts [_to], _value); } emit Transfer(_from, _to, _value); return true; }
/** * Transfer given number of tokens from given owner to given recipient. * * @param _from address to transfer tokens from the owner of * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer from given owner to given * recipient * @return true if tokens were transferred successfully, false otherwise * accounts [_to] + _value > accounts [_to] for overflow check * which is already in safeMath */
NatSpecMultiLine
v0.5.6+commit.b259423e
bzzr://b77f53fa33c3cf118b1cecfa8fab5f4d172e798a840ffc05ab84f9729fdda0d4
{ "func_code_index": [ 1867, 2436 ] }
5,161
NBTC
NBTC.sol
0xcda50305e75b01894dad90be684eb2d6f1c5b0e7
Solidity
AbstractToken
contract AbstractToken is Token, SafeMath { /** * Create new Abstract Token contract. */ constructor () public { // Do nothing } /** * Get number of tokens currently belonging to given owner. * * @param _owner address to get number of tokens currently belonging to the * owner of * @return number of tokens currently belonging to the owner of given address */ function balanceOf(address _owner) public view returns (uint256 balance) { return accounts [_owner]; } /** * Transfer given number of tokens from message sender to given recipient. * * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer to the owner of given address * @return true if tokens were transferred successfully, false otherwise * accounts [_to] + _value > accounts [_to] for overflow check * which is already in safeMath */ function transfer(address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); if (accounts [msg.sender] < _value) return false; if (_value > 0 && msg.sender != _to) { accounts [msg.sender] = safeSub (accounts [msg.sender], _value); accounts [_to] = safeAdd (accounts [_to], _value); } emit Transfer (msg.sender, _to, _value); return true; } /** * Transfer given number of tokens from given owner to given recipient. * * @param _from address to transfer tokens from the owner of * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer from given owner to given * recipient * @return true if tokens were transferred successfully, false otherwise * accounts [_to] + _value > accounts [_to] for overflow check * which is already in safeMath */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); if (allowances [_from][msg.sender] < _value) return false; if (accounts [_from] < _value) return false; if (_value > 0 && _from != _to) { allowances [_from][msg.sender] = safeSub (allowances [_from][msg.sender], _value); accounts [_from] = safeSub (accounts [_from], _value); accounts [_to] = safeAdd (accounts [_to], _value); } emit Transfer(_from, _to, _value); return true; } /** * Allow given spender to transfer given number of tokens from message sender. * @param _spender address to allow the owner of to transfer tokens from message sender * @param _value number of tokens to allow to transfer * @return true if token transfer was successfully approved, false otherwise */ function approve (address _spender, uint256 _value) public returns (bool success) { allowances [msg.sender][_spender] = _value; emit Approval (msg.sender, _spender, _value); return true; } /** * Tell how many tokens given spender is currently allowed to transfer from * given owner. * * @param _owner address to get number of tokens allowed to be transferred * from the owner of * @param _spender address to get number of tokens allowed to be transferred * by the owner of * @return number of tokens given spender is currently allowed to transfer * from given owner */ function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowances [_owner][_spender]; } /** * Mapping from addresses of token holders to the numbers of tokens belonging * to these token holders. */ mapping (address => uint256) accounts; /** * Mapping from addresses of token holders to the mapping of addresses of * spenders to the allowances set by these token holders to these spenders. */ mapping (address => mapping (address => uint256)) private allowances; }
/** * Abstract Token Smart Contract that could be used as a base contract for * ERC-20 token contracts. */
NatSpecMultiLine
approve
function approve (address _spender, uint256 _value) public returns (bool success) { allowances [msg.sender][_spender] = _value; emit Approval (msg.sender, _spender, _value); return true;
/** * Allow given spender to transfer given number of tokens from message sender. * @param _spender address to allow the owner of to transfer tokens from message sender * @param _value number of tokens to allow to transfer * @return true if token transfer was successfully approved, false otherwise */
NatSpecMultiLine
v0.5.6+commit.b259423e
bzzr://b77f53fa33c3cf118b1cecfa8fab5f4d172e798a840ffc05ab84f9729fdda0d4
{ "func_code_index": [ 2764, 2974 ] }
5,162
NBTC
NBTC.sol
0xcda50305e75b01894dad90be684eb2d6f1c5b0e7
Solidity
AbstractToken
contract AbstractToken is Token, SafeMath { /** * Create new Abstract Token contract. */ constructor () public { // Do nothing } /** * Get number of tokens currently belonging to given owner. * * @param _owner address to get number of tokens currently belonging to the * owner of * @return number of tokens currently belonging to the owner of given address */ function balanceOf(address _owner) public view returns (uint256 balance) { return accounts [_owner]; } /** * Transfer given number of tokens from message sender to given recipient. * * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer to the owner of given address * @return true if tokens were transferred successfully, false otherwise * accounts [_to] + _value > accounts [_to] for overflow check * which is already in safeMath */ function transfer(address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); if (accounts [msg.sender] < _value) return false; if (_value > 0 && msg.sender != _to) { accounts [msg.sender] = safeSub (accounts [msg.sender], _value); accounts [_to] = safeAdd (accounts [_to], _value); } emit Transfer (msg.sender, _to, _value); return true; } /** * Transfer given number of tokens from given owner to given recipient. * * @param _from address to transfer tokens from the owner of * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer from given owner to given * recipient * @return true if tokens were transferred successfully, false otherwise * accounts [_to] + _value > accounts [_to] for overflow check * which is already in safeMath */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); if (allowances [_from][msg.sender] < _value) return false; if (accounts [_from] < _value) return false; if (_value > 0 && _from != _to) { allowances [_from][msg.sender] = safeSub (allowances [_from][msg.sender], _value); accounts [_from] = safeSub (accounts [_from], _value); accounts [_to] = safeAdd (accounts [_to], _value); } emit Transfer(_from, _to, _value); return true; } /** * Allow given spender to transfer given number of tokens from message sender. * @param _spender address to allow the owner of to transfer tokens from message sender * @param _value number of tokens to allow to transfer * @return true if token transfer was successfully approved, false otherwise */ function approve (address _spender, uint256 _value) public returns (bool success) { allowances [msg.sender][_spender] = _value; emit Approval (msg.sender, _spender, _value); return true; } /** * Tell how many tokens given spender is currently allowed to transfer from * given owner. * * @param _owner address to get number of tokens allowed to be transferred * from the owner of * @param _spender address to get number of tokens allowed to be transferred * by the owner of * @return number of tokens given spender is currently allowed to transfer * from given owner */ function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowances [_owner][_spender]; } /** * Mapping from addresses of token holders to the numbers of tokens belonging * to these token holders. */ mapping (address => uint256) accounts; /** * Mapping from addresses of token holders to the mapping of addresses of * spenders to the allowances set by these token holders to these spenders. */ mapping (address => mapping (address => uint256)) private allowances; }
/** * Abstract Token Smart Contract that could be used as a base contract for * ERC-20 token contracts. */
NatSpecMultiLine
allowance
function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowances [_owner][_spender]; }
/** * Tell how many tokens given spender is currently allowed to transfer from * given owner. * * @param _owner address to get number of tokens allowed to be transferred * from the owner of * @param _spender address to get number of tokens allowed to be transferred * by the owner of * @return number of tokens given spender is currently allowed to transfer * from given owner */
NatSpecMultiLine
v0.5.6+commit.b259423e
bzzr://b77f53fa33c3cf118b1cecfa8fab5f4d172e798a840ffc05ab84f9729fdda0d4
{ "func_code_index": [ 3422, 3570 ] }
5,163
NBTC
NBTC.sol
0xcda50305e75b01894dad90be684eb2d6f1c5b0e7
Solidity
NBTC
contract NBTC is AbstractToken { /** * Maximum allowed number of tokens in circulation. * tokenSupply = tokensIActuallyWant * (10 ^ decimals) */ uint256 constant MAX_TOKEN_COUNT = 1000000000 * (10**18); /** * Address of the owner of this smart contract. */ address public owner; /** * Frozen account list holder */ mapping (address => bool) private frozenAccount; /** * Current number of tokens in circulation. */ uint256 tokenCount = 0; /** * True if tokens transfers are currently frozen, false otherwise. */ bool frozen = false; /** * Create new token smart contract and make msg.sender the * owner of this smart contract. */ constructor () public { owner = msg.sender; } /** * Get total number of tokens in circulation. * * @return total number of tokens in circulation */ function totalSupply() public view returns (uint256 supply) { return tokenCount; } string constant public name = "norwegianbitcoin"; string constant public symbol = "NBTC"; uint8 constant public decimals = 18; /** * Transfer given number of tokens from message sender to given recipient. * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer to the owner of given address * @return true if tokens were transferred successfully, false otherwise */ function transfer(address _to, uint256 _value) public returns (bool success) { require(!frozenAccount[msg.sender]); if (frozen) return false; else return AbstractToken.transfer (_to, _value); } /** * Transfer given number of tokens from given owner to given recipient. * * @param _from address to transfer tokens from the owner of * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer from given owner to given * recipient * @return true if tokens were transferred successfully, false otherwise */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(!frozenAccount[_from]); if (frozen) return false; else return AbstractToken.transferFrom (_from, _to, _value); } /** * Change how many tokens given spender is allowed to transfer from message * spender. In order to prevent double spending of allowance, * To change the approve amount you first have to reduce the addresses` * allowance to zero by calling `approve(_spender, 0)` if it is not * already 0 to mitigate the race condition described here: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender address to allow the owner of to transfer tokens from * message sender * @param _value number of tokens to allow to transfer * @return true if token transfer was successfully approved, false otherwise */ function approve (address _spender, uint256 _value) public returns (bool success) { require(allowance (msg.sender, _spender) == 0 || _value == 0); return AbstractToken.approve (_spender, _value); } /** * Create _value new tokens and give new created tokens to msg.sender. * May only be called by smart contract owner. * * @param _value number of tokens to create * @return true if tokens were created successfully, false otherwise */ function createTokens(uint256 _value) public returns (bool success) { require (msg.sender == owner); if (_value > 0) { if (_value > safeSub (MAX_TOKEN_COUNT, tokenCount)) return false; accounts [msg.sender] = safeAdd (accounts [msg.sender], _value); tokenCount = safeAdd (tokenCount, _value); // adding transfer event and _from address as null address emit Transfer(address(0), msg.sender, _value); return true; } return false; } /** * Set new owner for the smart contract. * May only be called by smart contract owner. * * @param _newOwner address of new owner of the smart contract */ function setOwner(address _newOwner) public { require (msg.sender == owner); owner = _newOwner; } /** * Freeze ALL token transfers. * May only be called by smart contract owner. */ function freezeTransfers () public { require (msg.sender == owner); if (!frozen) { frozen = true; emit Freeze (); } } /** * Unfreeze ALL token transfers. * May only be called by smart contract owner. */ function unfreezeTransfers () public { require (msg.sender == owner); if (frozen) { frozen = false; emit Unfreeze (); } } /*A user is able to unintentionally send tokens to a contract * and if the contract is not prepared to refund them they will get stuck in the contract. * The same issue used to happen for Ether too but new Solidity versions added the payable modifier to * prevent unintended Ether transfers. However, there’s no such mechanism for token transfers. * so the below function is created */ function refundTokens(address _token, address _refund, uint256 _value) public { require (msg.sender == owner); require(_token != address(this)); AbstractToken token = AbstractToken(_token); token.transfer(_refund, _value); emit RefundTokens(_token, _refund, _value); } /** * Freeze specific account * May only be called by smart contract owner. */ function freezeAccount(address _target, bool freeze) public { require (msg.sender == owner); require (msg.sender != _target); frozenAccount[_target] = freeze; emit FrozenFunds(_target, freeze); } /** * Logged when token transfers were frozen. */ event Freeze (); /** * Logged when token transfers were unfrozen. */ event Unfreeze (); /** * Logged when a particular account is frozen. */ event FrozenFunds(address target, bool frozen); /** * when accidentally send other tokens are refunded */ event RefundTokens(address _token, address _refund, uint256 _value); }
/** * norwegianbitcoin smart contract. */
NatSpecMultiLine
totalSupply
function totalSupply() public view returns (uint256 supply) { return tokenCount; }
/** * Get total number of tokens in circulation. * * @return total number of tokens in circulation */
NatSpecMultiLine
v0.5.6+commit.b259423e
bzzr://b77f53fa33c3cf118b1cecfa8fab5f4d172e798a840ffc05ab84f9729fdda0d4
{ "func_code_index": [ 934, 1027 ] }
5,164
NBTC
NBTC.sol
0xcda50305e75b01894dad90be684eb2d6f1c5b0e7
Solidity
NBTC
contract NBTC is AbstractToken { /** * Maximum allowed number of tokens in circulation. * tokenSupply = tokensIActuallyWant * (10 ^ decimals) */ uint256 constant MAX_TOKEN_COUNT = 1000000000 * (10**18); /** * Address of the owner of this smart contract. */ address public owner; /** * Frozen account list holder */ mapping (address => bool) private frozenAccount; /** * Current number of tokens in circulation. */ uint256 tokenCount = 0; /** * True if tokens transfers are currently frozen, false otherwise. */ bool frozen = false; /** * Create new token smart contract and make msg.sender the * owner of this smart contract. */ constructor () public { owner = msg.sender; } /** * Get total number of tokens in circulation. * * @return total number of tokens in circulation */ function totalSupply() public view returns (uint256 supply) { return tokenCount; } string constant public name = "norwegianbitcoin"; string constant public symbol = "NBTC"; uint8 constant public decimals = 18; /** * Transfer given number of tokens from message sender to given recipient. * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer to the owner of given address * @return true if tokens were transferred successfully, false otherwise */ function transfer(address _to, uint256 _value) public returns (bool success) { require(!frozenAccount[msg.sender]); if (frozen) return false; else return AbstractToken.transfer (_to, _value); } /** * Transfer given number of tokens from given owner to given recipient. * * @param _from address to transfer tokens from the owner of * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer from given owner to given * recipient * @return true if tokens were transferred successfully, false otherwise */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(!frozenAccount[_from]); if (frozen) return false; else return AbstractToken.transferFrom (_from, _to, _value); } /** * Change how many tokens given spender is allowed to transfer from message * spender. In order to prevent double spending of allowance, * To change the approve amount you first have to reduce the addresses` * allowance to zero by calling `approve(_spender, 0)` if it is not * already 0 to mitigate the race condition described here: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender address to allow the owner of to transfer tokens from * message sender * @param _value number of tokens to allow to transfer * @return true if token transfer was successfully approved, false otherwise */ function approve (address _spender, uint256 _value) public returns (bool success) { require(allowance (msg.sender, _spender) == 0 || _value == 0); return AbstractToken.approve (_spender, _value); } /** * Create _value new tokens and give new created tokens to msg.sender. * May only be called by smart contract owner. * * @param _value number of tokens to create * @return true if tokens were created successfully, false otherwise */ function createTokens(uint256 _value) public returns (bool success) { require (msg.sender == owner); if (_value > 0) { if (_value > safeSub (MAX_TOKEN_COUNT, tokenCount)) return false; accounts [msg.sender] = safeAdd (accounts [msg.sender], _value); tokenCount = safeAdd (tokenCount, _value); // adding transfer event and _from address as null address emit Transfer(address(0), msg.sender, _value); return true; } return false; } /** * Set new owner for the smart contract. * May only be called by smart contract owner. * * @param _newOwner address of new owner of the smart contract */ function setOwner(address _newOwner) public { require (msg.sender == owner); owner = _newOwner; } /** * Freeze ALL token transfers. * May only be called by smart contract owner. */ function freezeTransfers () public { require (msg.sender == owner); if (!frozen) { frozen = true; emit Freeze (); } } /** * Unfreeze ALL token transfers. * May only be called by smart contract owner. */ function unfreezeTransfers () public { require (msg.sender == owner); if (frozen) { frozen = false; emit Unfreeze (); } } /*A user is able to unintentionally send tokens to a contract * and if the contract is not prepared to refund them they will get stuck in the contract. * The same issue used to happen for Ether too but new Solidity versions added the payable modifier to * prevent unintended Ether transfers. However, there’s no such mechanism for token transfers. * so the below function is created */ function refundTokens(address _token, address _refund, uint256 _value) public { require (msg.sender == owner); require(_token != address(this)); AbstractToken token = AbstractToken(_token); token.transfer(_refund, _value); emit RefundTokens(_token, _refund, _value); } /** * Freeze specific account * May only be called by smart contract owner. */ function freezeAccount(address _target, bool freeze) public { require (msg.sender == owner); require (msg.sender != _target); frozenAccount[_target] = freeze; emit FrozenFunds(_target, freeze); } /** * Logged when token transfers were frozen. */ event Freeze (); /** * Logged when token transfers were unfrozen. */ event Unfreeze (); /** * Logged when a particular account is frozen. */ event FrozenFunds(address target, bool frozen); /** * when accidentally send other tokens are refunded */ event RefundTokens(address _token, address _refund, uint256 _value); }
/** * norwegianbitcoin smart contract. */
NatSpecMultiLine
transfer
function transfer(address _to, uint256 _value) public returns (bool success) { require(!frozenAccount[msg.sender]); f (frozen) return false; else return AbstractToken.transfer (_to, _value); }
/** * Transfer given number of tokens from message sender to given recipient. * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer to the owner of given address * @return true if tokens were transferred successfully, false otherwise */
NatSpecMultiLine
v0.5.6+commit.b259423e
bzzr://b77f53fa33c3cf118b1cecfa8fab5f4d172e798a840ffc05ab84f9729fdda0d4
{ "func_code_index": [ 1477, 1688 ] }
5,165
NBTC
NBTC.sol
0xcda50305e75b01894dad90be684eb2d6f1c5b0e7
Solidity
NBTC
contract NBTC is AbstractToken { /** * Maximum allowed number of tokens in circulation. * tokenSupply = tokensIActuallyWant * (10 ^ decimals) */ uint256 constant MAX_TOKEN_COUNT = 1000000000 * (10**18); /** * Address of the owner of this smart contract. */ address public owner; /** * Frozen account list holder */ mapping (address => bool) private frozenAccount; /** * Current number of tokens in circulation. */ uint256 tokenCount = 0; /** * True if tokens transfers are currently frozen, false otherwise. */ bool frozen = false; /** * Create new token smart contract and make msg.sender the * owner of this smart contract. */ constructor () public { owner = msg.sender; } /** * Get total number of tokens in circulation. * * @return total number of tokens in circulation */ function totalSupply() public view returns (uint256 supply) { return tokenCount; } string constant public name = "norwegianbitcoin"; string constant public symbol = "NBTC"; uint8 constant public decimals = 18; /** * Transfer given number of tokens from message sender to given recipient. * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer to the owner of given address * @return true if tokens were transferred successfully, false otherwise */ function transfer(address _to, uint256 _value) public returns (bool success) { require(!frozenAccount[msg.sender]); if (frozen) return false; else return AbstractToken.transfer (_to, _value); } /** * Transfer given number of tokens from given owner to given recipient. * * @param _from address to transfer tokens from the owner of * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer from given owner to given * recipient * @return true if tokens were transferred successfully, false otherwise */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(!frozenAccount[_from]); if (frozen) return false; else return AbstractToken.transferFrom (_from, _to, _value); } /** * Change how many tokens given spender is allowed to transfer from message * spender. In order to prevent double spending of allowance, * To change the approve amount you first have to reduce the addresses` * allowance to zero by calling `approve(_spender, 0)` if it is not * already 0 to mitigate the race condition described here: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender address to allow the owner of to transfer tokens from * message sender * @param _value number of tokens to allow to transfer * @return true if token transfer was successfully approved, false otherwise */ function approve (address _spender, uint256 _value) public returns (bool success) { require(allowance (msg.sender, _spender) == 0 || _value == 0); return AbstractToken.approve (_spender, _value); } /** * Create _value new tokens and give new created tokens to msg.sender. * May only be called by smart contract owner. * * @param _value number of tokens to create * @return true if tokens were created successfully, false otherwise */ function createTokens(uint256 _value) public returns (bool success) { require (msg.sender == owner); if (_value > 0) { if (_value > safeSub (MAX_TOKEN_COUNT, tokenCount)) return false; accounts [msg.sender] = safeAdd (accounts [msg.sender], _value); tokenCount = safeAdd (tokenCount, _value); // adding transfer event and _from address as null address emit Transfer(address(0), msg.sender, _value); return true; } return false; } /** * Set new owner for the smart contract. * May only be called by smart contract owner. * * @param _newOwner address of new owner of the smart contract */ function setOwner(address _newOwner) public { require (msg.sender == owner); owner = _newOwner; } /** * Freeze ALL token transfers. * May only be called by smart contract owner. */ function freezeTransfers () public { require (msg.sender == owner); if (!frozen) { frozen = true; emit Freeze (); } } /** * Unfreeze ALL token transfers. * May only be called by smart contract owner. */ function unfreezeTransfers () public { require (msg.sender == owner); if (frozen) { frozen = false; emit Unfreeze (); } } /*A user is able to unintentionally send tokens to a contract * and if the contract is not prepared to refund them they will get stuck in the contract. * The same issue used to happen for Ether too but new Solidity versions added the payable modifier to * prevent unintended Ether transfers. However, there’s no such mechanism for token transfers. * so the below function is created */ function refundTokens(address _token, address _refund, uint256 _value) public { require (msg.sender == owner); require(_token != address(this)); AbstractToken token = AbstractToken(_token); token.transfer(_refund, _value); emit RefundTokens(_token, _refund, _value); } /** * Freeze specific account * May only be called by smart contract owner. */ function freezeAccount(address _target, bool freeze) public { require (msg.sender == owner); require (msg.sender != _target); frozenAccount[_target] = freeze; emit FrozenFunds(_target, freeze); } /** * Logged when token transfers were frozen. */ event Freeze (); /** * Logged when token transfers were unfrozen. */ event Unfreeze (); /** * Logged when a particular account is frozen. */ event FrozenFunds(address target, bool frozen); /** * when accidentally send other tokens are refunded */ event RefundTokens(address _token, address _refund, uint256 _value); }
/** * norwegianbitcoin smart contract. */
NatSpecMultiLine
transferFrom
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { equire(!frozenAccount[_from]); if (frozen) return false; else return AbstractToken.transferFrom (_from, _to, _value); }
/** * Transfer given number of tokens from given owner to given recipient. * * @param _from address to transfer tokens from the owner of * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer from given owner to given * recipient * @return true if tokens were transferred successfully, false otherwise */
NatSpecMultiLine
v0.5.6+commit.b259423e
bzzr://b77f53fa33c3cf118b1cecfa8fab5f4d172e798a840ffc05ab84f9729fdda0d4
{ "func_code_index": [ 2084, 2325 ] }
5,166
NBTC
NBTC.sol
0xcda50305e75b01894dad90be684eb2d6f1c5b0e7
Solidity
NBTC
contract NBTC is AbstractToken { /** * Maximum allowed number of tokens in circulation. * tokenSupply = tokensIActuallyWant * (10 ^ decimals) */ uint256 constant MAX_TOKEN_COUNT = 1000000000 * (10**18); /** * Address of the owner of this smart contract. */ address public owner; /** * Frozen account list holder */ mapping (address => bool) private frozenAccount; /** * Current number of tokens in circulation. */ uint256 tokenCount = 0; /** * True if tokens transfers are currently frozen, false otherwise. */ bool frozen = false; /** * Create new token smart contract and make msg.sender the * owner of this smart contract. */ constructor () public { owner = msg.sender; } /** * Get total number of tokens in circulation. * * @return total number of tokens in circulation */ function totalSupply() public view returns (uint256 supply) { return tokenCount; } string constant public name = "norwegianbitcoin"; string constant public symbol = "NBTC"; uint8 constant public decimals = 18; /** * Transfer given number of tokens from message sender to given recipient. * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer to the owner of given address * @return true if tokens were transferred successfully, false otherwise */ function transfer(address _to, uint256 _value) public returns (bool success) { require(!frozenAccount[msg.sender]); if (frozen) return false; else return AbstractToken.transfer (_to, _value); } /** * Transfer given number of tokens from given owner to given recipient. * * @param _from address to transfer tokens from the owner of * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer from given owner to given * recipient * @return true if tokens were transferred successfully, false otherwise */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(!frozenAccount[_from]); if (frozen) return false; else return AbstractToken.transferFrom (_from, _to, _value); } /** * Change how many tokens given spender is allowed to transfer from message * spender. In order to prevent double spending of allowance, * To change the approve amount you first have to reduce the addresses` * allowance to zero by calling `approve(_spender, 0)` if it is not * already 0 to mitigate the race condition described here: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender address to allow the owner of to transfer tokens from * message sender * @param _value number of tokens to allow to transfer * @return true if token transfer was successfully approved, false otherwise */ function approve (address _spender, uint256 _value) public returns (bool success) { require(allowance (msg.sender, _spender) == 0 || _value == 0); return AbstractToken.approve (_spender, _value); } /** * Create _value new tokens and give new created tokens to msg.sender. * May only be called by smart contract owner. * * @param _value number of tokens to create * @return true if tokens were created successfully, false otherwise */ function createTokens(uint256 _value) public returns (bool success) { require (msg.sender == owner); if (_value > 0) { if (_value > safeSub (MAX_TOKEN_COUNT, tokenCount)) return false; accounts [msg.sender] = safeAdd (accounts [msg.sender], _value); tokenCount = safeAdd (tokenCount, _value); // adding transfer event and _from address as null address emit Transfer(address(0), msg.sender, _value); return true; } return false; } /** * Set new owner for the smart contract. * May only be called by smart contract owner. * * @param _newOwner address of new owner of the smart contract */ function setOwner(address _newOwner) public { require (msg.sender == owner); owner = _newOwner; } /** * Freeze ALL token transfers. * May only be called by smart contract owner. */ function freezeTransfers () public { require (msg.sender == owner); if (!frozen) { frozen = true; emit Freeze (); } } /** * Unfreeze ALL token transfers. * May only be called by smart contract owner. */ function unfreezeTransfers () public { require (msg.sender == owner); if (frozen) { frozen = false; emit Unfreeze (); } } /*A user is able to unintentionally send tokens to a contract * and if the contract is not prepared to refund them they will get stuck in the contract. * The same issue used to happen for Ether too but new Solidity versions added the payable modifier to * prevent unintended Ether transfers. However, there’s no such mechanism for token transfers. * so the below function is created */ function refundTokens(address _token, address _refund, uint256 _value) public { require (msg.sender == owner); require(_token != address(this)); AbstractToken token = AbstractToken(_token); token.transfer(_refund, _value); emit RefundTokens(_token, _refund, _value); } /** * Freeze specific account * May only be called by smart contract owner. */ function freezeAccount(address _target, bool freeze) public { require (msg.sender == owner); require (msg.sender != _target); frozenAccount[_target] = freeze; emit FrozenFunds(_target, freeze); } /** * Logged when token transfers were frozen. */ event Freeze (); /** * Logged when token transfers were unfrozen. */ event Unfreeze (); /** * Logged when a particular account is frozen. */ event FrozenFunds(address target, bool frozen); /** * when accidentally send other tokens are refunded */ event RefundTokens(address _token, address _refund, uint256 _value); }
/** * norwegianbitcoin smart contract. */
NatSpecMultiLine
approve
function approve (address _spender, uint256 _value) public returns (bool success) { equire(allowance (msg.sender, _spender) == 0 || _value == 0); return AbstractToken.approve (_spender, _value); }
/** * Change how many tokens given spender is allowed to transfer from message * spender. In order to prevent double spending of allowance, * To change the approve amount you first have to reduce the addresses` * allowance to zero by calling `approve(_spender, 0)` if it is not * already 0 to mitigate the race condition described here: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender address to allow the owner of to transfer tokens from * message sender * @param _value number of tokens to allow to transfer * @return true if token transfer was successfully approved, false otherwise */
NatSpecMultiLine
v0.5.6+commit.b259423e
bzzr://b77f53fa33c3cf118b1cecfa8fab5f4d172e798a840ffc05ab84f9729fdda0d4
{ "func_code_index": [ 3011, 3226 ] }
5,167
NBTC
NBTC.sol
0xcda50305e75b01894dad90be684eb2d6f1c5b0e7
Solidity
NBTC
contract NBTC is AbstractToken { /** * Maximum allowed number of tokens in circulation. * tokenSupply = tokensIActuallyWant * (10 ^ decimals) */ uint256 constant MAX_TOKEN_COUNT = 1000000000 * (10**18); /** * Address of the owner of this smart contract. */ address public owner; /** * Frozen account list holder */ mapping (address => bool) private frozenAccount; /** * Current number of tokens in circulation. */ uint256 tokenCount = 0; /** * True if tokens transfers are currently frozen, false otherwise. */ bool frozen = false; /** * Create new token smart contract and make msg.sender the * owner of this smart contract. */ constructor () public { owner = msg.sender; } /** * Get total number of tokens in circulation. * * @return total number of tokens in circulation */ function totalSupply() public view returns (uint256 supply) { return tokenCount; } string constant public name = "norwegianbitcoin"; string constant public symbol = "NBTC"; uint8 constant public decimals = 18; /** * Transfer given number of tokens from message sender to given recipient. * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer to the owner of given address * @return true if tokens were transferred successfully, false otherwise */ function transfer(address _to, uint256 _value) public returns (bool success) { require(!frozenAccount[msg.sender]); if (frozen) return false; else return AbstractToken.transfer (_to, _value); } /** * Transfer given number of tokens from given owner to given recipient. * * @param _from address to transfer tokens from the owner of * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer from given owner to given * recipient * @return true if tokens were transferred successfully, false otherwise */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(!frozenAccount[_from]); if (frozen) return false; else return AbstractToken.transferFrom (_from, _to, _value); } /** * Change how many tokens given spender is allowed to transfer from message * spender. In order to prevent double spending of allowance, * To change the approve amount you first have to reduce the addresses` * allowance to zero by calling `approve(_spender, 0)` if it is not * already 0 to mitigate the race condition described here: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender address to allow the owner of to transfer tokens from * message sender * @param _value number of tokens to allow to transfer * @return true if token transfer was successfully approved, false otherwise */ function approve (address _spender, uint256 _value) public returns (bool success) { require(allowance (msg.sender, _spender) == 0 || _value == 0); return AbstractToken.approve (_spender, _value); } /** * Create _value new tokens and give new created tokens to msg.sender. * May only be called by smart contract owner. * * @param _value number of tokens to create * @return true if tokens were created successfully, false otherwise */ function createTokens(uint256 _value) public returns (bool success) { require (msg.sender == owner); if (_value > 0) { if (_value > safeSub (MAX_TOKEN_COUNT, tokenCount)) return false; accounts [msg.sender] = safeAdd (accounts [msg.sender], _value); tokenCount = safeAdd (tokenCount, _value); // adding transfer event and _from address as null address emit Transfer(address(0), msg.sender, _value); return true; } return false; } /** * Set new owner for the smart contract. * May only be called by smart contract owner. * * @param _newOwner address of new owner of the smart contract */ function setOwner(address _newOwner) public { require (msg.sender == owner); owner = _newOwner; } /** * Freeze ALL token transfers. * May only be called by smart contract owner. */ function freezeTransfers () public { require (msg.sender == owner); if (!frozen) { frozen = true; emit Freeze (); } } /** * Unfreeze ALL token transfers. * May only be called by smart contract owner. */ function unfreezeTransfers () public { require (msg.sender == owner); if (frozen) { frozen = false; emit Unfreeze (); } } /*A user is able to unintentionally send tokens to a contract * and if the contract is not prepared to refund them they will get stuck in the contract. * The same issue used to happen for Ether too but new Solidity versions added the payable modifier to * prevent unintended Ether transfers. However, there’s no such mechanism for token transfers. * so the below function is created */ function refundTokens(address _token, address _refund, uint256 _value) public { require (msg.sender == owner); require(_token != address(this)); AbstractToken token = AbstractToken(_token); token.transfer(_refund, _value); emit RefundTokens(_token, _refund, _value); } /** * Freeze specific account * May only be called by smart contract owner. */ function freezeAccount(address _target, bool freeze) public { require (msg.sender == owner); require (msg.sender != _target); frozenAccount[_target] = freeze; emit FrozenFunds(_target, freeze); } /** * Logged when token transfers were frozen. */ event Freeze (); /** * Logged when token transfers were unfrozen. */ event Unfreeze (); /** * Logged when a particular account is frozen. */ event FrozenFunds(address target, bool frozen); /** * when accidentally send other tokens are refunded */ event RefundTokens(address _token, address _refund, uint256 _value); }
/** * norwegianbitcoin smart contract. */
NatSpecMultiLine
createTokens
function createTokens(uint256 _value) public returns (bool success) { require (msg.sender == owner); if (_value > 0) { if (_value > safeSub (MAX_TOKEN_COUNT, tokenCount)) return false; accounts [msg.sender] = safeAdd (accounts [msg.sender], _value); tokenCount = safeAdd (tokenCount, _value); // adding transfer event and _from address as null address emit Transfer(address(0), msg.sender, _value); return true; } return false; }
/** * Create _value new tokens and give new created tokens to msg.sender. * May only be called by smart contract owner. * * @param _value number of tokens to create * @return true if tokens were created successfully, false otherwise */
NatSpecMultiLine
v0.5.6+commit.b259423e
bzzr://b77f53fa33c3cf118b1cecfa8fab5f4d172e798a840ffc05ab84f9729fdda0d4
{ "func_code_index": [ 3492, 4010 ] }
5,168
NBTC
NBTC.sol
0xcda50305e75b01894dad90be684eb2d6f1c5b0e7
Solidity
NBTC
contract NBTC is AbstractToken { /** * Maximum allowed number of tokens in circulation. * tokenSupply = tokensIActuallyWant * (10 ^ decimals) */ uint256 constant MAX_TOKEN_COUNT = 1000000000 * (10**18); /** * Address of the owner of this smart contract. */ address public owner; /** * Frozen account list holder */ mapping (address => bool) private frozenAccount; /** * Current number of tokens in circulation. */ uint256 tokenCount = 0; /** * True if tokens transfers are currently frozen, false otherwise. */ bool frozen = false; /** * Create new token smart contract and make msg.sender the * owner of this smart contract. */ constructor () public { owner = msg.sender; } /** * Get total number of tokens in circulation. * * @return total number of tokens in circulation */ function totalSupply() public view returns (uint256 supply) { return tokenCount; } string constant public name = "norwegianbitcoin"; string constant public symbol = "NBTC"; uint8 constant public decimals = 18; /** * Transfer given number of tokens from message sender to given recipient. * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer to the owner of given address * @return true if tokens were transferred successfully, false otherwise */ function transfer(address _to, uint256 _value) public returns (bool success) { require(!frozenAccount[msg.sender]); if (frozen) return false; else return AbstractToken.transfer (_to, _value); } /** * Transfer given number of tokens from given owner to given recipient. * * @param _from address to transfer tokens from the owner of * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer from given owner to given * recipient * @return true if tokens were transferred successfully, false otherwise */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(!frozenAccount[_from]); if (frozen) return false; else return AbstractToken.transferFrom (_from, _to, _value); } /** * Change how many tokens given spender is allowed to transfer from message * spender. In order to prevent double spending of allowance, * To change the approve amount you first have to reduce the addresses` * allowance to zero by calling `approve(_spender, 0)` if it is not * already 0 to mitigate the race condition described here: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender address to allow the owner of to transfer tokens from * message sender * @param _value number of tokens to allow to transfer * @return true if token transfer was successfully approved, false otherwise */ function approve (address _spender, uint256 _value) public returns (bool success) { require(allowance (msg.sender, _spender) == 0 || _value == 0); return AbstractToken.approve (_spender, _value); } /** * Create _value new tokens and give new created tokens to msg.sender. * May only be called by smart contract owner. * * @param _value number of tokens to create * @return true if tokens were created successfully, false otherwise */ function createTokens(uint256 _value) public returns (bool success) { require (msg.sender == owner); if (_value > 0) { if (_value > safeSub (MAX_TOKEN_COUNT, tokenCount)) return false; accounts [msg.sender] = safeAdd (accounts [msg.sender], _value); tokenCount = safeAdd (tokenCount, _value); // adding transfer event and _from address as null address emit Transfer(address(0), msg.sender, _value); return true; } return false; } /** * Set new owner for the smart contract. * May only be called by smart contract owner. * * @param _newOwner address of new owner of the smart contract */ function setOwner(address _newOwner) public { require (msg.sender == owner); owner = _newOwner; } /** * Freeze ALL token transfers. * May only be called by smart contract owner. */ function freezeTransfers () public { require (msg.sender == owner); if (!frozen) { frozen = true; emit Freeze (); } } /** * Unfreeze ALL token transfers. * May only be called by smart contract owner. */ function unfreezeTransfers () public { require (msg.sender == owner); if (frozen) { frozen = false; emit Unfreeze (); } } /*A user is able to unintentionally send tokens to a contract * and if the contract is not prepared to refund them they will get stuck in the contract. * The same issue used to happen for Ether too but new Solidity versions added the payable modifier to * prevent unintended Ether transfers. However, there’s no such mechanism for token transfers. * so the below function is created */ function refundTokens(address _token, address _refund, uint256 _value) public { require (msg.sender == owner); require(_token != address(this)); AbstractToken token = AbstractToken(_token); token.transfer(_refund, _value); emit RefundTokens(_token, _refund, _value); } /** * Freeze specific account * May only be called by smart contract owner. */ function freezeAccount(address _target, bool freeze) public { require (msg.sender == owner); require (msg.sender != _target); frozenAccount[_target] = freeze; emit FrozenFunds(_target, freeze); } /** * Logged when token transfers were frozen. */ event Freeze (); /** * Logged when token transfers were unfrozen. */ event Unfreeze (); /** * Logged when a particular account is frozen. */ event FrozenFunds(address target, bool frozen); /** * when accidentally send other tokens are refunded */ event RefundTokens(address _token, address _refund, uint256 _value); }
/** * norwegianbitcoin smart contract. */
NatSpecMultiLine
setOwner
function setOwner(address _newOwner) public { require (msg.sender == owner); owner = _newOwner; }
/** * Set new owner for the smart contract. * May only be called by smart contract owner. * * @param _newOwner address of new owner of the smart contract */
NatSpecMultiLine
v0.5.6+commit.b259423e
bzzr://b77f53fa33c3cf118b1cecfa8fab5f4d172e798a840ffc05ab84f9729fdda0d4
{ "func_code_index": [ 4197, 4312 ] }
5,169
NBTC
NBTC.sol
0xcda50305e75b01894dad90be684eb2d6f1c5b0e7
Solidity
NBTC
contract NBTC is AbstractToken { /** * Maximum allowed number of tokens in circulation. * tokenSupply = tokensIActuallyWant * (10 ^ decimals) */ uint256 constant MAX_TOKEN_COUNT = 1000000000 * (10**18); /** * Address of the owner of this smart contract. */ address public owner; /** * Frozen account list holder */ mapping (address => bool) private frozenAccount; /** * Current number of tokens in circulation. */ uint256 tokenCount = 0; /** * True if tokens transfers are currently frozen, false otherwise. */ bool frozen = false; /** * Create new token smart contract and make msg.sender the * owner of this smart contract. */ constructor () public { owner = msg.sender; } /** * Get total number of tokens in circulation. * * @return total number of tokens in circulation */ function totalSupply() public view returns (uint256 supply) { return tokenCount; } string constant public name = "norwegianbitcoin"; string constant public symbol = "NBTC"; uint8 constant public decimals = 18; /** * Transfer given number of tokens from message sender to given recipient. * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer to the owner of given address * @return true if tokens were transferred successfully, false otherwise */ function transfer(address _to, uint256 _value) public returns (bool success) { require(!frozenAccount[msg.sender]); if (frozen) return false; else return AbstractToken.transfer (_to, _value); } /** * Transfer given number of tokens from given owner to given recipient. * * @param _from address to transfer tokens from the owner of * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer from given owner to given * recipient * @return true if tokens were transferred successfully, false otherwise */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(!frozenAccount[_from]); if (frozen) return false; else return AbstractToken.transferFrom (_from, _to, _value); } /** * Change how many tokens given spender is allowed to transfer from message * spender. In order to prevent double spending of allowance, * To change the approve amount you first have to reduce the addresses` * allowance to zero by calling `approve(_spender, 0)` if it is not * already 0 to mitigate the race condition described here: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender address to allow the owner of to transfer tokens from * message sender * @param _value number of tokens to allow to transfer * @return true if token transfer was successfully approved, false otherwise */ function approve (address _spender, uint256 _value) public returns (bool success) { require(allowance (msg.sender, _spender) == 0 || _value == 0); return AbstractToken.approve (_spender, _value); } /** * Create _value new tokens and give new created tokens to msg.sender. * May only be called by smart contract owner. * * @param _value number of tokens to create * @return true if tokens were created successfully, false otherwise */ function createTokens(uint256 _value) public returns (bool success) { require (msg.sender == owner); if (_value > 0) { if (_value > safeSub (MAX_TOKEN_COUNT, tokenCount)) return false; accounts [msg.sender] = safeAdd (accounts [msg.sender], _value); tokenCount = safeAdd (tokenCount, _value); // adding transfer event and _from address as null address emit Transfer(address(0), msg.sender, _value); return true; } return false; } /** * Set new owner for the smart contract. * May only be called by smart contract owner. * * @param _newOwner address of new owner of the smart contract */ function setOwner(address _newOwner) public { require (msg.sender == owner); owner = _newOwner; } /** * Freeze ALL token transfers. * May only be called by smart contract owner. */ function freezeTransfers () public { require (msg.sender == owner); if (!frozen) { frozen = true; emit Freeze (); } } /** * Unfreeze ALL token transfers. * May only be called by smart contract owner. */ function unfreezeTransfers () public { require (msg.sender == owner); if (frozen) { frozen = false; emit Unfreeze (); } } /*A user is able to unintentionally send tokens to a contract * and if the contract is not prepared to refund them they will get stuck in the contract. * The same issue used to happen for Ether too but new Solidity versions added the payable modifier to * prevent unintended Ether transfers. However, there’s no such mechanism for token transfers. * so the below function is created */ function refundTokens(address _token, address _refund, uint256 _value) public { require (msg.sender == owner); require(_token != address(this)); AbstractToken token = AbstractToken(_token); token.transfer(_refund, _value); emit RefundTokens(_token, _refund, _value); } /** * Freeze specific account * May only be called by smart contract owner. */ function freezeAccount(address _target, bool freeze) public { require (msg.sender == owner); require (msg.sender != _target); frozenAccount[_target] = freeze; emit FrozenFunds(_target, freeze); } /** * Logged when token transfers were frozen. */ event Freeze (); /** * Logged when token transfers were unfrozen. */ event Unfreeze (); /** * Logged when a particular account is frozen. */ event FrozenFunds(address target, bool frozen); /** * when accidentally send other tokens are refunded */ event RefundTokens(address _token, address _refund, uint256 _value); }
/** * norwegianbitcoin smart contract. */
NatSpecMultiLine
freezeTransfers
function freezeTransfers () public { require (msg.sender == owner); if (!frozen) { frozen = true; emit Freeze (); } }
/** * Freeze ALL token transfers. * May only be called by smart contract owner. */
NatSpecMultiLine
v0.5.6+commit.b259423e
bzzr://b77f53fa33c3cf118b1cecfa8fab5f4d172e798a840ffc05ab84f9729fdda0d4
{ "func_code_index": [ 4413, 4567 ] }
5,170
NBTC
NBTC.sol
0xcda50305e75b01894dad90be684eb2d6f1c5b0e7
Solidity
NBTC
contract NBTC is AbstractToken { /** * Maximum allowed number of tokens in circulation. * tokenSupply = tokensIActuallyWant * (10 ^ decimals) */ uint256 constant MAX_TOKEN_COUNT = 1000000000 * (10**18); /** * Address of the owner of this smart contract. */ address public owner; /** * Frozen account list holder */ mapping (address => bool) private frozenAccount; /** * Current number of tokens in circulation. */ uint256 tokenCount = 0; /** * True if tokens transfers are currently frozen, false otherwise. */ bool frozen = false; /** * Create new token smart contract and make msg.sender the * owner of this smart contract. */ constructor () public { owner = msg.sender; } /** * Get total number of tokens in circulation. * * @return total number of tokens in circulation */ function totalSupply() public view returns (uint256 supply) { return tokenCount; } string constant public name = "norwegianbitcoin"; string constant public symbol = "NBTC"; uint8 constant public decimals = 18; /** * Transfer given number of tokens from message sender to given recipient. * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer to the owner of given address * @return true if tokens were transferred successfully, false otherwise */ function transfer(address _to, uint256 _value) public returns (bool success) { require(!frozenAccount[msg.sender]); if (frozen) return false; else return AbstractToken.transfer (_to, _value); } /** * Transfer given number of tokens from given owner to given recipient. * * @param _from address to transfer tokens from the owner of * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer from given owner to given * recipient * @return true if tokens were transferred successfully, false otherwise */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(!frozenAccount[_from]); if (frozen) return false; else return AbstractToken.transferFrom (_from, _to, _value); } /** * Change how many tokens given spender is allowed to transfer from message * spender. In order to prevent double spending of allowance, * To change the approve amount you first have to reduce the addresses` * allowance to zero by calling `approve(_spender, 0)` if it is not * already 0 to mitigate the race condition described here: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender address to allow the owner of to transfer tokens from * message sender * @param _value number of tokens to allow to transfer * @return true if token transfer was successfully approved, false otherwise */ function approve (address _spender, uint256 _value) public returns (bool success) { require(allowance (msg.sender, _spender) == 0 || _value == 0); return AbstractToken.approve (_spender, _value); } /** * Create _value new tokens and give new created tokens to msg.sender. * May only be called by smart contract owner. * * @param _value number of tokens to create * @return true if tokens were created successfully, false otherwise */ function createTokens(uint256 _value) public returns (bool success) { require (msg.sender == owner); if (_value > 0) { if (_value > safeSub (MAX_TOKEN_COUNT, tokenCount)) return false; accounts [msg.sender] = safeAdd (accounts [msg.sender], _value); tokenCount = safeAdd (tokenCount, _value); // adding transfer event and _from address as null address emit Transfer(address(0), msg.sender, _value); return true; } return false; } /** * Set new owner for the smart contract. * May only be called by smart contract owner. * * @param _newOwner address of new owner of the smart contract */ function setOwner(address _newOwner) public { require (msg.sender == owner); owner = _newOwner; } /** * Freeze ALL token transfers. * May only be called by smart contract owner. */ function freezeTransfers () public { require (msg.sender == owner); if (!frozen) { frozen = true; emit Freeze (); } } /** * Unfreeze ALL token transfers. * May only be called by smart contract owner. */ function unfreezeTransfers () public { require (msg.sender == owner); if (frozen) { frozen = false; emit Unfreeze (); } } /*A user is able to unintentionally send tokens to a contract * and if the contract is not prepared to refund them they will get stuck in the contract. * The same issue used to happen for Ether too but new Solidity versions added the payable modifier to * prevent unintended Ether transfers. However, there’s no such mechanism for token transfers. * so the below function is created */ function refundTokens(address _token, address _refund, uint256 _value) public { require (msg.sender == owner); require(_token != address(this)); AbstractToken token = AbstractToken(_token); token.transfer(_refund, _value); emit RefundTokens(_token, _refund, _value); } /** * Freeze specific account * May only be called by smart contract owner. */ function freezeAccount(address _target, bool freeze) public { require (msg.sender == owner); require (msg.sender != _target); frozenAccount[_target] = freeze; emit FrozenFunds(_target, freeze); } /** * Logged when token transfers were frozen. */ event Freeze (); /** * Logged when token transfers were unfrozen. */ event Unfreeze (); /** * Logged when a particular account is frozen. */ event FrozenFunds(address target, bool frozen); /** * when accidentally send other tokens are refunded */ event RefundTokens(address _token, address _refund, uint256 _value); }
/** * norwegianbitcoin smart contract. */
NatSpecMultiLine
unfreezeTransfers
function unfreezeTransfers () public { require (msg.sender == owner); if (frozen) { frozen = false; emit Unfreeze (); } }
/** * Unfreeze ALL token transfers. * May only be called by smart contract owner. */
NatSpecMultiLine
v0.5.6+commit.b259423e
bzzr://b77f53fa33c3cf118b1cecfa8fab5f4d172e798a840ffc05ab84f9729fdda0d4
{ "func_code_index": [ 4670, 4828 ] }
5,171
NBTC
NBTC.sol
0xcda50305e75b01894dad90be684eb2d6f1c5b0e7
Solidity
NBTC
contract NBTC is AbstractToken { /** * Maximum allowed number of tokens in circulation. * tokenSupply = tokensIActuallyWant * (10 ^ decimals) */ uint256 constant MAX_TOKEN_COUNT = 1000000000 * (10**18); /** * Address of the owner of this smart contract. */ address public owner; /** * Frozen account list holder */ mapping (address => bool) private frozenAccount; /** * Current number of tokens in circulation. */ uint256 tokenCount = 0; /** * True if tokens transfers are currently frozen, false otherwise. */ bool frozen = false; /** * Create new token smart contract and make msg.sender the * owner of this smart contract. */ constructor () public { owner = msg.sender; } /** * Get total number of tokens in circulation. * * @return total number of tokens in circulation */ function totalSupply() public view returns (uint256 supply) { return tokenCount; } string constant public name = "norwegianbitcoin"; string constant public symbol = "NBTC"; uint8 constant public decimals = 18; /** * Transfer given number of tokens from message sender to given recipient. * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer to the owner of given address * @return true if tokens were transferred successfully, false otherwise */ function transfer(address _to, uint256 _value) public returns (bool success) { require(!frozenAccount[msg.sender]); if (frozen) return false; else return AbstractToken.transfer (_to, _value); } /** * Transfer given number of tokens from given owner to given recipient. * * @param _from address to transfer tokens from the owner of * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer from given owner to given * recipient * @return true if tokens were transferred successfully, false otherwise */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(!frozenAccount[_from]); if (frozen) return false; else return AbstractToken.transferFrom (_from, _to, _value); } /** * Change how many tokens given spender is allowed to transfer from message * spender. In order to prevent double spending of allowance, * To change the approve amount you first have to reduce the addresses` * allowance to zero by calling `approve(_spender, 0)` if it is not * already 0 to mitigate the race condition described here: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender address to allow the owner of to transfer tokens from * message sender * @param _value number of tokens to allow to transfer * @return true if token transfer was successfully approved, false otherwise */ function approve (address _spender, uint256 _value) public returns (bool success) { require(allowance (msg.sender, _spender) == 0 || _value == 0); return AbstractToken.approve (_spender, _value); } /** * Create _value new tokens and give new created tokens to msg.sender. * May only be called by smart contract owner. * * @param _value number of tokens to create * @return true if tokens were created successfully, false otherwise */ function createTokens(uint256 _value) public returns (bool success) { require (msg.sender == owner); if (_value > 0) { if (_value > safeSub (MAX_TOKEN_COUNT, tokenCount)) return false; accounts [msg.sender] = safeAdd (accounts [msg.sender], _value); tokenCount = safeAdd (tokenCount, _value); // adding transfer event and _from address as null address emit Transfer(address(0), msg.sender, _value); return true; } return false; } /** * Set new owner for the smart contract. * May only be called by smart contract owner. * * @param _newOwner address of new owner of the smart contract */ function setOwner(address _newOwner) public { require (msg.sender == owner); owner = _newOwner; } /** * Freeze ALL token transfers. * May only be called by smart contract owner. */ function freezeTransfers () public { require (msg.sender == owner); if (!frozen) { frozen = true; emit Freeze (); } } /** * Unfreeze ALL token transfers. * May only be called by smart contract owner. */ function unfreezeTransfers () public { require (msg.sender == owner); if (frozen) { frozen = false; emit Unfreeze (); } } /*A user is able to unintentionally send tokens to a contract * and if the contract is not prepared to refund them they will get stuck in the contract. * The same issue used to happen for Ether too but new Solidity versions added the payable modifier to * prevent unintended Ether transfers. However, there’s no such mechanism for token transfers. * so the below function is created */ function refundTokens(address _token, address _refund, uint256 _value) public { require (msg.sender == owner); require(_token != address(this)); AbstractToken token = AbstractToken(_token); token.transfer(_refund, _value); emit RefundTokens(_token, _refund, _value); } /** * Freeze specific account * May only be called by smart contract owner. */ function freezeAccount(address _target, bool freeze) public { require (msg.sender == owner); require (msg.sender != _target); frozenAccount[_target] = freeze; emit FrozenFunds(_target, freeze); } /** * Logged when token transfers were frozen. */ event Freeze (); /** * Logged when token transfers were unfrozen. */ event Unfreeze (); /** * Logged when a particular account is frozen. */ event FrozenFunds(address target, bool frozen); /** * when accidentally send other tokens are refunded */ event RefundTokens(address _token, address _refund, uint256 _value); }
/** * norwegianbitcoin smart contract. */
NatSpecMultiLine
refundTokens
function refundTokens(address _token, address _refund, uint256 _value) public { require (msg.sender == owner); require(_token != address(this)); AbstractToken token = AbstractToken(_token); token.transfer(_refund, _value); emit RefundTokens(_token, _refund, _value); }
/*A user is able to unintentionally send tokens to a contract * and if the contract is not prepared to refund them they will get stuck in the contract. * The same issue used to happen for Ether too but new Solidity versions added the payable modifier to * prevent unintended Ether transfers. However, there’s no such mechanism for token transfers. * so the below function is created */
Comment
v0.5.6+commit.b259423e
bzzr://b77f53fa33c3cf118b1cecfa8fab5f4d172e798a840ffc05ab84f9729fdda0d4
{ "func_code_index": [ 5247, 5546 ] }
5,172
NBTC
NBTC.sol
0xcda50305e75b01894dad90be684eb2d6f1c5b0e7
Solidity
NBTC
contract NBTC is AbstractToken { /** * Maximum allowed number of tokens in circulation. * tokenSupply = tokensIActuallyWant * (10 ^ decimals) */ uint256 constant MAX_TOKEN_COUNT = 1000000000 * (10**18); /** * Address of the owner of this smart contract. */ address public owner; /** * Frozen account list holder */ mapping (address => bool) private frozenAccount; /** * Current number of tokens in circulation. */ uint256 tokenCount = 0; /** * True if tokens transfers are currently frozen, false otherwise. */ bool frozen = false; /** * Create new token smart contract and make msg.sender the * owner of this smart contract. */ constructor () public { owner = msg.sender; } /** * Get total number of tokens in circulation. * * @return total number of tokens in circulation */ function totalSupply() public view returns (uint256 supply) { return tokenCount; } string constant public name = "norwegianbitcoin"; string constant public symbol = "NBTC"; uint8 constant public decimals = 18; /** * Transfer given number of tokens from message sender to given recipient. * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer to the owner of given address * @return true if tokens were transferred successfully, false otherwise */ function transfer(address _to, uint256 _value) public returns (bool success) { require(!frozenAccount[msg.sender]); if (frozen) return false; else return AbstractToken.transfer (_to, _value); } /** * Transfer given number of tokens from given owner to given recipient. * * @param _from address to transfer tokens from the owner of * @param _to address to transfer tokens to the owner of * @param _value number of tokens to transfer from given owner to given * recipient * @return true if tokens were transferred successfully, false otherwise */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(!frozenAccount[_from]); if (frozen) return false; else return AbstractToken.transferFrom (_from, _to, _value); } /** * Change how many tokens given spender is allowed to transfer from message * spender. In order to prevent double spending of allowance, * To change the approve amount you first have to reduce the addresses` * allowance to zero by calling `approve(_spender, 0)` if it is not * already 0 to mitigate the race condition described here: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender address to allow the owner of to transfer tokens from * message sender * @param _value number of tokens to allow to transfer * @return true if token transfer was successfully approved, false otherwise */ function approve (address _spender, uint256 _value) public returns (bool success) { require(allowance (msg.sender, _spender) == 0 || _value == 0); return AbstractToken.approve (_spender, _value); } /** * Create _value new tokens and give new created tokens to msg.sender. * May only be called by smart contract owner. * * @param _value number of tokens to create * @return true if tokens were created successfully, false otherwise */ function createTokens(uint256 _value) public returns (bool success) { require (msg.sender == owner); if (_value > 0) { if (_value > safeSub (MAX_TOKEN_COUNT, tokenCount)) return false; accounts [msg.sender] = safeAdd (accounts [msg.sender], _value); tokenCount = safeAdd (tokenCount, _value); // adding transfer event and _from address as null address emit Transfer(address(0), msg.sender, _value); return true; } return false; } /** * Set new owner for the smart contract. * May only be called by smart contract owner. * * @param _newOwner address of new owner of the smart contract */ function setOwner(address _newOwner) public { require (msg.sender == owner); owner = _newOwner; } /** * Freeze ALL token transfers. * May only be called by smart contract owner. */ function freezeTransfers () public { require (msg.sender == owner); if (!frozen) { frozen = true; emit Freeze (); } } /** * Unfreeze ALL token transfers. * May only be called by smart contract owner. */ function unfreezeTransfers () public { require (msg.sender == owner); if (frozen) { frozen = false; emit Unfreeze (); } } /*A user is able to unintentionally send tokens to a contract * and if the contract is not prepared to refund them they will get stuck in the contract. * The same issue used to happen for Ether too but new Solidity versions added the payable modifier to * prevent unintended Ether transfers. However, there’s no such mechanism for token transfers. * so the below function is created */ function refundTokens(address _token, address _refund, uint256 _value) public { require (msg.sender == owner); require(_token != address(this)); AbstractToken token = AbstractToken(_token); token.transfer(_refund, _value); emit RefundTokens(_token, _refund, _value); } /** * Freeze specific account * May only be called by smart contract owner. */ function freezeAccount(address _target, bool freeze) public { require (msg.sender == owner); require (msg.sender != _target); frozenAccount[_target] = freeze; emit FrozenFunds(_target, freeze); } /** * Logged when token transfers were frozen. */ event Freeze (); /** * Logged when token transfers were unfrozen. */ event Unfreeze (); /** * Logged when a particular account is frozen. */ event FrozenFunds(address target, bool frozen); /** * when accidentally send other tokens are refunded */ event RefundTokens(address _token, address _refund, uint256 _value); }
/** * norwegianbitcoin smart contract. */
NatSpecMultiLine
freezeAccount
function freezeAccount(address _target, bool freeze) public { require (msg.sender == owner); require (msg.sender != _target); frozenAccount[_target] = freeze; emit FrozenFunds(_target, freeze);
/** * Freeze specific account * May only be called by smart contract owner. */
NatSpecMultiLine
v0.5.6+commit.b259423e
bzzr://b77f53fa33c3cf118b1cecfa8fab5f4d172e798a840ffc05ab84f9729fdda0d4
{ "func_code_index": [ 5645, 5870 ] }
5,173
TALE
TALE.sol
0xfb6ccec5fe8567f5244549c20afa06f0f43c4c02
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 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 c; } /** * @dev Substracts 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) { uint256 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) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; }
/** * @dev Multiplies two numbers, throws on overflow. */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
None
bzzr://66d640d833dac8f251a083939842fe8bb4aff484d148983840537f0bd6ab8a64
{ "func_code_index": [ 89, 272 ] }
5,174
TALE
TALE.sol
0xfb6ccec5fe8567f5244549c20afa06f0f43c4c02
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 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 c; } /** * @dev Substracts 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) { uint256 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 c; }
/** * @dev Integer division of two numbers, truncating the quotient. */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
None
bzzr://66d640d833dac8f251a083939842fe8bb4aff484d148983840537f0bd6ab8a64
{ "func_code_index": [ 356, 629 ] }
5,175
TALE
TALE.sol
0xfb6ccec5fe8567f5244549c20afa06f0f43c4c02
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 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 c; } /** * @dev Substracts 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) { uint256 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 Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
None
bzzr://66d640d833dac8f251a083939842fe8bb4aff484d148983840537f0bd6ab8a64
{ "func_code_index": [ 744, 860 ] }
5,176
TALE
TALE.sol
0xfb6ccec5fe8567f5244549c20afa06f0f43c4c02
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 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 c; } /** * @dev Substracts 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) { uint256 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) { uint256 c = a + b; assert(c >= a); return c; }
/** * @dev Adds two numbers, throws on overflow. */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
None
bzzr://66d640d833dac8f251a083939842fe8bb4aff484d148983840537f0bd6ab8a64
{ "func_code_index": [ 924, 1060 ] }
5,177
TALE
TALE.sol
0xfb6ccec5fe8567f5244549c20afa06f0f43c4c02
Solidity
Ownable
contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } }
/** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */
NatSpecMultiLine
Ownable
function Ownable() public { owner = msg.sender; }
/** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
None
bzzr://66d640d833dac8f251a083939842fe8bb4aff484d148983840537f0bd6ab8a64
{ "func_code_index": [ 261, 321 ] }
5,178
TALE
TALE.sol
0xfb6ccec5fe8567f5244549c20afa06f0f43c4c02
Solidity
Ownable
contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } }
/** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */
NatSpecMultiLine
transferOwnership
function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; }
/** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
None
bzzr://66d640d833dac8f251a083939842fe8bb4aff484d148983840537f0bd6ab8a64
{ "func_code_index": [ 640, 816 ] }
5,179
TALE
TALE.sol
0xfb6ccec5fe8567f5244549c20afa06f0f43c4c02
Solidity
BasicToken
contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } }
/** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */
NatSpecMultiLine
totalSupply
function totalSupply() public view returns (uint256) { return totalSupply_; }
/** * @dev total number of tokens in existence */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
None
bzzr://66d640d833dac8f251a083939842fe8bb4aff484d148983840537f0bd6ab8a64
{ "func_code_index": [ 199, 287 ] }
5,180
TALE
TALE.sol
0xfb6ccec5fe8567f5244549c20afa06f0f43c4c02
Solidity
BasicToken
contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } }
/** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */
NatSpecMultiLine
transfer
function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; }
/** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
None
bzzr://66d640d833dac8f251a083939842fe8bb4aff484d148983840537f0bd6ab8a64
{ "func_code_index": [ 445, 836 ] }
5,181
TALE
TALE.sol
0xfb6ccec5fe8567f5244549c20afa06f0f43c4c02
Solidity
BasicToken
contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } }
/** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */
NatSpecMultiLine
balanceOf
function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; }
/** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
None
bzzr://66d640d833dac8f251a083939842fe8bb4aff484d148983840537f0bd6ab8a64
{ "func_code_index": [ 1042, 1154 ] }
5,182
TALE
TALE.sol
0xfb6ccec5fe8567f5244549c20afa06f0f43c4c02
Solidity
StandardToken
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
/** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */
NatSpecMultiLine
transferFrom
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; }
/** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
None
bzzr://66d640d833dac8f251a083939842fe8bb4aff484d148983840537f0bd6ab8a64
{ "func_code_index": [ 401, 853 ] }
5,183
TALE
TALE.sol
0xfb6ccec5fe8567f5244549c20afa06f0f43c4c02
Solidity
StandardToken
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
/** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */
NatSpecMultiLine
approve
function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; }
/** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
None
bzzr://66d640d833dac8f251a083939842fe8bb4aff484d148983840537f0bd6ab8a64
{ "func_code_index": [ 1485, 1675 ] }
5,184
TALE
TALE.sol
0xfb6ccec5fe8567f5244549c20afa06f0f43c4c02
Solidity
StandardToken
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
/** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */
NatSpecMultiLine
allowance
function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; }
/** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
None
bzzr://66d640d833dac8f251a083939842fe8bb4aff484d148983840537f0bd6ab8a64
{ "func_code_index": [ 1999, 2130 ] }
5,185
TALE
TALE.sol
0xfb6ccec5fe8567f5244549c20afa06f0f43c4c02
Solidity
StandardToken
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
/** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */
NatSpecMultiLine
increaseApproval
function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; }
/** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
None
bzzr://66d640d833dac8f251a083939842fe8bb4aff484d148983840537f0bd6ab8a64
{ "func_code_index": [ 2596, 2860 ] }
5,186
TALE
TALE.sol
0xfb6ccec5fe8567f5244549c20afa06f0f43c4c02
Solidity
StandardToken
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
/** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */
NatSpecMultiLine
decreaseApproval
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; }
/** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
None
bzzr://66d640d833dac8f251a083939842fe8bb4aff484d148983840537f0bd6ab8a64
{ "func_code_index": [ 3331, 3741 ] }
5,187
TALE
TALE.sol
0xfb6ccec5fe8567f5244549c20afa06f0f43c4c02
Solidity
MintableToken
contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); Transfer(address(0), _to, _amount); return true; } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; MintFinished(); return true; } }
/** * @title Mintable token * @dev Simple ERC20 Token example, with mintable token creation * @dev Issue: * https://github.com/OpenZeppelin/zeppelin-solidity/issues/120 * Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol */
NatSpecMultiLine
mint
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); Transfer(address(0), _to, _amount); return true; }
/** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
None
bzzr://66d640d833dac8f251a083939842fe8bb4aff484d148983840537f0bd6ab8a64
{ "func_code_index": [ 483, 756 ] }
5,188
TALE
TALE.sol
0xfb6ccec5fe8567f5244549c20afa06f0f43c4c02
Solidity
MintableToken
contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); Transfer(address(0), _to, _amount); return true; } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; MintFinished(); return true; } }
/** * @title Mintable token * @dev Simple ERC20 Token example, with mintable token creation * @dev Issue: * https://github.com/OpenZeppelin/zeppelin-solidity/issues/120 * Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol */
NatSpecMultiLine
finishMinting
function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; MintFinished(); return true; }
/** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
None
bzzr://66d640d833dac8f251a083939842fe8bb4aff484d148983840537f0bd6ab8a64
{ "func_code_index": [ 873, 1015 ] }
5,189
PoaManager
contracts/PoaProxy.sol
0x9b97d864543f0e755228b27a552ed145f3d1e964
Solidity
PoaProxy
contract PoaProxy is PoaProxyCommon { uint8 public constant version = 1; event ProxyUpgraded(address upgradedFrom, address upgradedTo); /** @notice Stores addresses of our contract registry as well as the PoaToken and PoaCrowdsale master contracts to forward calls to. */ constructor( address _poaTokenMaster, address _poaCrowdsaleMaster, address _registry ) public { // Ensure that none of the given addresses are empty require(_poaTokenMaster != address(0)); require(_poaCrowdsaleMaster != address(0)); require(_registry != address(0)); // Set addresses in common storage using deterministic storage slots poaTokenMaster = _poaTokenMaster; poaCrowdsaleMaster = _poaCrowdsaleMaster; registry = _registry; } /***************************** * Start Proxy State Helpers * *****************************/ /** @notice Ensures that a given address is a contract by making sure it has code. Used during upgrading to make sure the new addresses to upgrade to are smart contracts. */ function isContract(address _address) private view returns (bool) { uint256 _size; assembly { _size := extcodesize(_address) } return _size > 0; } /*************************** * End Proxy State Helpers * ***************************/ /***************************** * Start Proxy State Setters * *****************************/ /// @notice Update the stored "poaTokenMaster" address to upgrade the PoaToken master contract function proxyChangeTokenMaster(address _newMaster) public returns (bool) { require(msg.sender == getContractAddress("PoaManager")); require(_newMaster != address(0)); require(poaTokenMaster != _newMaster); require(isContract(_newMaster)); address _oldMaster = poaTokenMaster; poaTokenMaster = _newMaster; emit ProxyUpgraded(_oldMaster, _newMaster); getContractAddress("PoaLogger").call( abi.encodeWithSignature( "logProxyUpgraded(address,address)", _oldMaster, _newMaster ) ); return true; } /// @notice Update the stored `poaCrowdsaleMaster` address to upgrade the PoaCrowdsale master contract function proxyChangeCrowdsaleMaster(address _newMaster) public returns (bool) { require(msg.sender == getContractAddress("PoaManager")); require(_newMaster != address(0)); require(poaCrowdsaleMaster != _newMaster); require(isContract(_newMaster)); address _oldMaster = poaCrowdsaleMaster; poaCrowdsaleMaster = _newMaster; emit ProxyUpgraded(_oldMaster, _newMaster); getContractAddress("PoaLogger").call( abi.encodeWithSignature( "logProxyUpgraded(address,address)", _oldMaster, _newMaster ) ); return true; } /*************************** * End Proxy State Setters * ***************************/ /** @notice Fallback function for all proxied functions using "delegatecall()". It will first forward all functions to the "poaTokenMaster" address. If the called function isn't found there, then "poaTokenMaster"'s fallback function will forward the call to "poaCrowdsale". If the called function also isn't found there, it will fail at last. */ function() external payable { assembly { // Load PoaToken master address from first storage pointer let _poaTokenMaster := sload(poaTokenMaster_slot) // calldatacopy(t, f, s) calldatacopy( 0x0, // t = mem position to 0x0, // f = mem position from calldatasize // s = size bytes ) // delegatecall(g, a, in, insize, out, outsize) => returns "0" on error, or "1" on success let result := delegatecall( gas, // g = gas _poaTokenMaster, // a = address 0x0, // in = mem in mem[in..(in+insize) calldatasize, // insize = mem insize mem[in..(in+insize) 0x0, // out = mem out mem[out..(out+outsize) 0 // outsize = mem outsize mem[out..(out+outsize) ) // Check if the call was successful if iszero(result) { // Revert if call failed revert(0, 0) } // returndatacopy(t, f, s) returndatacopy( 0x0, // t = mem position to 0x0, // f = mem position from returndatasize // s = size bytes ) // Return if call succeeded return( 0x0, returndatasize ) } } }
/** @title This contract manages the storage of: - PoaProxy - PoaToken - PoaCrowdsale @notice PoaProxy uses chained "delegatecall()"s to call functions on PoaToken and PoaCrowdsale and sets the resulting storage here on PoaProxy. @dev `getContractAddress("PoaLogger").call()` does not use the return value because we would rather contract functions to continue even if the event did not successfully trigger on the logger contract. */
NatSpecMultiLine
isContract
function isContract(address _address) private view returns (bool) { uint256 _size; assembly { _size := extcodesize(_address) } return _size > 0; }
/** @notice Ensures that a given address is a contract by making sure it has code. Used during upgrading to make sure the new addresses to upgrade to are smart contracts. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://68fb153aab6ea446eb7f0a299aec399928ed8d899dc798bc3cd6c9d99c5193e3
{ "func_code_index": [ 1117, 1304 ] }
5,190
PoaManager
contracts/PoaProxy.sol
0x9b97d864543f0e755228b27a552ed145f3d1e964
Solidity
PoaProxy
contract PoaProxy is PoaProxyCommon { uint8 public constant version = 1; event ProxyUpgraded(address upgradedFrom, address upgradedTo); /** @notice Stores addresses of our contract registry as well as the PoaToken and PoaCrowdsale master contracts to forward calls to. */ constructor( address _poaTokenMaster, address _poaCrowdsaleMaster, address _registry ) public { // Ensure that none of the given addresses are empty require(_poaTokenMaster != address(0)); require(_poaCrowdsaleMaster != address(0)); require(_registry != address(0)); // Set addresses in common storage using deterministic storage slots poaTokenMaster = _poaTokenMaster; poaCrowdsaleMaster = _poaCrowdsaleMaster; registry = _registry; } /***************************** * Start Proxy State Helpers * *****************************/ /** @notice Ensures that a given address is a contract by making sure it has code. Used during upgrading to make sure the new addresses to upgrade to are smart contracts. */ function isContract(address _address) private view returns (bool) { uint256 _size; assembly { _size := extcodesize(_address) } return _size > 0; } /*************************** * End Proxy State Helpers * ***************************/ /***************************** * Start Proxy State Setters * *****************************/ /// @notice Update the stored "poaTokenMaster" address to upgrade the PoaToken master contract function proxyChangeTokenMaster(address _newMaster) public returns (bool) { require(msg.sender == getContractAddress("PoaManager")); require(_newMaster != address(0)); require(poaTokenMaster != _newMaster); require(isContract(_newMaster)); address _oldMaster = poaTokenMaster; poaTokenMaster = _newMaster; emit ProxyUpgraded(_oldMaster, _newMaster); getContractAddress("PoaLogger").call( abi.encodeWithSignature( "logProxyUpgraded(address,address)", _oldMaster, _newMaster ) ); return true; } /// @notice Update the stored `poaCrowdsaleMaster` address to upgrade the PoaCrowdsale master contract function proxyChangeCrowdsaleMaster(address _newMaster) public returns (bool) { require(msg.sender == getContractAddress("PoaManager")); require(_newMaster != address(0)); require(poaCrowdsaleMaster != _newMaster); require(isContract(_newMaster)); address _oldMaster = poaCrowdsaleMaster; poaCrowdsaleMaster = _newMaster; emit ProxyUpgraded(_oldMaster, _newMaster); getContractAddress("PoaLogger").call( abi.encodeWithSignature( "logProxyUpgraded(address,address)", _oldMaster, _newMaster ) ); return true; } /*************************** * End Proxy State Setters * ***************************/ /** @notice Fallback function for all proxied functions using "delegatecall()". It will first forward all functions to the "poaTokenMaster" address. If the called function isn't found there, then "poaTokenMaster"'s fallback function will forward the call to "poaCrowdsale". If the called function also isn't found there, it will fail at last. */ function() external payable { assembly { // Load PoaToken master address from first storage pointer let _poaTokenMaster := sload(poaTokenMaster_slot) // calldatacopy(t, f, s) calldatacopy( 0x0, // t = mem position to 0x0, // f = mem position from calldatasize // s = size bytes ) // delegatecall(g, a, in, insize, out, outsize) => returns "0" on error, or "1" on success let result := delegatecall( gas, // g = gas _poaTokenMaster, // a = address 0x0, // in = mem in mem[in..(in+insize) calldatasize, // insize = mem insize mem[in..(in+insize) 0x0, // out = mem out mem[out..(out+outsize) 0 // outsize = mem outsize mem[out..(out+outsize) ) // Check if the call was successful if iszero(result) { // Revert if call failed revert(0, 0) } // returndatacopy(t, f, s) returndatacopy( 0x0, // t = mem position to 0x0, // f = mem position from returndatasize // s = size bytes ) // Return if call succeeded return( 0x0, returndatasize ) } } }
/** @title This contract manages the storage of: - PoaProxy - PoaToken - PoaCrowdsale @notice PoaProxy uses chained "delegatecall()"s to call functions on PoaToken and PoaCrowdsale and sets the resulting storage here on PoaProxy. @dev `getContractAddress("PoaLogger").call()` does not use the return value because we would rather contract functions to continue even if the event did not successfully trigger on the logger contract. */
NatSpecMultiLine
proxyChangeTokenMaster
function proxyChangeTokenMaster(address _newMaster) public returns (bool) { require(msg.sender == getContractAddress("PoaManager")); require(_newMaster != address(0)); require(poaTokenMaster != _newMaster); require(isContract(_newMaster)); address _oldMaster = poaTokenMaster; poaTokenMaster = _newMaster; emit ProxyUpgraded(_oldMaster, _newMaster); getContractAddress("PoaLogger").call( abi.encodeWithSignature( "logProxyUpgraded(address,address)", _oldMaster, _newMaster ) ); return true; }
/// @notice Update the stored "poaTokenMaster" address to upgrade the PoaToken master contract
NatSpecSingleLine
v0.4.24+commit.e67f0147
bzzr://68fb153aab6ea446eb7f0a299aec399928ed8d899dc798bc3cd6c9d99c5193e3
{ "func_code_index": [ 1611, 2217 ] }
5,191
PoaManager
contracts/PoaProxy.sol
0x9b97d864543f0e755228b27a552ed145f3d1e964
Solidity
PoaProxy
contract PoaProxy is PoaProxyCommon { uint8 public constant version = 1; event ProxyUpgraded(address upgradedFrom, address upgradedTo); /** @notice Stores addresses of our contract registry as well as the PoaToken and PoaCrowdsale master contracts to forward calls to. */ constructor( address _poaTokenMaster, address _poaCrowdsaleMaster, address _registry ) public { // Ensure that none of the given addresses are empty require(_poaTokenMaster != address(0)); require(_poaCrowdsaleMaster != address(0)); require(_registry != address(0)); // Set addresses in common storage using deterministic storage slots poaTokenMaster = _poaTokenMaster; poaCrowdsaleMaster = _poaCrowdsaleMaster; registry = _registry; } /***************************** * Start Proxy State Helpers * *****************************/ /** @notice Ensures that a given address is a contract by making sure it has code. Used during upgrading to make sure the new addresses to upgrade to are smart contracts. */ function isContract(address _address) private view returns (bool) { uint256 _size; assembly { _size := extcodesize(_address) } return _size > 0; } /*************************** * End Proxy State Helpers * ***************************/ /***************************** * Start Proxy State Setters * *****************************/ /// @notice Update the stored "poaTokenMaster" address to upgrade the PoaToken master contract function proxyChangeTokenMaster(address _newMaster) public returns (bool) { require(msg.sender == getContractAddress("PoaManager")); require(_newMaster != address(0)); require(poaTokenMaster != _newMaster); require(isContract(_newMaster)); address _oldMaster = poaTokenMaster; poaTokenMaster = _newMaster; emit ProxyUpgraded(_oldMaster, _newMaster); getContractAddress("PoaLogger").call( abi.encodeWithSignature( "logProxyUpgraded(address,address)", _oldMaster, _newMaster ) ); return true; } /// @notice Update the stored `poaCrowdsaleMaster` address to upgrade the PoaCrowdsale master contract function proxyChangeCrowdsaleMaster(address _newMaster) public returns (bool) { require(msg.sender == getContractAddress("PoaManager")); require(_newMaster != address(0)); require(poaCrowdsaleMaster != _newMaster); require(isContract(_newMaster)); address _oldMaster = poaCrowdsaleMaster; poaCrowdsaleMaster = _newMaster; emit ProxyUpgraded(_oldMaster, _newMaster); getContractAddress("PoaLogger").call( abi.encodeWithSignature( "logProxyUpgraded(address,address)", _oldMaster, _newMaster ) ); return true; } /*************************** * End Proxy State Setters * ***************************/ /** @notice Fallback function for all proxied functions using "delegatecall()". It will first forward all functions to the "poaTokenMaster" address. If the called function isn't found there, then "poaTokenMaster"'s fallback function will forward the call to "poaCrowdsale". If the called function also isn't found there, it will fail at last. */ function() external payable { assembly { // Load PoaToken master address from first storage pointer let _poaTokenMaster := sload(poaTokenMaster_slot) // calldatacopy(t, f, s) calldatacopy( 0x0, // t = mem position to 0x0, // f = mem position from calldatasize // s = size bytes ) // delegatecall(g, a, in, insize, out, outsize) => returns "0" on error, or "1" on success let result := delegatecall( gas, // g = gas _poaTokenMaster, // a = address 0x0, // in = mem in mem[in..(in+insize) calldatasize, // insize = mem insize mem[in..(in+insize) 0x0, // out = mem out mem[out..(out+outsize) 0 // outsize = mem outsize mem[out..(out+outsize) ) // Check if the call was successful if iszero(result) { // Revert if call failed revert(0, 0) } // returndatacopy(t, f, s) returndatacopy( 0x0, // t = mem position to 0x0, // f = mem position from returndatasize // s = size bytes ) // Return if call succeeded return( 0x0, returndatasize ) } } }
/** @title This contract manages the storage of: - PoaProxy - PoaToken - PoaCrowdsale @notice PoaProxy uses chained "delegatecall()"s to call functions on PoaToken and PoaCrowdsale and sets the resulting storage here on PoaProxy. @dev `getContractAddress("PoaLogger").call()` does not use the return value because we would rather contract functions to continue even if the event did not successfully trigger on the logger contract. */
NatSpecMultiLine
proxyChangeCrowdsaleMaster
function proxyChangeCrowdsaleMaster(address _newMaster) public returns (bool) { require(msg.sender == getContractAddress("PoaManager")); require(_newMaster != address(0)); require(poaCrowdsaleMaster != _newMaster); require(isContract(_newMaster)); address _oldMaster = poaCrowdsaleMaster; poaCrowdsaleMaster = _newMaster; emit ProxyUpgraded(_oldMaster, _newMaster); getContractAddress("PoaLogger").call( abi.encodeWithSignature( "logProxyUpgraded(address,address)", _oldMaster, _newMaster ) ); return true; }
/// @notice Update the stored `poaCrowdsaleMaster` address to upgrade the PoaCrowdsale master contract
NatSpecSingleLine
v0.4.24+commit.e67f0147
bzzr://68fb153aab6ea446eb7f0a299aec399928ed8d899dc798bc3cd6c9d99c5193e3
{ "func_code_index": [ 2326, 2948 ] }
5,192
PoaManager
contracts/PoaProxy.sol
0x9b97d864543f0e755228b27a552ed145f3d1e964
Solidity
PoaProxy
contract PoaProxy is PoaProxyCommon { uint8 public constant version = 1; event ProxyUpgraded(address upgradedFrom, address upgradedTo); /** @notice Stores addresses of our contract registry as well as the PoaToken and PoaCrowdsale master contracts to forward calls to. */ constructor( address _poaTokenMaster, address _poaCrowdsaleMaster, address _registry ) public { // Ensure that none of the given addresses are empty require(_poaTokenMaster != address(0)); require(_poaCrowdsaleMaster != address(0)); require(_registry != address(0)); // Set addresses in common storage using deterministic storage slots poaTokenMaster = _poaTokenMaster; poaCrowdsaleMaster = _poaCrowdsaleMaster; registry = _registry; } /***************************** * Start Proxy State Helpers * *****************************/ /** @notice Ensures that a given address is a contract by making sure it has code. Used during upgrading to make sure the new addresses to upgrade to are smart contracts. */ function isContract(address _address) private view returns (bool) { uint256 _size; assembly { _size := extcodesize(_address) } return _size > 0; } /*************************** * End Proxy State Helpers * ***************************/ /***************************** * Start Proxy State Setters * *****************************/ /// @notice Update the stored "poaTokenMaster" address to upgrade the PoaToken master contract function proxyChangeTokenMaster(address _newMaster) public returns (bool) { require(msg.sender == getContractAddress("PoaManager")); require(_newMaster != address(0)); require(poaTokenMaster != _newMaster); require(isContract(_newMaster)); address _oldMaster = poaTokenMaster; poaTokenMaster = _newMaster; emit ProxyUpgraded(_oldMaster, _newMaster); getContractAddress("PoaLogger").call( abi.encodeWithSignature( "logProxyUpgraded(address,address)", _oldMaster, _newMaster ) ); return true; } /// @notice Update the stored `poaCrowdsaleMaster` address to upgrade the PoaCrowdsale master contract function proxyChangeCrowdsaleMaster(address _newMaster) public returns (bool) { require(msg.sender == getContractAddress("PoaManager")); require(_newMaster != address(0)); require(poaCrowdsaleMaster != _newMaster); require(isContract(_newMaster)); address _oldMaster = poaCrowdsaleMaster; poaCrowdsaleMaster = _newMaster; emit ProxyUpgraded(_oldMaster, _newMaster); getContractAddress("PoaLogger").call( abi.encodeWithSignature( "logProxyUpgraded(address,address)", _oldMaster, _newMaster ) ); return true; } /*************************** * End Proxy State Setters * ***************************/ /** @notice Fallback function for all proxied functions using "delegatecall()". It will first forward all functions to the "poaTokenMaster" address. If the called function isn't found there, then "poaTokenMaster"'s fallback function will forward the call to "poaCrowdsale". If the called function also isn't found there, it will fail at last. */ function() external payable { assembly { // Load PoaToken master address from first storage pointer let _poaTokenMaster := sload(poaTokenMaster_slot) // calldatacopy(t, f, s) calldatacopy( 0x0, // t = mem position to 0x0, // f = mem position from calldatasize // s = size bytes ) // delegatecall(g, a, in, insize, out, outsize) => returns "0" on error, or "1" on success let result := delegatecall( gas, // g = gas _poaTokenMaster, // a = address 0x0, // in = mem in mem[in..(in+insize) calldatasize, // insize = mem insize mem[in..(in+insize) 0x0, // out = mem out mem[out..(out+outsize) 0 // outsize = mem outsize mem[out..(out+outsize) ) // Check if the call was successful if iszero(result) { // Revert if call failed revert(0, 0) } // returndatacopy(t, f, s) returndatacopy( 0x0, // t = mem position to 0x0, // f = mem position from returndatasize // s = size bytes ) // Return if call succeeded return( 0x0, returndatasize ) } } }
/** @title This contract manages the storage of: - PoaProxy - PoaToken - PoaCrowdsale @notice PoaProxy uses chained "delegatecall()"s to call functions on PoaToken and PoaCrowdsale and sets the resulting storage here on PoaProxy. @dev `getContractAddress("PoaLogger").call()` does not use the return value because we would rather contract functions to continue even if the event did not successfully trigger on the logger contract. */
NatSpecMultiLine
function() external payable { assembly { // Load PoaToken master address from first storage pointer let _poaTokenMaster := sload(poaTokenMaster_slot) // calldatacopy(t, f, s) calldatacopy( 0x0, // t = mem position to 0x0, // f = mem position from calldatasize // s = size bytes ) // delegatecall(g, a, in, insize, out, outsize) => returns "0" on error, or "1" on success let result := delegatecall( gas, // g = gas _poaTokenMaster, // a = address 0x0, // in = mem in mem[in..(in+insize) calldatasize, // insize = mem insize mem[in..(in+insize) 0x0, // out = mem out mem[out..(out+outsize) 0 // outsize = mem outsize mem[out..(out+outsize) ) // Check if the call was successful if iszero(result) { // Revert if call failed revert(0, 0) } // returndatacopy(t, f, s) returndatacopy( 0x0, // t = mem position to 0x0, // f = mem position from returndatasize // s = size bytes ) // Return if call succeeded return( 0x0, returndatasize ) } }
/** @notice Fallback function for all proxied functions using "delegatecall()". It will first forward all functions to the "poaTokenMaster" address. If the called function isn't found there, then "poaTokenMaster"'s fallback function will forward the call to "poaCrowdsale". If the called function also isn't found there, it will fail at last. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://68fb153aab6ea446eb7f0a299aec399928ed8d899dc798bc3cd6c9d99c5193e3
{ "func_code_index": [ 3427, 4666 ] }
5,193
SalvatorMundi
@openzeppelin/contracts/access/Ownable.sol
0x0cce0c492d4a9da79c1c58e23b414504419b8590
Solidity
Ownable
abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
/** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */
NatSpecMultiLine
owner
function owner() public view virtual returns (address) { return _owner; }
/** * @dev Returns the address of the current owner. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
MIT
ipfs://cd1ce40d528c24a29964360bc75ce46ea837d3caeaf064de1f048052863ba51d
{ "func_code_index": [ 399, 491 ] }
5,194
SalvatorMundi
@openzeppelin/contracts/access/Ownable.sol
0x0cce0c492d4a9da79c1c58e23b414504419b8590
Solidity
Ownable
abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
/** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */
NatSpecMultiLine
renounceOwnership
function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); }
/** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
MIT
ipfs://cd1ce40d528c24a29964360bc75ce46ea837d3caeaf064de1f048052863ba51d
{ "func_code_index": [ 1050, 1149 ] }
5,195
SalvatorMundi
@openzeppelin/contracts/access/Ownable.sol
0x0cce0c492d4a9da79c1c58e23b414504419b8590
Solidity
Ownable
abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
/** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */
NatSpecMultiLine
transferOwnership
function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); }
/** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */
NatSpecMultiLine
v0.8.7+commit.e28d00a7
MIT
ipfs://cd1ce40d528c24a29964360bc75ce46ea837d3caeaf064de1f048052863ba51d
{ "func_code_index": [ 1299, 1496 ] }
5,196
SalvatorMundi
@openzeppelin/contracts/access/Ownable.sol
0x0cce0c492d4a9da79c1c58e23b414504419b8590
Solidity
SalvatorMundi
contract SalvatorMundi is ERC721Enumerable, Ownable { using Strings for uint256; string baseURI; string public baseExtension = ".json"; uint256 public cost = 1.5 ether; uint256 public maxSupply = 10000; uint256 public maxMintAmount = 20; bool public paused = false; bool public revealed = false; string public notRevealedUri; constructor( string memory _name, string memory _symbol, string memory _initBaseURI, string memory _initNotRevealedUri ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); setNotRevealedURI(_initNotRevealedUri); } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(uint256 _mintAmount) public payable { uint256 supply = totalSupply(); require(!paused); require(_mintAmount > 0); require(_mintAmount <= maxMintAmount); require(supply + _mintAmount <= maxSupply); if (msg.sender != owner()) { require(msg.value >= cost * _mintAmount); } for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(msg.sender, supply + i); } } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); if(revealed == false) { return notRevealedUri; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } //only owner function reveal() public onlyOwner() { revealed = true; } function setCost(uint256 _newCost) public onlyOwner() { cost = _newCost; } function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner() { maxMintAmount = _newmaxMintAmount; } function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner { notRevealedUri = _notRevealedURI; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } function pause(bool _state) public onlyOwner { paused = _state; } function withdraw() public payable onlyOwner { (bool success, ) = payable(msg.sender).call{value: address(this).balance}(""); require(success); } }
_baseURI
function _baseURI() internal view virtual override returns (string memory) { return baseURI; }
// internal
LineComment
v0.8.7+commit.e28d00a7
MIT
ipfs://cd1ce40d528c24a29964360bc75ce46ea837d3caeaf064de1f048052863ba51d
{ "func_code_index": [ 628, 733 ] }
5,197
SalvatorMundi
@openzeppelin/contracts/access/Ownable.sol
0x0cce0c492d4a9da79c1c58e23b414504419b8590
Solidity
SalvatorMundi
contract SalvatorMundi is ERC721Enumerable, Ownable { using Strings for uint256; string baseURI; string public baseExtension = ".json"; uint256 public cost = 1.5 ether; uint256 public maxSupply = 10000; uint256 public maxMintAmount = 20; bool public paused = false; bool public revealed = false; string public notRevealedUri; constructor( string memory _name, string memory _symbol, string memory _initBaseURI, string memory _initNotRevealedUri ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); setNotRevealedURI(_initNotRevealedUri); } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(uint256 _mintAmount) public payable { uint256 supply = totalSupply(); require(!paused); require(_mintAmount > 0); require(_mintAmount <= maxMintAmount); require(supply + _mintAmount <= maxSupply); if (msg.sender != owner()) { require(msg.value >= cost * _mintAmount); } for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(msg.sender, supply + i); } } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); if(revealed == false) { return notRevealedUri; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } //only owner function reveal() public onlyOwner() { revealed = true; } function setCost(uint256 _newCost) public onlyOwner() { cost = _newCost; } function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner() { maxMintAmount = _newmaxMintAmount; } function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner { notRevealedUri = _notRevealedURI; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } function pause(bool _state) public onlyOwner { paused = _state; } function withdraw() public payable onlyOwner { (bool success, ) = payable(msg.sender).call{value: address(this).balance}(""); require(success); } }
mint
function mint(uint256 _mintAmount) public payable { uint256 supply = totalSupply(); require(!paused); require(_mintAmount > 0); require(_mintAmount <= maxMintAmount); require(supply + _mintAmount <= maxSupply); if (msg.sender != owner()) { require(msg.value >= cost * _mintAmount); } for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(msg.sender, supply + i); } }
// public
LineComment
v0.8.7+commit.e28d00a7
MIT
ipfs://cd1ce40d528c24a29964360bc75ce46ea837d3caeaf064de1f048052863ba51d
{ "func_code_index": [ 749, 1185 ] }
5,198
SalvatorMundi
@openzeppelin/contracts/access/Ownable.sol
0x0cce0c492d4a9da79c1c58e23b414504419b8590
Solidity
SalvatorMundi
contract SalvatorMundi is ERC721Enumerable, Ownable { using Strings for uint256; string baseURI; string public baseExtension = ".json"; uint256 public cost = 1.5 ether; uint256 public maxSupply = 10000; uint256 public maxMintAmount = 20; bool public paused = false; bool public revealed = false; string public notRevealedUri; constructor( string memory _name, string memory _symbol, string memory _initBaseURI, string memory _initNotRevealedUri ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); setNotRevealedURI(_initNotRevealedUri); } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(uint256 _mintAmount) public payable { uint256 supply = totalSupply(); require(!paused); require(_mintAmount > 0); require(_mintAmount <= maxMintAmount); require(supply + _mintAmount <= maxSupply); if (msg.sender != owner()) { require(msg.value >= cost * _mintAmount); } for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(msg.sender, supply + i); } } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); if(revealed == false) { return notRevealedUri; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } //only owner function reveal() public onlyOwner() { revealed = true; } function setCost(uint256 _newCost) public onlyOwner() { cost = _newCost; } function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner() { maxMintAmount = _newmaxMintAmount; } function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner { notRevealedUri = _notRevealedURI; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } function pause(bool _state) public onlyOwner { paused = _state; } function withdraw() public payable onlyOwner { (bool success, ) = payable(msg.sender).call{value: address(this).balance}(""); require(success); } }
reveal
function reveal() public onlyOwner() { revealed = true; }
//only owner
LineComment
v0.8.7+commit.e28d00a7
MIT
ipfs://cd1ce40d528c24a29964360bc75ce46ea837d3caeaf064de1f048052863ba51d
{ "func_code_index": [ 2061, 2131 ] }
5,199
BatchPreOrder
BatchPreOrder.sol
0xd558f0c903ccac458495f0dc776dbcc78f1adf79
Solidity
Ownable
contract Ownable { address private _owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { _owner = msg.sender; } /** * @return the address of the owner. */ function owner() public view returns(address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner()); _; } /** * @return true if `msg.sender` is the owner of the contract. */ function isOwner() public view returns(bool) { return msg.sender == _owner; } /** * @dev Allows the current owner to relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(_owner); _owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0)); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
/** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */
NatSpecMultiLine
owner
function owner() public view returns(address) { return _owner; }
/** * @return the address of the owner. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://40803e85a639ed1f108b5ac71d85535c59732bc2f66ea68acc0216f6e033e4b7
{ "func_code_index": [ 451, 526 ] }
5,200
BatchPreOrder
BatchPreOrder.sol
0xd558f0c903ccac458495f0dc776dbcc78f1adf79
Solidity
Ownable
contract Ownable { address private _owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { _owner = msg.sender; } /** * @return the address of the owner. */ function owner() public view returns(address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner()); _; } /** * @return true if `msg.sender` is the owner of the contract. */ function isOwner() public view returns(bool) { return msg.sender == _owner; } /** * @dev Allows the current owner to relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(_owner); _owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0)); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
/** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */
NatSpecMultiLine
isOwner
function isOwner() public view returns(bool) { return msg.sender == _owner; }
/** * @return true if `msg.sender` is the owner of the contract. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://40803e85a639ed1f108b5ac71d85535c59732bc2f66ea68acc0216f6e033e4b7
{ "func_code_index": [ 753, 841 ] }
5,201
BatchPreOrder
BatchPreOrder.sol
0xd558f0c903ccac458495f0dc776dbcc78f1adf79
Solidity
Ownable
contract Ownable { address private _owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { _owner = msg.sender; } /** * @return the address of the owner. */ function owner() public view returns(address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner()); _; } /** * @return true if `msg.sender` is the owner of the contract. */ function isOwner() public view returns(bool) { return msg.sender == _owner; } /** * @dev Allows the current owner to relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(_owner); _owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0)); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
/** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */
NatSpecMultiLine
renounceOwnership
function renounceOwnership() public onlyOwner { emit OwnershipRenounced(_owner); _owner = address(0); }
/** * @dev Allows the current owner to relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://40803e85a639ed1f108b5ac71d85535c59732bc2f66ea68acc0216f6e033e4b7
{ "func_code_index": [ 1110, 1229 ] }
5,202
BatchPreOrder
BatchPreOrder.sol
0xd558f0c903ccac458495f0dc776dbcc78f1adf79
Solidity
Ownable
contract Ownable { address private _owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { _owner = msg.sender; } /** * @return the address of the owner. */ function owner() public view returns(address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner()); _; } /** * @return true if `msg.sender` is the owner of the contract. */ function isOwner() public view returns(bool) { return msg.sender == _owner; } /** * @dev Allows the current owner to relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(_owner); _owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0)); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
/** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */
NatSpecMultiLine
transferOwnership
function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); }
/** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://40803e85a639ed1f108b5ac71d85535c59732bc2f66ea68acc0216f6e033e4b7
{ "func_code_index": [ 1393, 1499 ] }
5,203
BatchPreOrder
BatchPreOrder.sol
0xd558f0c903ccac458495f0dc776dbcc78f1adf79
Solidity
Ownable
contract Ownable { address private _owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { _owner = msg.sender; } /** * @return the address of the owner. */ function owner() public view returns(address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner()); _; } /** * @return true if `msg.sender` is the owner of the contract. */ function isOwner() public view returns(bool) { return msg.sender == _owner; } /** * @dev Allows the current owner to relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(_owner); _owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0)); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
/** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */
NatSpecMultiLine
_transferOwnership
function _transferOwnership(address newOwner) internal { require(newOwner != address(0)); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; }
/** * @dev Transfers control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://40803e85a639ed1f108b5ac71d85535c59732bc2f66ea68acc0216f6e033e4b7
{ "func_code_index": [ 1636, 1812 ] }
5,204
BatchPreOrder
BatchPreOrder.sol
0xd558f0c903ccac458495f0dc776dbcc78f1adf79
Solidity
Destructible
contract Destructible is Ownable { /** * @dev Transfers the current balance to the owner and terminates the contract. */ function destroy() public onlyOwner { selfdestruct(owner()); } function destroyAndSend(address _recipient) public onlyOwner { selfdestruct(_recipient); } }
/** * @title Destructible * @dev Base contract that can be destroyed by owner. All funds in contract will be sent to the owner. */
NatSpecMultiLine
destroy
function destroy() public onlyOwner { selfdestruct(owner()); }
/** * @dev Transfers the current balance to the owner and terminates the contract. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://40803e85a639ed1f108b5ac71d85535c59732bc2f66ea68acc0216f6e033e4b7
{ "func_code_index": [ 133, 206 ] }
5,205
BatchPreOrder
BatchPreOrder.sol
0xd558f0c903ccac458495f0dc776dbcc78f1adf79
Solidity
IERC165
interface IERC165 { /** * @notice Query if a contract implements an interface * @param interfaceId The interface identifier, as specified in ERC-165 * @dev Interface identification is specified in ERC-165. This function * uses less than 30,000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
/** * @title IERC165 * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md */
NatSpecMultiLine
supportsInterface
function supportsInterface(bytes4 interfaceId) external view returns (bool);
/** * @notice Query if a contract implements an interface * @param interfaceId The interface identifier, as specified in ERC-165 * @dev Interface identification is specified in ERC-165. This function * uses less than 30,000 gas. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://40803e85a639ed1f108b5ac71d85535c59732bc2f66ea68acc0216f6e033e4b7
{ "func_code_index": [ 278, 372 ] }
5,206