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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
SedoPoWToken | SedoPoWToken.sol | 0x0f00f1696218eaefa2d2330df3d6d1f94813b38f | Solidity | SedoPoWToken | contract SedoPoWToken is ERC20Interface, Owned {
using SafeMath for uint;
using ExtendedMath for uint;
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
uint public latestDifficultyPeriodStarted;
uint public epochCount;//number of 'blocks' mined
uint public _BLOCKS_PER_READJUSTMENT = 1024;
//a little number
uint public _MINIMUM_TARGET = 2**16;
uint public _MAXIMUM_TARGET = 2**234;
uint public miningTarget;
bytes32 public challengeNumber; //generate a new one when a new reward is minted
uint public rewardEra;
uint public maxSupplyForEra;
address public lastRewardTo;
uint public lastRewardAmount;
uint public lastRewardEthBlockNumber;
bool locked = false;
mapping(bytes32 => bytes32) solutionForChallenge;
uint public tokensMinted;
address public parentAddress; //address of 0xbtc
uint public miningReward; //initial reward
mapping(address => uint) balances;
mapping(address => uint) merge_mint_ious;
mapping(address => uint) merge_mint_payout_threshold;
mapping(address => mapping(address => uint)) allowed;
event Mint(address indexed from, uint reward_amount, uint epochCount, bytes32 newChallengeNumber);
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
function SedoPoWToken() public onlyOwner{
symbol = "SEDO";
name = "SEDO PoW Token";
decimals = 8;
_totalSupply = 50000000 * 10**uint(decimals);
if(locked) revert();
locked = true;
tokensMinted = 1000000 * 10**uint(decimals);
miningReward = 25; //initial Mining reward for 1st half of totalSupply (50 000 000 / 2)
rewardEra = 0;
maxSupplyForEra = _totalSupply.div(2);
miningTarget = 2**220; //initial mining target
latestDifficultyPeriodStarted = block.number;
_startNewMiningEpoch();
parentAddress = 0x9D2Cc383E677292ed87f63586086CfF62a009010; //address of parent coin 0xBTC - need to be changed to actual in the mainnet !
//0xB6eD7644C69416d67B522e20bC294A9a9B405B31 - production
balances[owner] = balances[owner].add(tokensMinted);
Transfer(address(this), owner, tokensMinted);
}
// ------------------------------------------------------------------------
// Parent contract changing (it can be useful if parent will make a swap or in some other cases)
// ------------------------------------------------------------------------
function ParentCoinAddress(address parent) public onlyOwner{
parentAddress = parent;
}
// ------------------------------------------------------------------------
// Main mint function
// ------------------------------------------------------------------------
function mint(uint256 nonce, bytes32 challenge_digest) public returns (bool success) {
//the PoW must contain work that includes a recent ethereum block hash (challenge number) and the msg.sender's address to prevent MITM attacks
bytes32 digest = keccak256(challengeNumber, msg.sender, nonce );
//the challenge digest must match the expected
if (digest != challenge_digest) revert();
//the digest must be smaller than the target
if(uint256(digest) > miningTarget) revert();
//only allow one reward for each challenge
bytes32 solution = solutionForChallenge[challengeNumber];
solutionForChallenge[challengeNumber] = digest;
if(solution != 0x0) revert(); //prevent the same answer from awarding twice
uint reward_amount = getMiningReward();
balances[msg.sender] = balances[msg.sender].add(reward_amount);
tokensMinted = tokensMinted.add(reward_amount);
//Cannot mint more tokens than there are
assert(tokensMinted <= maxSupplyForEra);
//set readonly diagnostics data
lastRewardTo = msg.sender;
lastRewardAmount = reward_amount;
lastRewardEthBlockNumber = block.number;
_startNewMiningEpoch();
Mint(msg.sender, reward_amount, epochCount, challengeNumber );
emit Transfer(address(this), msg.sender, reward_amount); //we need add it to show token transfers in the etherscan
return true;
}
// ------------------------------------------------------------------------
// merge mint function
// ------------------------------------------------------------------------
function merge() public returns (bool success) {
// Function for the Merge mining (0xbitcoin as a parent coin)
// original idea by 0xbitcoin developers
// the idea is that the miner uses https://github.com/0xbitcoin/mint-helper/blob/master/contracts/MintHelper.sol
// to call mint() and then mergeMint() in the same transaction
// hard code a reference to the "Parent" ERC918 Contract ( in this case 0xBitcoin)
// Verify that the Parent contract was minted in this block, by the same person calling this contract
// then followthrough with the resulting mint logic
// don't call revert, but return true or false based on success
// this method shouldn't revert because it will be calleed in the same transaction as a "Parent" mint attempt
//ensure that mergeMint() can only be called once per Parent::mint()
//do this by ensuring that the "new" challenge number from Parent::challenge post mint can be called once
//and that this block time is the same as this mint, and the caller is msg.sender
//only allow one reward for each challenge
// do this by calculating what the new challenge will be in _startNewMiningEpoch, and verify that it is not that value
// this checks happen in the local contract, not in the parent
bytes32 future_challengeNumber = block.blockhash(block.number - 1);
if(challengeNumber == future_challengeNumber){
return false; // ( this is likely the second time that mergeMint() has been called in a transaction, so return false (don't revert))
}
if(ERC918Interface(parentAddress).lastRewardTo() != msg.sender){
return false; // a different address called mint last so return false ( don't revert)
}
if(ERC918Interface(parentAddress).lastRewardEthBlockNumber() != block.number){
return false; // parent::mint() was called in a different block number so return false ( don't revert)
}
//we have verified that _startNewMiningEpoch has not been run more than once this block by verifying that
// the challenge is not the challenge that will be set by _startNewMiningEpoch
//we have verified that this is the same block as a call to Parent::mint() and that the sender
// is the sender that has called mint
//SEDO will have the same challenge numbers as 0xBitcoin, this means that mining for one is literally the same process as mining for the other
// we want to make sure that one can't use a combination of merge and mint to get two blocks of SEDO for each valid nonce, since the same solution
// applies to each coin
// for this reason, we update the solutionForChallenge hashmap with the value of parent::challengeNumber when a solution is merge minted.
// when a miner finds a valid solution, if they call this::mint(), without the next few lines of code they can then subsequently use the mint helper and in one transaction
// call parent::mint() this::merge(). the following code will ensure that this::merge() does not give a block reward, because the challenge number will already be set in the
// solutionForChallenge map
//only allow one reward for each challenge based on parent::challengeNumber
bytes32 parentChallengeNumber = ERC918Interface(parentAddress).challengeNumber();
bytes32 solution = solutionForChallenge[parentChallengeNumber];
if(solution != 0x0) return false; //prevent the same answer from awarding twice
//now that we've checked that the next challenge wasn't reused, apply the current SEDO challenge
//this will prevent the 'previous' challenge from being reused
bytes32 digest = 'merge';
solutionForChallenge[challengeNumber] = digest;
//so now we may safely run the relevant logic to give an award to the sender, and update the contract
uint reward_amount = getMiningReward();
balances[msg.sender] = balances[msg.sender].add(reward_amount);
tokensMinted = tokensMinted.add(reward_amount);
//Cannot mint more tokens than there are
assert(tokensMinted <= maxSupplyForEra);
//set readonly diagnostics data
lastRewardTo = msg.sender;
lastRewardAmount = reward_amount;
lastRewardEthBlockNumber = block.number;
_startNewMiningEpoch();
Mint(msg.sender, reward_amount, epochCount, 0 ); // use 0 to indicate a merge mine
return true;
}
//a new 'block' to be mined
function _startNewMiningEpoch() internal {
//if max supply for the era will be exceeded next reward round then enter the new era before that happens
//40 is the final reward era, almost all tokens minted
//once the final era is reached, more tokens will not be given out because the assert function
if( tokensMinted.add(getMiningReward()) > maxSupplyForEra && rewardEra < 39)
{
rewardEra = rewardEra + 1;
}
//set the next minted supply at which the era will change
// total supply is 5000000000000000 because of 8 decimal places
maxSupplyForEra = _totalSupply - _totalSupply.div( 2**(rewardEra + 1));
epochCount = epochCount.add(1);
//every so often, readjust difficulty. Dont readjust when deploying
if(epochCount % _BLOCKS_PER_READJUSTMENT == 0)
{
_reAdjustDifficulty();
}
//make the latest ethereum block hash a part of the next challenge for PoW to prevent pre-mining future blocks
//do this last since this is a protection mechanism in the mint() function
challengeNumber = block.blockhash(block.number - 1);
}
//https://en.bitcoin.it/wiki/Difficulty#What_is_the_formula_for_difficulty.3F
//as of 2017 the bitcoin difficulty was up to 17 zeroes, it was only 8 in the early days
//readjust the target by 5 percent
function _reAdjustDifficulty() internal {
uint ethBlocksSinceLastDifficultyPeriod = block.number - latestDifficultyPeriodStarted;
uint epochsMined = _BLOCKS_PER_READJUSTMENT; //256
uint targetEthBlocksPerDiffPeriod = epochsMined * 60; //should be 60 times slower than ethereum
//if there were less eth blocks passed in time than expected
if( ethBlocksSinceLastDifficultyPeriod < targetEthBlocksPerDiffPeriod )
{
uint excess_block_pct = (targetEthBlocksPerDiffPeriod.mul(100)).div( ethBlocksSinceLastDifficultyPeriod );
uint excess_block_pct_extra = excess_block_pct.sub(100).limitLessThan(1000);
// If there were 5% more blocks mined than expected then this is 5. If there were 100% more blocks mined than expected then this is 100.
//make it harder
miningTarget = miningTarget.sub(miningTarget.div(2000).mul(excess_block_pct_extra)); //by up to 50 %
}else{
uint shortage_block_pct = (ethBlocksSinceLastDifficultyPeriod.mul(100)).div( targetEthBlocksPerDiffPeriod );
uint shortage_block_pct_extra = shortage_block_pct.sub(100).limitLessThan(1000); //always between 0 and 1000
//make it easier
miningTarget = miningTarget.add(miningTarget.div(2000).mul(shortage_block_pct_extra)); //by up to 50 %
}
latestDifficultyPeriodStarted = block.number;
if(miningTarget < _MINIMUM_TARGET) //very difficult
{
miningTarget = _MINIMUM_TARGET;
}
if(miningTarget > _MAXIMUM_TARGET) //very easy
{
miningTarget = _MAXIMUM_TARGET;
}
}
//this is a recent ethereum block hash, used to prevent pre-mining future blocks
function getChallengeNumber() public constant returns (bytes32) {
return challengeNumber;
}
//the number of zeroes the digest of the PoW solution requires. Auto adjusts
function getMiningDifficulty() public constant returns (uint) {
return _MAXIMUM_TARGET.div(miningTarget);
}
function getMiningTarget() public constant returns (uint) {
return miningTarget;
}
//50m coins total
//reward begins at miningReward and is cut in half every reward era (as tokens are mined)
function getMiningReward() public constant returns (uint) {
//once we get half way thru the coins, only get 25 per block
//every reward era, the reward amount halves.
return (miningReward * 10**uint(decimals) ).div( 2**rewardEra ) ;
}
//help debug mining software
function getMintDigest(uint256 nonce, bytes32 challenge_digest, bytes32 challenge_number) public view returns (bytes32 digesttest) {
bytes32 digest = keccak256(challenge_number,msg.sender,nonce);
return digest;
}
//help debug mining software
function checkMintSolution(uint256 nonce, bytes32 challenge_digest, bytes32 challenge_number, uint testTarget) public view returns (bool success) {
bytes32 digest = keccak256(challenge_number,msg.sender,nonce);
if(uint256(digest) > testTarget) revert();
return (digest == challenge_digest);
}
// ------------------------------------------------------------------------
// 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] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer `tokens` from the `from` account to the `to` account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the `from` account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = balances[from].sub(tokens);
allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account. The `spender` contract function
// `receiveApproval(...)` is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and an
// initial fixed supply
// ---------------------------------------------------------------------------- | LineComment | transferAnyERC20Token | function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
| // ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | bzzr://c4774b9768b3b751f21d10c61fa3e0c71800beaa69e1672013c69d5ace49c9fb | {
"func_code_index": [
19319,
19512
]
} | 6,007 |
|
MGEX | contracts/MGEX.sol | 0x10ea970cd621fab8553551030db5f9787958d422 | Solidity | MGEX | contract MGEX is EIP20Interface {
uint256 constant private MAX_UINT256 = 2**256 - 1;
mapping (address => uint256) public balances;
mapping (address => mapping (address => uint256)) public allowed;
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; //fancy name: eg Simon Bucks
uint8 public decimals; //How many decimals to show.
string public symbol; //An identifier: eg SBX
function MGEX(
uint256 _initialAmount,
string _tokenName,
uint8 _decimalUnits,
string _tokenSymbol
) public {
balances[msg.sender] = _initialAmount; // Give the creator all initial tokens
totalSupply = _initialAmount; // Update total supply
name = _tokenName; // Set the name for display purposes
decimals = _decimalUnits; // Amount of decimals for display purposes
symbol = _tokenSymbol; // Set the symbol for display purposes
}
function transfer(address _to, uint256 _value) public returns (bool success) {
require(balances[msg.sender] >= _value);
balances[msg.sender] -= _value;
balances[_to] += _value;
emit Transfer(msg.sender, _to, _value); //solhint-disable-line indent, no-unused-vars
return true;
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
uint256 allowance = allowed[_from][msg.sender];
require(balances[_from] >= _value && allowance >= _value);
balances[_to] += _value;
balances[_from] -= _value;
if (allowance < MAX_UINT256) {
allowed[_from][msg.sender] -= _value;
}
emit Transfer(_from, _to, _value); //solhint-disable-line indent, no-unused-vars
return true;
}
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
function approve(address _spender, uint256 _value) public returns (bool success) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value); //solhint-disable-line indent, no-unused-vars
return true;
}
function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
return allowed[_owner][_spender];
}
} | MGEX | function MGEX(
uint256 _initialAmount,
string _tokenName,
uint8 _decimalUnits,
string _tokenSymbol
) public {
balances[msg.sender] = _initialAmount; // Give the creator all initial tokens
totalSupply = _initialAmount; // Update total supply
name = _tokenName; // Set the name for display purposes
decimals = _decimalUnits; // Amount of decimals for display purposes
symbol = _tokenSymbol; // Set the symbol for display purposes
}
| //An identifier: eg SBX | LineComment | v0.4.21+commit.dfe3193c | bzzr://d9c53457a34646bb679f473a90b2ae69084a4a65d7d6ce2c4beef4551b9fdfc0 | {
"func_code_index": [
721,
1374
]
} | 6,008 |
|||
Mingoes | contracts/src/ERC721/ERC721.sol | 0xe6f475c11ad693e48455fcaf7bca33fe84ce71b0 | Solidity | ERC721 | abstract contract ERC721 {
/* -------------------------------------------------------------------------- */
/* EVENTS */
/* -------------------------------------------------------------------------- */
/// @dev Emitted when `id` token is transferred from `from` to `to`.
event Transfer(address indexed from, address indexed to, uint256 indexed id);
/// @dev Emitted when `owner` enables `approved` to manage the `id` token.
event Approval(address indexed owner, address indexed spender, uint256 indexed id);
/// @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/* -------------------------------------------------------------------------- */
/* METADATA STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev The collection name.
string private _name;
/// @dev The collection symbol.
string private _symbol;
/* -------------------------------------------------------------------------- */
/* ERC721 STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev ID => spender
mapping(uint256 => address) internal _tokenApprovals;
/// @dev owner => operator => approved
mapping(address => mapping(address => bool)) internal _operatorApprovals;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
/// @param name_ The collection name.
/// @param symbol_ The collection symbol.
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/* -------------------------------------------------------------------------- */
/* ERC165 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns true if this contract implements an interface from its ID.
/// @dev See the corresponding
/// [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
/// to learn more about how these IDs are created.
/// @return The implementation status.
function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool) {
return
interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721
interfaceId == 0x5b5e139f || // ERC165 Interface ID for ERC721Metadata
interfaceId == 0x780e9d63; // ERC165 Interface ID for ERC721Enumerable
}
/* -------------------------------------------------------------------------- */
/* METADATA LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the collection name.
/// @return The collection name.
function name() public view virtual returns (string memory) {
return _name;
}
/// @notice Returns the collection symbol.
/// @return The collection symbol.
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/// @notice Returns the Uniform Resource Identifier (URI) for `id` token.
/// @param id The token ID.
/// @return The URI.
function tokenURI(uint256 id) public view virtual returns (string memory);
/* -------------------------------------------------------------------------- */
/* ENUMERABLE LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the total amount of tokens stored by the contract.
/// @return The token supply.
function totalSupply() public view virtual returns (uint256);
/// @notice Returns a token ID owned by `owner` at a given `index` of its token list.
/// @dev Use along with {balanceOf} to enumerate all of `owner`'s tokens.
/// @param owner The address to query.
/// @param index The index to query.
/// @return The token ID.
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256);
/// @notice Returns a token ID at a given `index` of all the tokens stored by the contract.
/// @dev Use along with {totalSupply} to enumerate all tokens.
/// @param index The index to query.
/// @return The token ID.
function tokenByIndex(uint256 index) public view virtual returns (uint256);
/* -------------------------------------------------------------------------- */
/* ERC721 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the account approved for a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id Token ID to query.
/// @return The account approved for `id` token.
function getApproved(uint256 id) public virtual returns (address) {
require(_exists(id), "NONEXISTENT_TOKEN");
return _tokenApprovals[id];
}
/// @notice Returns if the `operator` is allowed to manage all of the assets of `owner`.
/// @param owner The address of the owner.
/// @param operator The address of the operator.
/// @return True if `operator` was approved by `owner`.
function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
return _operatorApprovals[owner][operator];
}
/// @notice Gives permission to `to` to transfer `id` token to another account.
/// @dev The approval is cleared when the token is transferred.
/// Only a single account can be approved at a time, so approving the zero address clears previous approvals.
/// Requirements:
/// - The caller must own the token or be an approved operator.
/// - `id` must exist.
/// Emits an {Approval} event.
/// @param spender The address of the spender to approve to.
/// @param id The token ID to approve.
function approve(address spender, uint256 id) public virtual {
address owner = ownerOf(id);
require(isApprovedForAll(owner, msg.sender) || msg.sender == owner, "NOT_AUTHORIZED");
_tokenApprovals[id] = spender;
emit Approval(owner, spender, id);
}
/// @notice Approve or remove `operator` as an operator for the caller.
/// @dev Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
/// Emits an {ApprovalForAll} event.
/// @param operator The address of the operator to approve.
/// @param approved The status to set.
function setApprovalForAll(address operator, bool approved) public virtual {
_operatorApprovals[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
/// @notice Transfers `id` token from `from` to `to`.
/// WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function transferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function safeTransferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// Additionally passes `data` in the callback.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
/// @param data The calldata to pass in the {ERC721TokenReceiver-onERC721Received} callback.
function safeTransferFrom(
address from,
address to,
uint256 id,
bytes memory data
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Returns the number of tokens in an account.
/// @param owner The address to query.
/// @return The balance.
function balanceOf(address owner) public view virtual returns (uint256);
/// @notice Returns the owner of a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id The token ID.
function ownerOf(uint256 id) public view virtual returns (address);
/* -------------------------------------------------------------------------- */
/* INTERNAL LOGIC */
/* -------------------------------------------------------------------------- */
/// @dev Returns whether a token ID exists.
/// Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
/// Tokens start existing when they are minted.
/// @param id Token ID to query.
function _exists(uint256 id) internal view virtual returns (bool);
/// @dev Transfers `id` from `from` to `to`.
/// Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function _transfer(
address from,
address to,
uint256 id
) internal virtual;
/// @dev Mints `amount` tokens to `to`.
/// Requirements:
/// - there must be `amount` tokens remaining unminted in the total collection.
/// - `to` cannot be the zero address.
/// Emits `amount` {Transfer} events.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _mint(address to, uint256 amount) internal virtual;
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// If `to` is a contract it must implement {ERC721TokenReceiver.onERC721Received}
/// that returns {ERC721TokenReceiver.onERC721Received.selector}.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _safeMint(address to, uint256 amount) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// Requirements:
/// - `id` must not exist.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver.onERC721Received}, which is called upon a safe transfer.
/// Additionally passes `data` in the callback.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
/// @param data The calldata to pass in the {ERC721TokenReceiver.onERC721Received} callback.
function _safeMint(
address to,
uint256 amount,
bytes memory data
) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/* -------------------------------------------------------------------------- */
/* UTILS */
/* -------------------------------------------------------------------------- */
/// @notice Converts a `uint256` to its ASCII `string` decimal representation.
/// @dev https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Strings.sol
function toString(uint256 value) internal pure virtual returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
} | supportsInterface | function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool) {
return
interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721
interfaceId == 0x5b5e139f || // ERC165 Interface ID for ERC721Metadata
interfaceId == 0x780e9d63; // ERC165 Interface ID for ERC721Enumerable
}
| /// @notice Returns true if this contract implements an interface from its ID.
/// @dev See the corresponding
/// [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
/// to learn more about how these IDs are created.
/// @return The implementation status. | NatSpecSingleLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
2552,
2928
]
} | 6,009 |
||||
Mingoes | contracts/src/ERC721/ERC721.sol | 0xe6f475c11ad693e48455fcaf7bca33fe84ce71b0 | Solidity | ERC721 | abstract contract ERC721 {
/* -------------------------------------------------------------------------- */
/* EVENTS */
/* -------------------------------------------------------------------------- */
/// @dev Emitted when `id` token is transferred from `from` to `to`.
event Transfer(address indexed from, address indexed to, uint256 indexed id);
/// @dev Emitted when `owner` enables `approved` to manage the `id` token.
event Approval(address indexed owner, address indexed spender, uint256 indexed id);
/// @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/* -------------------------------------------------------------------------- */
/* METADATA STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev The collection name.
string private _name;
/// @dev The collection symbol.
string private _symbol;
/* -------------------------------------------------------------------------- */
/* ERC721 STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev ID => spender
mapping(uint256 => address) internal _tokenApprovals;
/// @dev owner => operator => approved
mapping(address => mapping(address => bool)) internal _operatorApprovals;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
/// @param name_ The collection name.
/// @param symbol_ The collection symbol.
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/* -------------------------------------------------------------------------- */
/* ERC165 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns true if this contract implements an interface from its ID.
/// @dev See the corresponding
/// [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
/// to learn more about how these IDs are created.
/// @return The implementation status.
function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool) {
return
interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721
interfaceId == 0x5b5e139f || // ERC165 Interface ID for ERC721Metadata
interfaceId == 0x780e9d63; // ERC165 Interface ID for ERC721Enumerable
}
/* -------------------------------------------------------------------------- */
/* METADATA LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the collection name.
/// @return The collection name.
function name() public view virtual returns (string memory) {
return _name;
}
/// @notice Returns the collection symbol.
/// @return The collection symbol.
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/// @notice Returns the Uniform Resource Identifier (URI) for `id` token.
/// @param id The token ID.
/// @return The URI.
function tokenURI(uint256 id) public view virtual returns (string memory);
/* -------------------------------------------------------------------------- */
/* ENUMERABLE LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the total amount of tokens stored by the contract.
/// @return The token supply.
function totalSupply() public view virtual returns (uint256);
/// @notice Returns a token ID owned by `owner` at a given `index` of its token list.
/// @dev Use along with {balanceOf} to enumerate all of `owner`'s tokens.
/// @param owner The address to query.
/// @param index The index to query.
/// @return The token ID.
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256);
/// @notice Returns a token ID at a given `index` of all the tokens stored by the contract.
/// @dev Use along with {totalSupply} to enumerate all tokens.
/// @param index The index to query.
/// @return The token ID.
function tokenByIndex(uint256 index) public view virtual returns (uint256);
/* -------------------------------------------------------------------------- */
/* ERC721 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the account approved for a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id Token ID to query.
/// @return The account approved for `id` token.
function getApproved(uint256 id) public virtual returns (address) {
require(_exists(id), "NONEXISTENT_TOKEN");
return _tokenApprovals[id];
}
/// @notice Returns if the `operator` is allowed to manage all of the assets of `owner`.
/// @param owner The address of the owner.
/// @param operator The address of the operator.
/// @return True if `operator` was approved by `owner`.
function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
return _operatorApprovals[owner][operator];
}
/// @notice Gives permission to `to` to transfer `id` token to another account.
/// @dev The approval is cleared when the token is transferred.
/// Only a single account can be approved at a time, so approving the zero address clears previous approvals.
/// Requirements:
/// - The caller must own the token or be an approved operator.
/// - `id` must exist.
/// Emits an {Approval} event.
/// @param spender The address of the spender to approve to.
/// @param id The token ID to approve.
function approve(address spender, uint256 id) public virtual {
address owner = ownerOf(id);
require(isApprovedForAll(owner, msg.sender) || msg.sender == owner, "NOT_AUTHORIZED");
_tokenApprovals[id] = spender;
emit Approval(owner, spender, id);
}
/// @notice Approve or remove `operator` as an operator for the caller.
/// @dev Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
/// Emits an {ApprovalForAll} event.
/// @param operator The address of the operator to approve.
/// @param approved The status to set.
function setApprovalForAll(address operator, bool approved) public virtual {
_operatorApprovals[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
/// @notice Transfers `id` token from `from` to `to`.
/// WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function transferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function safeTransferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// Additionally passes `data` in the callback.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
/// @param data The calldata to pass in the {ERC721TokenReceiver-onERC721Received} callback.
function safeTransferFrom(
address from,
address to,
uint256 id,
bytes memory data
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Returns the number of tokens in an account.
/// @param owner The address to query.
/// @return The balance.
function balanceOf(address owner) public view virtual returns (uint256);
/// @notice Returns the owner of a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id The token ID.
function ownerOf(uint256 id) public view virtual returns (address);
/* -------------------------------------------------------------------------- */
/* INTERNAL LOGIC */
/* -------------------------------------------------------------------------- */
/// @dev Returns whether a token ID exists.
/// Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
/// Tokens start existing when they are minted.
/// @param id Token ID to query.
function _exists(uint256 id) internal view virtual returns (bool);
/// @dev Transfers `id` from `from` to `to`.
/// Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function _transfer(
address from,
address to,
uint256 id
) internal virtual;
/// @dev Mints `amount` tokens to `to`.
/// Requirements:
/// - there must be `amount` tokens remaining unminted in the total collection.
/// - `to` cannot be the zero address.
/// Emits `amount` {Transfer} events.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _mint(address to, uint256 amount) internal virtual;
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// If `to` is a contract it must implement {ERC721TokenReceiver.onERC721Received}
/// that returns {ERC721TokenReceiver.onERC721Received.selector}.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _safeMint(address to, uint256 amount) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// Requirements:
/// - `id` must not exist.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver.onERC721Received}, which is called upon a safe transfer.
/// Additionally passes `data` in the callback.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
/// @param data The calldata to pass in the {ERC721TokenReceiver.onERC721Received} callback.
function _safeMint(
address to,
uint256 amount,
bytes memory data
) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/* -------------------------------------------------------------------------- */
/* UTILS */
/* -------------------------------------------------------------------------- */
/// @notice Converts a `uint256` to its ASCII `string` decimal representation.
/// @dev https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Strings.sol
function toString(uint256 value) internal pure virtual returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
} | name | function name() public view virtual returns (string memory) {
return _name;
}
| /// @notice Returns the collection name.
/// @return The collection name. | NatSpecSingleLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
3253,
3334
]
} | 6,010 |
||||
Mingoes | contracts/src/ERC721/ERC721.sol | 0xe6f475c11ad693e48455fcaf7bca33fe84ce71b0 | Solidity | ERC721 | abstract contract ERC721 {
/* -------------------------------------------------------------------------- */
/* EVENTS */
/* -------------------------------------------------------------------------- */
/// @dev Emitted when `id` token is transferred from `from` to `to`.
event Transfer(address indexed from, address indexed to, uint256 indexed id);
/// @dev Emitted when `owner` enables `approved` to manage the `id` token.
event Approval(address indexed owner, address indexed spender, uint256 indexed id);
/// @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/* -------------------------------------------------------------------------- */
/* METADATA STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev The collection name.
string private _name;
/// @dev The collection symbol.
string private _symbol;
/* -------------------------------------------------------------------------- */
/* ERC721 STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev ID => spender
mapping(uint256 => address) internal _tokenApprovals;
/// @dev owner => operator => approved
mapping(address => mapping(address => bool)) internal _operatorApprovals;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
/// @param name_ The collection name.
/// @param symbol_ The collection symbol.
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/* -------------------------------------------------------------------------- */
/* ERC165 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns true if this contract implements an interface from its ID.
/// @dev See the corresponding
/// [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
/// to learn more about how these IDs are created.
/// @return The implementation status.
function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool) {
return
interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721
interfaceId == 0x5b5e139f || // ERC165 Interface ID for ERC721Metadata
interfaceId == 0x780e9d63; // ERC165 Interface ID for ERC721Enumerable
}
/* -------------------------------------------------------------------------- */
/* METADATA LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the collection name.
/// @return The collection name.
function name() public view virtual returns (string memory) {
return _name;
}
/// @notice Returns the collection symbol.
/// @return The collection symbol.
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/// @notice Returns the Uniform Resource Identifier (URI) for `id` token.
/// @param id The token ID.
/// @return The URI.
function tokenURI(uint256 id) public view virtual returns (string memory);
/* -------------------------------------------------------------------------- */
/* ENUMERABLE LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the total amount of tokens stored by the contract.
/// @return The token supply.
function totalSupply() public view virtual returns (uint256);
/// @notice Returns a token ID owned by `owner` at a given `index` of its token list.
/// @dev Use along with {balanceOf} to enumerate all of `owner`'s tokens.
/// @param owner The address to query.
/// @param index The index to query.
/// @return The token ID.
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256);
/// @notice Returns a token ID at a given `index` of all the tokens stored by the contract.
/// @dev Use along with {totalSupply} to enumerate all tokens.
/// @param index The index to query.
/// @return The token ID.
function tokenByIndex(uint256 index) public view virtual returns (uint256);
/* -------------------------------------------------------------------------- */
/* ERC721 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the account approved for a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id Token ID to query.
/// @return The account approved for `id` token.
function getApproved(uint256 id) public virtual returns (address) {
require(_exists(id), "NONEXISTENT_TOKEN");
return _tokenApprovals[id];
}
/// @notice Returns if the `operator` is allowed to manage all of the assets of `owner`.
/// @param owner The address of the owner.
/// @param operator The address of the operator.
/// @return True if `operator` was approved by `owner`.
function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
return _operatorApprovals[owner][operator];
}
/// @notice Gives permission to `to` to transfer `id` token to another account.
/// @dev The approval is cleared when the token is transferred.
/// Only a single account can be approved at a time, so approving the zero address clears previous approvals.
/// Requirements:
/// - The caller must own the token or be an approved operator.
/// - `id` must exist.
/// Emits an {Approval} event.
/// @param spender The address of the spender to approve to.
/// @param id The token ID to approve.
function approve(address spender, uint256 id) public virtual {
address owner = ownerOf(id);
require(isApprovedForAll(owner, msg.sender) || msg.sender == owner, "NOT_AUTHORIZED");
_tokenApprovals[id] = spender;
emit Approval(owner, spender, id);
}
/// @notice Approve or remove `operator` as an operator for the caller.
/// @dev Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
/// Emits an {ApprovalForAll} event.
/// @param operator The address of the operator to approve.
/// @param approved The status to set.
function setApprovalForAll(address operator, bool approved) public virtual {
_operatorApprovals[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
/// @notice Transfers `id` token from `from` to `to`.
/// WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function transferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function safeTransferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// Additionally passes `data` in the callback.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
/// @param data The calldata to pass in the {ERC721TokenReceiver-onERC721Received} callback.
function safeTransferFrom(
address from,
address to,
uint256 id,
bytes memory data
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Returns the number of tokens in an account.
/// @param owner The address to query.
/// @return The balance.
function balanceOf(address owner) public view virtual returns (uint256);
/// @notice Returns the owner of a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id The token ID.
function ownerOf(uint256 id) public view virtual returns (address);
/* -------------------------------------------------------------------------- */
/* INTERNAL LOGIC */
/* -------------------------------------------------------------------------- */
/// @dev Returns whether a token ID exists.
/// Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
/// Tokens start existing when they are minted.
/// @param id Token ID to query.
function _exists(uint256 id) internal view virtual returns (bool);
/// @dev Transfers `id` from `from` to `to`.
/// Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function _transfer(
address from,
address to,
uint256 id
) internal virtual;
/// @dev Mints `amount` tokens to `to`.
/// Requirements:
/// - there must be `amount` tokens remaining unminted in the total collection.
/// - `to` cannot be the zero address.
/// Emits `amount` {Transfer} events.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _mint(address to, uint256 amount) internal virtual;
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// If `to` is a contract it must implement {ERC721TokenReceiver.onERC721Received}
/// that returns {ERC721TokenReceiver.onERC721Received.selector}.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _safeMint(address to, uint256 amount) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// Requirements:
/// - `id` must not exist.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver.onERC721Received}, which is called upon a safe transfer.
/// Additionally passes `data` in the callback.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
/// @param data The calldata to pass in the {ERC721TokenReceiver.onERC721Received} callback.
function _safeMint(
address to,
uint256 amount,
bytes memory data
) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/* -------------------------------------------------------------------------- */
/* UTILS */
/* -------------------------------------------------------------------------- */
/// @notice Converts a `uint256` to its ASCII `string` decimal representation.
/// @dev https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Strings.sol
function toString(uint256 value) internal pure virtual returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
} | symbol | function symbol() public view virtual returns (string memory) {
return _symbol;
}
| /// @notice Returns the collection symbol.
/// @return The collection symbol. | NatSpecSingleLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
3416,
3501
]
} | 6,011 |
||||
Mingoes | contracts/src/ERC721/ERC721.sol | 0xe6f475c11ad693e48455fcaf7bca33fe84ce71b0 | Solidity | ERC721 | abstract contract ERC721 {
/* -------------------------------------------------------------------------- */
/* EVENTS */
/* -------------------------------------------------------------------------- */
/// @dev Emitted when `id` token is transferred from `from` to `to`.
event Transfer(address indexed from, address indexed to, uint256 indexed id);
/// @dev Emitted when `owner` enables `approved` to manage the `id` token.
event Approval(address indexed owner, address indexed spender, uint256 indexed id);
/// @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/* -------------------------------------------------------------------------- */
/* METADATA STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev The collection name.
string private _name;
/// @dev The collection symbol.
string private _symbol;
/* -------------------------------------------------------------------------- */
/* ERC721 STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev ID => spender
mapping(uint256 => address) internal _tokenApprovals;
/// @dev owner => operator => approved
mapping(address => mapping(address => bool)) internal _operatorApprovals;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
/// @param name_ The collection name.
/// @param symbol_ The collection symbol.
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/* -------------------------------------------------------------------------- */
/* ERC165 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns true if this contract implements an interface from its ID.
/// @dev See the corresponding
/// [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
/// to learn more about how these IDs are created.
/// @return The implementation status.
function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool) {
return
interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721
interfaceId == 0x5b5e139f || // ERC165 Interface ID for ERC721Metadata
interfaceId == 0x780e9d63; // ERC165 Interface ID for ERC721Enumerable
}
/* -------------------------------------------------------------------------- */
/* METADATA LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the collection name.
/// @return The collection name.
function name() public view virtual returns (string memory) {
return _name;
}
/// @notice Returns the collection symbol.
/// @return The collection symbol.
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/// @notice Returns the Uniform Resource Identifier (URI) for `id` token.
/// @param id The token ID.
/// @return The URI.
function tokenURI(uint256 id) public view virtual returns (string memory);
/* -------------------------------------------------------------------------- */
/* ENUMERABLE LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the total amount of tokens stored by the contract.
/// @return The token supply.
function totalSupply() public view virtual returns (uint256);
/// @notice Returns a token ID owned by `owner` at a given `index` of its token list.
/// @dev Use along with {balanceOf} to enumerate all of `owner`'s tokens.
/// @param owner The address to query.
/// @param index The index to query.
/// @return The token ID.
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256);
/// @notice Returns a token ID at a given `index` of all the tokens stored by the contract.
/// @dev Use along with {totalSupply} to enumerate all tokens.
/// @param index The index to query.
/// @return The token ID.
function tokenByIndex(uint256 index) public view virtual returns (uint256);
/* -------------------------------------------------------------------------- */
/* ERC721 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the account approved for a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id Token ID to query.
/// @return The account approved for `id` token.
function getApproved(uint256 id) public virtual returns (address) {
require(_exists(id), "NONEXISTENT_TOKEN");
return _tokenApprovals[id];
}
/// @notice Returns if the `operator` is allowed to manage all of the assets of `owner`.
/// @param owner The address of the owner.
/// @param operator The address of the operator.
/// @return True if `operator` was approved by `owner`.
function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
return _operatorApprovals[owner][operator];
}
/// @notice Gives permission to `to` to transfer `id` token to another account.
/// @dev The approval is cleared when the token is transferred.
/// Only a single account can be approved at a time, so approving the zero address clears previous approvals.
/// Requirements:
/// - The caller must own the token or be an approved operator.
/// - `id` must exist.
/// Emits an {Approval} event.
/// @param spender The address of the spender to approve to.
/// @param id The token ID to approve.
function approve(address spender, uint256 id) public virtual {
address owner = ownerOf(id);
require(isApprovedForAll(owner, msg.sender) || msg.sender == owner, "NOT_AUTHORIZED");
_tokenApprovals[id] = spender;
emit Approval(owner, spender, id);
}
/// @notice Approve or remove `operator` as an operator for the caller.
/// @dev Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
/// Emits an {ApprovalForAll} event.
/// @param operator The address of the operator to approve.
/// @param approved The status to set.
function setApprovalForAll(address operator, bool approved) public virtual {
_operatorApprovals[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
/// @notice Transfers `id` token from `from` to `to`.
/// WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function transferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function safeTransferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// Additionally passes `data` in the callback.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
/// @param data The calldata to pass in the {ERC721TokenReceiver-onERC721Received} callback.
function safeTransferFrom(
address from,
address to,
uint256 id,
bytes memory data
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Returns the number of tokens in an account.
/// @param owner The address to query.
/// @return The balance.
function balanceOf(address owner) public view virtual returns (uint256);
/// @notice Returns the owner of a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id The token ID.
function ownerOf(uint256 id) public view virtual returns (address);
/* -------------------------------------------------------------------------- */
/* INTERNAL LOGIC */
/* -------------------------------------------------------------------------- */
/// @dev Returns whether a token ID exists.
/// Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
/// Tokens start existing when they are minted.
/// @param id Token ID to query.
function _exists(uint256 id) internal view virtual returns (bool);
/// @dev Transfers `id` from `from` to `to`.
/// Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function _transfer(
address from,
address to,
uint256 id
) internal virtual;
/// @dev Mints `amount` tokens to `to`.
/// Requirements:
/// - there must be `amount` tokens remaining unminted in the total collection.
/// - `to` cannot be the zero address.
/// Emits `amount` {Transfer} events.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _mint(address to, uint256 amount) internal virtual;
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// If `to` is a contract it must implement {ERC721TokenReceiver.onERC721Received}
/// that returns {ERC721TokenReceiver.onERC721Received.selector}.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _safeMint(address to, uint256 amount) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// Requirements:
/// - `id` must not exist.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver.onERC721Received}, which is called upon a safe transfer.
/// Additionally passes `data` in the callback.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
/// @param data The calldata to pass in the {ERC721TokenReceiver.onERC721Received} callback.
function _safeMint(
address to,
uint256 amount,
bytes memory data
) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/* -------------------------------------------------------------------------- */
/* UTILS */
/* -------------------------------------------------------------------------- */
/// @notice Converts a `uint256` to its ASCII `string` decimal representation.
/// @dev https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Strings.sol
function toString(uint256 value) internal pure virtual returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
} | tokenURI | function tokenURI(uint256 id) public view virtual returns (string memory);
| /// @notice Returns the Uniform Resource Identifier (URI) for `id` token.
/// @param id The token ID.
/// @return The URI. | NatSpecSingleLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
3629,
3704
]
} | 6,012 |
||||
Mingoes | contracts/src/ERC721/ERC721.sol | 0xe6f475c11ad693e48455fcaf7bca33fe84ce71b0 | Solidity | ERC721 | abstract contract ERC721 {
/* -------------------------------------------------------------------------- */
/* EVENTS */
/* -------------------------------------------------------------------------- */
/// @dev Emitted when `id` token is transferred from `from` to `to`.
event Transfer(address indexed from, address indexed to, uint256 indexed id);
/// @dev Emitted when `owner` enables `approved` to manage the `id` token.
event Approval(address indexed owner, address indexed spender, uint256 indexed id);
/// @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/* -------------------------------------------------------------------------- */
/* METADATA STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev The collection name.
string private _name;
/// @dev The collection symbol.
string private _symbol;
/* -------------------------------------------------------------------------- */
/* ERC721 STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev ID => spender
mapping(uint256 => address) internal _tokenApprovals;
/// @dev owner => operator => approved
mapping(address => mapping(address => bool)) internal _operatorApprovals;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
/// @param name_ The collection name.
/// @param symbol_ The collection symbol.
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/* -------------------------------------------------------------------------- */
/* ERC165 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns true if this contract implements an interface from its ID.
/// @dev See the corresponding
/// [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
/// to learn more about how these IDs are created.
/// @return The implementation status.
function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool) {
return
interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721
interfaceId == 0x5b5e139f || // ERC165 Interface ID for ERC721Metadata
interfaceId == 0x780e9d63; // ERC165 Interface ID for ERC721Enumerable
}
/* -------------------------------------------------------------------------- */
/* METADATA LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the collection name.
/// @return The collection name.
function name() public view virtual returns (string memory) {
return _name;
}
/// @notice Returns the collection symbol.
/// @return The collection symbol.
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/// @notice Returns the Uniform Resource Identifier (URI) for `id` token.
/// @param id The token ID.
/// @return The URI.
function tokenURI(uint256 id) public view virtual returns (string memory);
/* -------------------------------------------------------------------------- */
/* ENUMERABLE LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the total amount of tokens stored by the contract.
/// @return The token supply.
function totalSupply() public view virtual returns (uint256);
/// @notice Returns a token ID owned by `owner` at a given `index` of its token list.
/// @dev Use along with {balanceOf} to enumerate all of `owner`'s tokens.
/// @param owner The address to query.
/// @param index The index to query.
/// @return The token ID.
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256);
/// @notice Returns a token ID at a given `index` of all the tokens stored by the contract.
/// @dev Use along with {totalSupply} to enumerate all tokens.
/// @param index The index to query.
/// @return The token ID.
function tokenByIndex(uint256 index) public view virtual returns (uint256);
/* -------------------------------------------------------------------------- */
/* ERC721 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the account approved for a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id Token ID to query.
/// @return The account approved for `id` token.
function getApproved(uint256 id) public virtual returns (address) {
require(_exists(id), "NONEXISTENT_TOKEN");
return _tokenApprovals[id];
}
/// @notice Returns if the `operator` is allowed to manage all of the assets of `owner`.
/// @param owner The address of the owner.
/// @param operator The address of the operator.
/// @return True if `operator` was approved by `owner`.
function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
return _operatorApprovals[owner][operator];
}
/// @notice Gives permission to `to` to transfer `id` token to another account.
/// @dev The approval is cleared when the token is transferred.
/// Only a single account can be approved at a time, so approving the zero address clears previous approvals.
/// Requirements:
/// - The caller must own the token or be an approved operator.
/// - `id` must exist.
/// Emits an {Approval} event.
/// @param spender The address of the spender to approve to.
/// @param id The token ID to approve.
function approve(address spender, uint256 id) public virtual {
address owner = ownerOf(id);
require(isApprovedForAll(owner, msg.sender) || msg.sender == owner, "NOT_AUTHORIZED");
_tokenApprovals[id] = spender;
emit Approval(owner, spender, id);
}
/// @notice Approve or remove `operator` as an operator for the caller.
/// @dev Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
/// Emits an {ApprovalForAll} event.
/// @param operator The address of the operator to approve.
/// @param approved The status to set.
function setApprovalForAll(address operator, bool approved) public virtual {
_operatorApprovals[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
/// @notice Transfers `id` token from `from` to `to`.
/// WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function transferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function safeTransferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// Additionally passes `data` in the callback.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
/// @param data The calldata to pass in the {ERC721TokenReceiver-onERC721Received} callback.
function safeTransferFrom(
address from,
address to,
uint256 id,
bytes memory data
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Returns the number of tokens in an account.
/// @param owner The address to query.
/// @return The balance.
function balanceOf(address owner) public view virtual returns (uint256);
/// @notice Returns the owner of a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id The token ID.
function ownerOf(uint256 id) public view virtual returns (address);
/* -------------------------------------------------------------------------- */
/* INTERNAL LOGIC */
/* -------------------------------------------------------------------------- */
/// @dev Returns whether a token ID exists.
/// Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
/// Tokens start existing when they are minted.
/// @param id Token ID to query.
function _exists(uint256 id) internal view virtual returns (bool);
/// @dev Transfers `id` from `from` to `to`.
/// Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function _transfer(
address from,
address to,
uint256 id
) internal virtual;
/// @dev Mints `amount` tokens to `to`.
/// Requirements:
/// - there must be `amount` tokens remaining unminted in the total collection.
/// - `to` cannot be the zero address.
/// Emits `amount` {Transfer} events.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _mint(address to, uint256 amount) internal virtual;
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// If `to` is a contract it must implement {ERC721TokenReceiver.onERC721Received}
/// that returns {ERC721TokenReceiver.onERC721Received.selector}.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _safeMint(address to, uint256 amount) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// Requirements:
/// - `id` must not exist.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver.onERC721Received}, which is called upon a safe transfer.
/// Additionally passes `data` in the callback.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
/// @param data The calldata to pass in the {ERC721TokenReceiver.onERC721Received} callback.
function _safeMint(
address to,
uint256 amount,
bytes memory data
) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/* -------------------------------------------------------------------------- */
/* UTILS */
/* -------------------------------------------------------------------------- */
/// @notice Converts a `uint256` to its ASCII `string` decimal representation.
/// @dev https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Strings.sol
function toString(uint256 value) internal pure virtual returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
} | totalSupply | function totalSupply() public view virtual returns (uint256);
| /// @notice Returns the total amount of tokens stored by the contract.
/// @return The token supply. | NatSpecSingleLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
4056,
4118
]
} | 6,013 |
||||
Mingoes | contracts/src/ERC721/ERC721.sol | 0xe6f475c11ad693e48455fcaf7bca33fe84ce71b0 | Solidity | ERC721 | abstract contract ERC721 {
/* -------------------------------------------------------------------------- */
/* EVENTS */
/* -------------------------------------------------------------------------- */
/// @dev Emitted when `id` token is transferred from `from` to `to`.
event Transfer(address indexed from, address indexed to, uint256 indexed id);
/// @dev Emitted when `owner` enables `approved` to manage the `id` token.
event Approval(address indexed owner, address indexed spender, uint256 indexed id);
/// @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/* -------------------------------------------------------------------------- */
/* METADATA STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev The collection name.
string private _name;
/// @dev The collection symbol.
string private _symbol;
/* -------------------------------------------------------------------------- */
/* ERC721 STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev ID => spender
mapping(uint256 => address) internal _tokenApprovals;
/// @dev owner => operator => approved
mapping(address => mapping(address => bool)) internal _operatorApprovals;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
/// @param name_ The collection name.
/// @param symbol_ The collection symbol.
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/* -------------------------------------------------------------------------- */
/* ERC165 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns true if this contract implements an interface from its ID.
/// @dev See the corresponding
/// [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
/// to learn more about how these IDs are created.
/// @return The implementation status.
function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool) {
return
interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721
interfaceId == 0x5b5e139f || // ERC165 Interface ID for ERC721Metadata
interfaceId == 0x780e9d63; // ERC165 Interface ID for ERC721Enumerable
}
/* -------------------------------------------------------------------------- */
/* METADATA LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the collection name.
/// @return The collection name.
function name() public view virtual returns (string memory) {
return _name;
}
/// @notice Returns the collection symbol.
/// @return The collection symbol.
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/// @notice Returns the Uniform Resource Identifier (URI) for `id` token.
/// @param id The token ID.
/// @return The URI.
function tokenURI(uint256 id) public view virtual returns (string memory);
/* -------------------------------------------------------------------------- */
/* ENUMERABLE LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the total amount of tokens stored by the contract.
/// @return The token supply.
function totalSupply() public view virtual returns (uint256);
/// @notice Returns a token ID owned by `owner` at a given `index` of its token list.
/// @dev Use along with {balanceOf} to enumerate all of `owner`'s tokens.
/// @param owner The address to query.
/// @param index The index to query.
/// @return The token ID.
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256);
/// @notice Returns a token ID at a given `index` of all the tokens stored by the contract.
/// @dev Use along with {totalSupply} to enumerate all tokens.
/// @param index The index to query.
/// @return The token ID.
function tokenByIndex(uint256 index) public view virtual returns (uint256);
/* -------------------------------------------------------------------------- */
/* ERC721 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the account approved for a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id Token ID to query.
/// @return The account approved for `id` token.
function getApproved(uint256 id) public virtual returns (address) {
require(_exists(id), "NONEXISTENT_TOKEN");
return _tokenApprovals[id];
}
/// @notice Returns if the `operator` is allowed to manage all of the assets of `owner`.
/// @param owner The address of the owner.
/// @param operator The address of the operator.
/// @return True if `operator` was approved by `owner`.
function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
return _operatorApprovals[owner][operator];
}
/// @notice Gives permission to `to` to transfer `id` token to another account.
/// @dev The approval is cleared when the token is transferred.
/// Only a single account can be approved at a time, so approving the zero address clears previous approvals.
/// Requirements:
/// - The caller must own the token or be an approved operator.
/// - `id` must exist.
/// Emits an {Approval} event.
/// @param spender The address of the spender to approve to.
/// @param id The token ID to approve.
function approve(address spender, uint256 id) public virtual {
address owner = ownerOf(id);
require(isApprovedForAll(owner, msg.sender) || msg.sender == owner, "NOT_AUTHORIZED");
_tokenApprovals[id] = spender;
emit Approval(owner, spender, id);
}
/// @notice Approve or remove `operator` as an operator for the caller.
/// @dev Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
/// Emits an {ApprovalForAll} event.
/// @param operator The address of the operator to approve.
/// @param approved The status to set.
function setApprovalForAll(address operator, bool approved) public virtual {
_operatorApprovals[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
/// @notice Transfers `id` token from `from` to `to`.
/// WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function transferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function safeTransferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// Additionally passes `data` in the callback.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
/// @param data The calldata to pass in the {ERC721TokenReceiver-onERC721Received} callback.
function safeTransferFrom(
address from,
address to,
uint256 id,
bytes memory data
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Returns the number of tokens in an account.
/// @param owner The address to query.
/// @return The balance.
function balanceOf(address owner) public view virtual returns (uint256);
/// @notice Returns the owner of a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id The token ID.
function ownerOf(uint256 id) public view virtual returns (address);
/* -------------------------------------------------------------------------- */
/* INTERNAL LOGIC */
/* -------------------------------------------------------------------------- */
/// @dev Returns whether a token ID exists.
/// Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
/// Tokens start existing when they are minted.
/// @param id Token ID to query.
function _exists(uint256 id) internal view virtual returns (bool);
/// @dev Transfers `id` from `from` to `to`.
/// Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function _transfer(
address from,
address to,
uint256 id
) internal virtual;
/// @dev Mints `amount` tokens to `to`.
/// Requirements:
/// - there must be `amount` tokens remaining unminted in the total collection.
/// - `to` cannot be the zero address.
/// Emits `amount` {Transfer} events.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _mint(address to, uint256 amount) internal virtual;
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// If `to` is a contract it must implement {ERC721TokenReceiver.onERC721Received}
/// that returns {ERC721TokenReceiver.onERC721Received.selector}.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _safeMint(address to, uint256 amount) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// Requirements:
/// - `id` must not exist.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver.onERC721Received}, which is called upon a safe transfer.
/// Additionally passes `data` in the callback.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
/// @param data The calldata to pass in the {ERC721TokenReceiver.onERC721Received} callback.
function _safeMint(
address to,
uint256 amount,
bytes memory data
) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/* -------------------------------------------------------------------------- */
/* UTILS */
/* -------------------------------------------------------------------------- */
/// @notice Converts a `uint256` to its ASCII `string` decimal representation.
/// @dev https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Strings.sol
function toString(uint256 value) internal pure virtual returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
} | tokenOfOwnerByIndex | function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256);
| /// @notice Returns a token ID owned by `owner` at a given `index` of its token list.
/// @dev Use along with {balanceOf} to enumerate all of `owner`'s tokens.
/// @param owner The address to query.
/// @param index The index to query.
/// @return The token ID. | NatSpecSingleLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
4387,
4485
]
} | 6,014 |
||||
Mingoes | contracts/src/ERC721/ERC721.sol | 0xe6f475c11ad693e48455fcaf7bca33fe84ce71b0 | Solidity | ERC721 | abstract contract ERC721 {
/* -------------------------------------------------------------------------- */
/* EVENTS */
/* -------------------------------------------------------------------------- */
/// @dev Emitted when `id` token is transferred from `from` to `to`.
event Transfer(address indexed from, address indexed to, uint256 indexed id);
/// @dev Emitted when `owner` enables `approved` to manage the `id` token.
event Approval(address indexed owner, address indexed spender, uint256 indexed id);
/// @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/* -------------------------------------------------------------------------- */
/* METADATA STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev The collection name.
string private _name;
/// @dev The collection symbol.
string private _symbol;
/* -------------------------------------------------------------------------- */
/* ERC721 STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev ID => spender
mapping(uint256 => address) internal _tokenApprovals;
/// @dev owner => operator => approved
mapping(address => mapping(address => bool)) internal _operatorApprovals;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
/// @param name_ The collection name.
/// @param symbol_ The collection symbol.
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/* -------------------------------------------------------------------------- */
/* ERC165 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns true if this contract implements an interface from its ID.
/// @dev See the corresponding
/// [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
/// to learn more about how these IDs are created.
/// @return The implementation status.
function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool) {
return
interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721
interfaceId == 0x5b5e139f || // ERC165 Interface ID for ERC721Metadata
interfaceId == 0x780e9d63; // ERC165 Interface ID for ERC721Enumerable
}
/* -------------------------------------------------------------------------- */
/* METADATA LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the collection name.
/// @return The collection name.
function name() public view virtual returns (string memory) {
return _name;
}
/// @notice Returns the collection symbol.
/// @return The collection symbol.
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/// @notice Returns the Uniform Resource Identifier (URI) for `id` token.
/// @param id The token ID.
/// @return The URI.
function tokenURI(uint256 id) public view virtual returns (string memory);
/* -------------------------------------------------------------------------- */
/* ENUMERABLE LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the total amount of tokens stored by the contract.
/// @return The token supply.
function totalSupply() public view virtual returns (uint256);
/// @notice Returns a token ID owned by `owner` at a given `index` of its token list.
/// @dev Use along with {balanceOf} to enumerate all of `owner`'s tokens.
/// @param owner The address to query.
/// @param index The index to query.
/// @return The token ID.
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256);
/// @notice Returns a token ID at a given `index` of all the tokens stored by the contract.
/// @dev Use along with {totalSupply} to enumerate all tokens.
/// @param index The index to query.
/// @return The token ID.
function tokenByIndex(uint256 index) public view virtual returns (uint256);
/* -------------------------------------------------------------------------- */
/* ERC721 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the account approved for a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id Token ID to query.
/// @return The account approved for `id` token.
function getApproved(uint256 id) public virtual returns (address) {
require(_exists(id), "NONEXISTENT_TOKEN");
return _tokenApprovals[id];
}
/// @notice Returns if the `operator` is allowed to manage all of the assets of `owner`.
/// @param owner The address of the owner.
/// @param operator The address of the operator.
/// @return True if `operator` was approved by `owner`.
function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
return _operatorApprovals[owner][operator];
}
/// @notice Gives permission to `to` to transfer `id` token to another account.
/// @dev The approval is cleared when the token is transferred.
/// Only a single account can be approved at a time, so approving the zero address clears previous approvals.
/// Requirements:
/// - The caller must own the token or be an approved operator.
/// - `id` must exist.
/// Emits an {Approval} event.
/// @param spender The address of the spender to approve to.
/// @param id The token ID to approve.
function approve(address spender, uint256 id) public virtual {
address owner = ownerOf(id);
require(isApprovedForAll(owner, msg.sender) || msg.sender == owner, "NOT_AUTHORIZED");
_tokenApprovals[id] = spender;
emit Approval(owner, spender, id);
}
/// @notice Approve or remove `operator` as an operator for the caller.
/// @dev Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
/// Emits an {ApprovalForAll} event.
/// @param operator The address of the operator to approve.
/// @param approved The status to set.
function setApprovalForAll(address operator, bool approved) public virtual {
_operatorApprovals[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
/// @notice Transfers `id` token from `from` to `to`.
/// WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function transferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function safeTransferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// Additionally passes `data` in the callback.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
/// @param data The calldata to pass in the {ERC721TokenReceiver-onERC721Received} callback.
function safeTransferFrom(
address from,
address to,
uint256 id,
bytes memory data
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Returns the number of tokens in an account.
/// @param owner The address to query.
/// @return The balance.
function balanceOf(address owner) public view virtual returns (uint256);
/// @notice Returns the owner of a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id The token ID.
function ownerOf(uint256 id) public view virtual returns (address);
/* -------------------------------------------------------------------------- */
/* INTERNAL LOGIC */
/* -------------------------------------------------------------------------- */
/// @dev Returns whether a token ID exists.
/// Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
/// Tokens start existing when they are minted.
/// @param id Token ID to query.
function _exists(uint256 id) internal view virtual returns (bool);
/// @dev Transfers `id` from `from` to `to`.
/// Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function _transfer(
address from,
address to,
uint256 id
) internal virtual;
/// @dev Mints `amount` tokens to `to`.
/// Requirements:
/// - there must be `amount` tokens remaining unminted in the total collection.
/// - `to` cannot be the zero address.
/// Emits `amount` {Transfer} events.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _mint(address to, uint256 amount) internal virtual;
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// If `to` is a contract it must implement {ERC721TokenReceiver.onERC721Received}
/// that returns {ERC721TokenReceiver.onERC721Received.selector}.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _safeMint(address to, uint256 amount) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// Requirements:
/// - `id` must not exist.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver.onERC721Received}, which is called upon a safe transfer.
/// Additionally passes `data` in the callback.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
/// @param data The calldata to pass in the {ERC721TokenReceiver.onERC721Received} callback.
function _safeMint(
address to,
uint256 amount,
bytes memory data
) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/* -------------------------------------------------------------------------- */
/* UTILS */
/* -------------------------------------------------------------------------- */
/// @notice Converts a `uint256` to its ASCII `string` decimal representation.
/// @dev https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Strings.sol
function toString(uint256 value) internal pure virtual returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
} | tokenByIndex | function tokenByIndex(uint256 index) public view virtual returns (uint256);
| /// @notice Returns a token ID at a given `index` of all the tokens stored by the contract.
/// @dev Use along with {totalSupply} to enumerate all tokens.
/// @param index The index to query.
/// @return The token ID. | NatSpecSingleLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
4709,
4785
]
} | 6,015 |
||||
Mingoes | contracts/src/ERC721/ERC721.sol | 0xe6f475c11ad693e48455fcaf7bca33fe84ce71b0 | Solidity | ERC721 | abstract contract ERC721 {
/* -------------------------------------------------------------------------- */
/* EVENTS */
/* -------------------------------------------------------------------------- */
/// @dev Emitted when `id` token is transferred from `from` to `to`.
event Transfer(address indexed from, address indexed to, uint256 indexed id);
/// @dev Emitted when `owner` enables `approved` to manage the `id` token.
event Approval(address indexed owner, address indexed spender, uint256 indexed id);
/// @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/* -------------------------------------------------------------------------- */
/* METADATA STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev The collection name.
string private _name;
/// @dev The collection symbol.
string private _symbol;
/* -------------------------------------------------------------------------- */
/* ERC721 STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev ID => spender
mapping(uint256 => address) internal _tokenApprovals;
/// @dev owner => operator => approved
mapping(address => mapping(address => bool)) internal _operatorApprovals;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
/// @param name_ The collection name.
/// @param symbol_ The collection symbol.
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/* -------------------------------------------------------------------------- */
/* ERC165 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns true if this contract implements an interface from its ID.
/// @dev See the corresponding
/// [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
/// to learn more about how these IDs are created.
/// @return The implementation status.
function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool) {
return
interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721
interfaceId == 0x5b5e139f || // ERC165 Interface ID for ERC721Metadata
interfaceId == 0x780e9d63; // ERC165 Interface ID for ERC721Enumerable
}
/* -------------------------------------------------------------------------- */
/* METADATA LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the collection name.
/// @return The collection name.
function name() public view virtual returns (string memory) {
return _name;
}
/// @notice Returns the collection symbol.
/// @return The collection symbol.
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/// @notice Returns the Uniform Resource Identifier (URI) for `id` token.
/// @param id The token ID.
/// @return The URI.
function tokenURI(uint256 id) public view virtual returns (string memory);
/* -------------------------------------------------------------------------- */
/* ENUMERABLE LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the total amount of tokens stored by the contract.
/// @return The token supply.
function totalSupply() public view virtual returns (uint256);
/// @notice Returns a token ID owned by `owner` at a given `index` of its token list.
/// @dev Use along with {balanceOf} to enumerate all of `owner`'s tokens.
/// @param owner The address to query.
/// @param index The index to query.
/// @return The token ID.
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256);
/// @notice Returns a token ID at a given `index` of all the tokens stored by the contract.
/// @dev Use along with {totalSupply} to enumerate all tokens.
/// @param index The index to query.
/// @return The token ID.
function tokenByIndex(uint256 index) public view virtual returns (uint256);
/* -------------------------------------------------------------------------- */
/* ERC721 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the account approved for a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id Token ID to query.
/// @return The account approved for `id` token.
function getApproved(uint256 id) public virtual returns (address) {
require(_exists(id), "NONEXISTENT_TOKEN");
return _tokenApprovals[id];
}
/// @notice Returns if the `operator` is allowed to manage all of the assets of `owner`.
/// @param owner The address of the owner.
/// @param operator The address of the operator.
/// @return True if `operator` was approved by `owner`.
function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
return _operatorApprovals[owner][operator];
}
/// @notice Gives permission to `to` to transfer `id` token to another account.
/// @dev The approval is cleared when the token is transferred.
/// Only a single account can be approved at a time, so approving the zero address clears previous approvals.
/// Requirements:
/// - The caller must own the token or be an approved operator.
/// - `id` must exist.
/// Emits an {Approval} event.
/// @param spender The address of the spender to approve to.
/// @param id The token ID to approve.
function approve(address spender, uint256 id) public virtual {
address owner = ownerOf(id);
require(isApprovedForAll(owner, msg.sender) || msg.sender == owner, "NOT_AUTHORIZED");
_tokenApprovals[id] = spender;
emit Approval(owner, spender, id);
}
/// @notice Approve or remove `operator` as an operator for the caller.
/// @dev Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
/// Emits an {ApprovalForAll} event.
/// @param operator The address of the operator to approve.
/// @param approved The status to set.
function setApprovalForAll(address operator, bool approved) public virtual {
_operatorApprovals[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
/// @notice Transfers `id` token from `from` to `to`.
/// WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function transferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function safeTransferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// Additionally passes `data` in the callback.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
/// @param data The calldata to pass in the {ERC721TokenReceiver-onERC721Received} callback.
function safeTransferFrom(
address from,
address to,
uint256 id,
bytes memory data
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Returns the number of tokens in an account.
/// @param owner The address to query.
/// @return The balance.
function balanceOf(address owner) public view virtual returns (uint256);
/// @notice Returns the owner of a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id The token ID.
function ownerOf(uint256 id) public view virtual returns (address);
/* -------------------------------------------------------------------------- */
/* INTERNAL LOGIC */
/* -------------------------------------------------------------------------- */
/// @dev Returns whether a token ID exists.
/// Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
/// Tokens start existing when they are minted.
/// @param id Token ID to query.
function _exists(uint256 id) internal view virtual returns (bool);
/// @dev Transfers `id` from `from` to `to`.
/// Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function _transfer(
address from,
address to,
uint256 id
) internal virtual;
/// @dev Mints `amount` tokens to `to`.
/// Requirements:
/// - there must be `amount` tokens remaining unminted in the total collection.
/// - `to` cannot be the zero address.
/// Emits `amount` {Transfer} events.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _mint(address to, uint256 amount) internal virtual;
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// If `to` is a contract it must implement {ERC721TokenReceiver.onERC721Received}
/// that returns {ERC721TokenReceiver.onERC721Received.selector}.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _safeMint(address to, uint256 amount) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// Requirements:
/// - `id` must not exist.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver.onERC721Received}, which is called upon a safe transfer.
/// Additionally passes `data` in the callback.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
/// @param data The calldata to pass in the {ERC721TokenReceiver.onERC721Received} callback.
function _safeMint(
address to,
uint256 amount,
bytes memory data
) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/* -------------------------------------------------------------------------- */
/* UTILS */
/* -------------------------------------------------------------------------- */
/// @notice Converts a `uint256` to its ASCII `string` decimal representation.
/// @dev https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Strings.sol
function toString(uint256 value) internal pure virtual returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
} | getApproved | function getApproved(uint256 id) public virtual returns (address) {
require(_exists(id), "NONEXISTENT_TOKEN");
return _tokenApprovals[id];
}
| /// @notice Returns the account approved for a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id Token ID to query.
/// @return The account approved for `id` token. | NatSpecSingleLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
5224,
5370
]
} | 6,016 |
||||
Mingoes | contracts/src/ERC721/ERC721.sol | 0xe6f475c11ad693e48455fcaf7bca33fe84ce71b0 | Solidity | ERC721 | abstract contract ERC721 {
/* -------------------------------------------------------------------------- */
/* EVENTS */
/* -------------------------------------------------------------------------- */
/// @dev Emitted when `id` token is transferred from `from` to `to`.
event Transfer(address indexed from, address indexed to, uint256 indexed id);
/// @dev Emitted when `owner` enables `approved` to manage the `id` token.
event Approval(address indexed owner, address indexed spender, uint256 indexed id);
/// @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/* -------------------------------------------------------------------------- */
/* METADATA STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev The collection name.
string private _name;
/// @dev The collection symbol.
string private _symbol;
/* -------------------------------------------------------------------------- */
/* ERC721 STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev ID => spender
mapping(uint256 => address) internal _tokenApprovals;
/// @dev owner => operator => approved
mapping(address => mapping(address => bool)) internal _operatorApprovals;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
/// @param name_ The collection name.
/// @param symbol_ The collection symbol.
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/* -------------------------------------------------------------------------- */
/* ERC165 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns true if this contract implements an interface from its ID.
/// @dev See the corresponding
/// [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
/// to learn more about how these IDs are created.
/// @return The implementation status.
function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool) {
return
interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721
interfaceId == 0x5b5e139f || // ERC165 Interface ID for ERC721Metadata
interfaceId == 0x780e9d63; // ERC165 Interface ID for ERC721Enumerable
}
/* -------------------------------------------------------------------------- */
/* METADATA LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the collection name.
/// @return The collection name.
function name() public view virtual returns (string memory) {
return _name;
}
/// @notice Returns the collection symbol.
/// @return The collection symbol.
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/// @notice Returns the Uniform Resource Identifier (URI) for `id` token.
/// @param id The token ID.
/// @return The URI.
function tokenURI(uint256 id) public view virtual returns (string memory);
/* -------------------------------------------------------------------------- */
/* ENUMERABLE LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the total amount of tokens stored by the contract.
/// @return The token supply.
function totalSupply() public view virtual returns (uint256);
/// @notice Returns a token ID owned by `owner` at a given `index` of its token list.
/// @dev Use along with {balanceOf} to enumerate all of `owner`'s tokens.
/// @param owner The address to query.
/// @param index The index to query.
/// @return The token ID.
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256);
/// @notice Returns a token ID at a given `index` of all the tokens stored by the contract.
/// @dev Use along with {totalSupply} to enumerate all tokens.
/// @param index The index to query.
/// @return The token ID.
function tokenByIndex(uint256 index) public view virtual returns (uint256);
/* -------------------------------------------------------------------------- */
/* ERC721 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the account approved for a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id Token ID to query.
/// @return The account approved for `id` token.
function getApproved(uint256 id) public virtual returns (address) {
require(_exists(id), "NONEXISTENT_TOKEN");
return _tokenApprovals[id];
}
/// @notice Returns if the `operator` is allowed to manage all of the assets of `owner`.
/// @param owner The address of the owner.
/// @param operator The address of the operator.
/// @return True if `operator` was approved by `owner`.
function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
return _operatorApprovals[owner][operator];
}
/// @notice Gives permission to `to` to transfer `id` token to another account.
/// @dev The approval is cleared when the token is transferred.
/// Only a single account can be approved at a time, so approving the zero address clears previous approvals.
/// Requirements:
/// - The caller must own the token or be an approved operator.
/// - `id` must exist.
/// Emits an {Approval} event.
/// @param spender The address of the spender to approve to.
/// @param id The token ID to approve.
function approve(address spender, uint256 id) public virtual {
address owner = ownerOf(id);
require(isApprovedForAll(owner, msg.sender) || msg.sender == owner, "NOT_AUTHORIZED");
_tokenApprovals[id] = spender;
emit Approval(owner, spender, id);
}
/// @notice Approve or remove `operator` as an operator for the caller.
/// @dev Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
/// Emits an {ApprovalForAll} event.
/// @param operator The address of the operator to approve.
/// @param approved The status to set.
function setApprovalForAll(address operator, bool approved) public virtual {
_operatorApprovals[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
/// @notice Transfers `id` token from `from` to `to`.
/// WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function transferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function safeTransferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// Additionally passes `data` in the callback.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
/// @param data The calldata to pass in the {ERC721TokenReceiver-onERC721Received} callback.
function safeTransferFrom(
address from,
address to,
uint256 id,
bytes memory data
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Returns the number of tokens in an account.
/// @param owner The address to query.
/// @return The balance.
function balanceOf(address owner) public view virtual returns (uint256);
/// @notice Returns the owner of a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id The token ID.
function ownerOf(uint256 id) public view virtual returns (address);
/* -------------------------------------------------------------------------- */
/* INTERNAL LOGIC */
/* -------------------------------------------------------------------------- */
/// @dev Returns whether a token ID exists.
/// Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
/// Tokens start existing when they are minted.
/// @param id Token ID to query.
function _exists(uint256 id) internal view virtual returns (bool);
/// @dev Transfers `id` from `from` to `to`.
/// Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function _transfer(
address from,
address to,
uint256 id
) internal virtual;
/// @dev Mints `amount` tokens to `to`.
/// Requirements:
/// - there must be `amount` tokens remaining unminted in the total collection.
/// - `to` cannot be the zero address.
/// Emits `amount` {Transfer} events.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _mint(address to, uint256 amount) internal virtual;
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// If `to` is a contract it must implement {ERC721TokenReceiver.onERC721Received}
/// that returns {ERC721TokenReceiver.onERC721Received.selector}.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _safeMint(address to, uint256 amount) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// Requirements:
/// - `id` must not exist.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver.onERC721Received}, which is called upon a safe transfer.
/// Additionally passes `data` in the callback.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
/// @param data The calldata to pass in the {ERC721TokenReceiver.onERC721Received} callback.
function _safeMint(
address to,
uint256 amount,
bytes memory data
) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/* -------------------------------------------------------------------------- */
/* UTILS */
/* -------------------------------------------------------------------------- */
/// @notice Converts a `uint256` to its ASCII `string` decimal representation.
/// @dev https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Strings.sol
function toString(uint256 value) internal pure virtual returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
} | isApprovedForAll | function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
return _operatorApprovals[owner][operator];
}
| /// @notice Returns if the `operator` is allowed to manage all of the assets of `owner`.
/// @param owner The address of the owner.
/// @param operator The address of the operator.
/// @return True if `operator` was approved by `owner`. | NatSpecSingleLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
5613,
5758
]
} | 6,017 |
||||
Mingoes | contracts/src/ERC721/ERC721.sol | 0xe6f475c11ad693e48455fcaf7bca33fe84ce71b0 | Solidity | ERC721 | abstract contract ERC721 {
/* -------------------------------------------------------------------------- */
/* EVENTS */
/* -------------------------------------------------------------------------- */
/// @dev Emitted when `id` token is transferred from `from` to `to`.
event Transfer(address indexed from, address indexed to, uint256 indexed id);
/// @dev Emitted when `owner` enables `approved` to manage the `id` token.
event Approval(address indexed owner, address indexed spender, uint256 indexed id);
/// @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/* -------------------------------------------------------------------------- */
/* METADATA STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev The collection name.
string private _name;
/// @dev The collection symbol.
string private _symbol;
/* -------------------------------------------------------------------------- */
/* ERC721 STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev ID => spender
mapping(uint256 => address) internal _tokenApprovals;
/// @dev owner => operator => approved
mapping(address => mapping(address => bool)) internal _operatorApprovals;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
/// @param name_ The collection name.
/// @param symbol_ The collection symbol.
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/* -------------------------------------------------------------------------- */
/* ERC165 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns true if this contract implements an interface from its ID.
/// @dev See the corresponding
/// [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
/// to learn more about how these IDs are created.
/// @return The implementation status.
function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool) {
return
interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721
interfaceId == 0x5b5e139f || // ERC165 Interface ID for ERC721Metadata
interfaceId == 0x780e9d63; // ERC165 Interface ID for ERC721Enumerable
}
/* -------------------------------------------------------------------------- */
/* METADATA LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the collection name.
/// @return The collection name.
function name() public view virtual returns (string memory) {
return _name;
}
/// @notice Returns the collection symbol.
/// @return The collection symbol.
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/// @notice Returns the Uniform Resource Identifier (URI) for `id` token.
/// @param id The token ID.
/// @return The URI.
function tokenURI(uint256 id) public view virtual returns (string memory);
/* -------------------------------------------------------------------------- */
/* ENUMERABLE LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the total amount of tokens stored by the contract.
/// @return The token supply.
function totalSupply() public view virtual returns (uint256);
/// @notice Returns a token ID owned by `owner` at a given `index` of its token list.
/// @dev Use along with {balanceOf} to enumerate all of `owner`'s tokens.
/// @param owner The address to query.
/// @param index The index to query.
/// @return The token ID.
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256);
/// @notice Returns a token ID at a given `index` of all the tokens stored by the contract.
/// @dev Use along with {totalSupply} to enumerate all tokens.
/// @param index The index to query.
/// @return The token ID.
function tokenByIndex(uint256 index) public view virtual returns (uint256);
/* -------------------------------------------------------------------------- */
/* ERC721 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the account approved for a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id Token ID to query.
/// @return The account approved for `id` token.
function getApproved(uint256 id) public virtual returns (address) {
require(_exists(id), "NONEXISTENT_TOKEN");
return _tokenApprovals[id];
}
/// @notice Returns if the `operator` is allowed to manage all of the assets of `owner`.
/// @param owner The address of the owner.
/// @param operator The address of the operator.
/// @return True if `operator` was approved by `owner`.
function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
return _operatorApprovals[owner][operator];
}
/// @notice Gives permission to `to` to transfer `id` token to another account.
/// @dev The approval is cleared when the token is transferred.
/// Only a single account can be approved at a time, so approving the zero address clears previous approvals.
/// Requirements:
/// - The caller must own the token or be an approved operator.
/// - `id` must exist.
/// Emits an {Approval} event.
/// @param spender The address of the spender to approve to.
/// @param id The token ID to approve.
function approve(address spender, uint256 id) public virtual {
address owner = ownerOf(id);
require(isApprovedForAll(owner, msg.sender) || msg.sender == owner, "NOT_AUTHORIZED");
_tokenApprovals[id] = spender;
emit Approval(owner, spender, id);
}
/// @notice Approve or remove `operator` as an operator for the caller.
/// @dev Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
/// Emits an {ApprovalForAll} event.
/// @param operator The address of the operator to approve.
/// @param approved The status to set.
function setApprovalForAll(address operator, bool approved) public virtual {
_operatorApprovals[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
/// @notice Transfers `id` token from `from` to `to`.
/// WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function transferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function safeTransferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// Additionally passes `data` in the callback.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
/// @param data The calldata to pass in the {ERC721TokenReceiver-onERC721Received} callback.
function safeTransferFrom(
address from,
address to,
uint256 id,
bytes memory data
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Returns the number of tokens in an account.
/// @param owner The address to query.
/// @return The balance.
function balanceOf(address owner) public view virtual returns (uint256);
/// @notice Returns the owner of a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id The token ID.
function ownerOf(uint256 id) public view virtual returns (address);
/* -------------------------------------------------------------------------- */
/* INTERNAL LOGIC */
/* -------------------------------------------------------------------------- */
/// @dev Returns whether a token ID exists.
/// Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
/// Tokens start existing when they are minted.
/// @param id Token ID to query.
function _exists(uint256 id) internal view virtual returns (bool);
/// @dev Transfers `id` from `from` to `to`.
/// Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function _transfer(
address from,
address to,
uint256 id
) internal virtual;
/// @dev Mints `amount` tokens to `to`.
/// Requirements:
/// - there must be `amount` tokens remaining unminted in the total collection.
/// - `to` cannot be the zero address.
/// Emits `amount` {Transfer} events.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _mint(address to, uint256 amount) internal virtual;
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// If `to` is a contract it must implement {ERC721TokenReceiver.onERC721Received}
/// that returns {ERC721TokenReceiver.onERC721Received.selector}.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _safeMint(address to, uint256 amount) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// Requirements:
/// - `id` must not exist.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver.onERC721Received}, which is called upon a safe transfer.
/// Additionally passes `data` in the callback.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
/// @param data The calldata to pass in the {ERC721TokenReceiver.onERC721Received} callback.
function _safeMint(
address to,
uint256 amount,
bytes memory data
) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/* -------------------------------------------------------------------------- */
/* UTILS */
/* -------------------------------------------------------------------------- */
/// @notice Converts a `uint256` to its ASCII `string` decimal representation.
/// @dev https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Strings.sol
function toString(uint256 value) internal pure virtual returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
} | approve | function approve(address spender, uint256 id) public virtual {
address owner = ownerOf(id);
require(isApprovedForAll(owner, msg.sender) || msg.sender == owner, "NOT_AUTHORIZED");
_tokenApprovals[id] = spender;
emit Approval(owner, spender, id);
}
| /// @notice Gives permission to `to` to transfer `id` token to another account.
/// @dev The approval is cleared when the token is transferred.
/// Only a single account can be approved at a time, so approving the zero address clears previous approvals.
/// Requirements:
/// - The caller must own the token or be an approved operator.
/// - `id` must exist.
/// Emits an {Approval} event.
/// @param spender The address of the spender to approve to.
/// @param id The token ID to approve. | NatSpecSingleLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
6259,
6518
]
} | 6,018 |
||||
Mingoes | contracts/src/ERC721/ERC721.sol | 0xe6f475c11ad693e48455fcaf7bca33fe84ce71b0 | Solidity | ERC721 | abstract contract ERC721 {
/* -------------------------------------------------------------------------- */
/* EVENTS */
/* -------------------------------------------------------------------------- */
/// @dev Emitted when `id` token is transferred from `from` to `to`.
event Transfer(address indexed from, address indexed to, uint256 indexed id);
/// @dev Emitted when `owner` enables `approved` to manage the `id` token.
event Approval(address indexed owner, address indexed spender, uint256 indexed id);
/// @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/* -------------------------------------------------------------------------- */
/* METADATA STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev The collection name.
string private _name;
/// @dev The collection symbol.
string private _symbol;
/* -------------------------------------------------------------------------- */
/* ERC721 STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev ID => spender
mapping(uint256 => address) internal _tokenApprovals;
/// @dev owner => operator => approved
mapping(address => mapping(address => bool)) internal _operatorApprovals;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
/// @param name_ The collection name.
/// @param symbol_ The collection symbol.
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/* -------------------------------------------------------------------------- */
/* ERC165 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns true if this contract implements an interface from its ID.
/// @dev See the corresponding
/// [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
/// to learn more about how these IDs are created.
/// @return The implementation status.
function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool) {
return
interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721
interfaceId == 0x5b5e139f || // ERC165 Interface ID for ERC721Metadata
interfaceId == 0x780e9d63; // ERC165 Interface ID for ERC721Enumerable
}
/* -------------------------------------------------------------------------- */
/* METADATA LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the collection name.
/// @return The collection name.
function name() public view virtual returns (string memory) {
return _name;
}
/// @notice Returns the collection symbol.
/// @return The collection symbol.
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/// @notice Returns the Uniform Resource Identifier (URI) for `id` token.
/// @param id The token ID.
/// @return The URI.
function tokenURI(uint256 id) public view virtual returns (string memory);
/* -------------------------------------------------------------------------- */
/* ENUMERABLE LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the total amount of tokens stored by the contract.
/// @return The token supply.
function totalSupply() public view virtual returns (uint256);
/// @notice Returns a token ID owned by `owner` at a given `index` of its token list.
/// @dev Use along with {balanceOf} to enumerate all of `owner`'s tokens.
/// @param owner The address to query.
/// @param index The index to query.
/// @return The token ID.
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256);
/// @notice Returns a token ID at a given `index` of all the tokens stored by the contract.
/// @dev Use along with {totalSupply} to enumerate all tokens.
/// @param index The index to query.
/// @return The token ID.
function tokenByIndex(uint256 index) public view virtual returns (uint256);
/* -------------------------------------------------------------------------- */
/* ERC721 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the account approved for a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id Token ID to query.
/// @return The account approved for `id` token.
function getApproved(uint256 id) public virtual returns (address) {
require(_exists(id), "NONEXISTENT_TOKEN");
return _tokenApprovals[id];
}
/// @notice Returns if the `operator` is allowed to manage all of the assets of `owner`.
/// @param owner The address of the owner.
/// @param operator The address of the operator.
/// @return True if `operator` was approved by `owner`.
function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
return _operatorApprovals[owner][operator];
}
/// @notice Gives permission to `to` to transfer `id` token to another account.
/// @dev The approval is cleared when the token is transferred.
/// Only a single account can be approved at a time, so approving the zero address clears previous approvals.
/// Requirements:
/// - The caller must own the token or be an approved operator.
/// - `id` must exist.
/// Emits an {Approval} event.
/// @param spender The address of the spender to approve to.
/// @param id The token ID to approve.
function approve(address spender, uint256 id) public virtual {
address owner = ownerOf(id);
require(isApprovedForAll(owner, msg.sender) || msg.sender == owner, "NOT_AUTHORIZED");
_tokenApprovals[id] = spender;
emit Approval(owner, spender, id);
}
/// @notice Approve or remove `operator` as an operator for the caller.
/// @dev Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
/// Emits an {ApprovalForAll} event.
/// @param operator The address of the operator to approve.
/// @param approved The status to set.
function setApprovalForAll(address operator, bool approved) public virtual {
_operatorApprovals[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
/// @notice Transfers `id` token from `from` to `to`.
/// WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function transferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function safeTransferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// Additionally passes `data` in the callback.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
/// @param data The calldata to pass in the {ERC721TokenReceiver-onERC721Received} callback.
function safeTransferFrom(
address from,
address to,
uint256 id,
bytes memory data
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Returns the number of tokens in an account.
/// @param owner The address to query.
/// @return The balance.
function balanceOf(address owner) public view virtual returns (uint256);
/// @notice Returns the owner of a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id The token ID.
function ownerOf(uint256 id) public view virtual returns (address);
/* -------------------------------------------------------------------------- */
/* INTERNAL LOGIC */
/* -------------------------------------------------------------------------- */
/// @dev Returns whether a token ID exists.
/// Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
/// Tokens start existing when they are minted.
/// @param id Token ID to query.
function _exists(uint256 id) internal view virtual returns (bool);
/// @dev Transfers `id` from `from` to `to`.
/// Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function _transfer(
address from,
address to,
uint256 id
) internal virtual;
/// @dev Mints `amount` tokens to `to`.
/// Requirements:
/// - there must be `amount` tokens remaining unminted in the total collection.
/// - `to` cannot be the zero address.
/// Emits `amount` {Transfer} events.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _mint(address to, uint256 amount) internal virtual;
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// If `to` is a contract it must implement {ERC721TokenReceiver.onERC721Received}
/// that returns {ERC721TokenReceiver.onERC721Received.selector}.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _safeMint(address to, uint256 amount) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// Requirements:
/// - `id` must not exist.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver.onERC721Received}, which is called upon a safe transfer.
/// Additionally passes `data` in the callback.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
/// @param data The calldata to pass in the {ERC721TokenReceiver.onERC721Received} callback.
function _safeMint(
address to,
uint256 amount,
bytes memory data
) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/* -------------------------------------------------------------------------- */
/* UTILS */
/* -------------------------------------------------------------------------- */
/// @notice Converts a `uint256` to its ASCII `string` decimal representation.
/// @dev https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Strings.sol
function toString(uint256 value) internal pure virtual returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
} | setApprovalForAll | function setApprovalForAll(address operator, bool approved) public virtual {
_operatorApprovals[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
| /// @notice Approve or remove `operator` as an operator for the caller.
/// @dev Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
/// Emits an {ApprovalForAll} event.
/// @param operator The address of the operator to approve.
/// @param approved The status to set. | NatSpecSingleLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
6833,
7024
]
} | 6,019 |
||||
Mingoes | contracts/src/ERC721/ERC721.sol | 0xe6f475c11ad693e48455fcaf7bca33fe84ce71b0 | Solidity | ERC721 | abstract contract ERC721 {
/* -------------------------------------------------------------------------- */
/* EVENTS */
/* -------------------------------------------------------------------------- */
/// @dev Emitted when `id` token is transferred from `from` to `to`.
event Transfer(address indexed from, address indexed to, uint256 indexed id);
/// @dev Emitted when `owner` enables `approved` to manage the `id` token.
event Approval(address indexed owner, address indexed spender, uint256 indexed id);
/// @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/* -------------------------------------------------------------------------- */
/* METADATA STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev The collection name.
string private _name;
/// @dev The collection symbol.
string private _symbol;
/* -------------------------------------------------------------------------- */
/* ERC721 STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev ID => spender
mapping(uint256 => address) internal _tokenApprovals;
/// @dev owner => operator => approved
mapping(address => mapping(address => bool)) internal _operatorApprovals;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
/// @param name_ The collection name.
/// @param symbol_ The collection symbol.
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/* -------------------------------------------------------------------------- */
/* ERC165 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns true if this contract implements an interface from its ID.
/// @dev See the corresponding
/// [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
/// to learn more about how these IDs are created.
/// @return The implementation status.
function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool) {
return
interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721
interfaceId == 0x5b5e139f || // ERC165 Interface ID for ERC721Metadata
interfaceId == 0x780e9d63; // ERC165 Interface ID for ERC721Enumerable
}
/* -------------------------------------------------------------------------- */
/* METADATA LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the collection name.
/// @return The collection name.
function name() public view virtual returns (string memory) {
return _name;
}
/// @notice Returns the collection symbol.
/// @return The collection symbol.
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/// @notice Returns the Uniform Resource Identifier (URI) for `id` token.
/// @param id The token ID.
/// @return The URI.
function tokenURI(uint256 id) public view virtual returns (string memory);
/* -------------------------------------------------------------------------- */
/* ENUMERABLE LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the total amount of tokens stored by the contract.
/// @return The token supply.
function totalSupply() public view virtual returns (uint256);
/// @notice Returns a token ID owned by `owner` at a given `index` of its token list.
/// @dev Use along with {balanceOf} to enumerate all of `owner`'s tokens.
/// @param owner The address to query.
/// @param index The index to query.
/// @return The token ID.
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256);
/// @notice Returns a token ID at a given `index` of all the tokens stored by the contract.
/// @dev Use along with {totalSupply} to enumerate all tokens.
/// @param index The index to query.
/// @return The token ID.
function tokenByIndex(uint256 index) public view virtual returns (uint256);
/* -------------------------------------------------------------------------- */
/* ERC721 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the account approved for a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id Token ID to query.
/// @return The account approved for `id` token.
function getApproved(uint256 id) public virtual returns (address) {
require(_exists(id), "NONEXISTENT_TOKEN");
return _tokenApprovals[id];
}
/// @notice Returns if the `operator` is allowed to manage all of the assets of `owner`.
/// @param owner The address of the owner.
/// @param operator The address of the operator.
/// @return True if `operator` was approved by `owner`.
function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
return _operatorApprovals[owner][operator];
}
/// @notice Gives permission to `to` to transfer `id` token to another account.
/// @dev The approval is cleared when the token is transferred.
/// Only a single account can be approved at a time, so approving the zero address clears previous approvals.
/// Requirements:
/// - The caller must own the token or be an approved operator.
/// - `id` must exist.
/// Emits an {Approval} event.
/// @param spender The address of the spender to approve to.
/// @param id The token ID to approve.
function approve(address spender, uint256 id) public virtual {
address owner = ownerOf(id);
require(isApprovedForAll(owner, msg.sender) || msg.sender == owner, "NOT_AUTHORIZED");
_tokenApprovals[id] = spender;
emit Approval(owner, spender, id);
}
/// @notice Approve or remove `operator` as an operator for the caller.
/// @dev Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
/// Emits an {ApprovalForAll} event.
/// @param operator The address of the operator to approve.
/// @param approved The status to set.
function setApprovalForAll(address operator, bool approved) public virtual {
_operatorApprovals[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
/// @notice Transfers `id` token from `from` to `to`.
/// WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function transferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function safeTransferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// Additionally passes `data` in the callback.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
/// @param data The calldata to pass in the {ERC721TokenReceiver-onERC721Received} callback.
function safeTransferFrom(
address from,
address to,
uint256 id,
bytes memory data
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Returns the number of tokens in an account.
/// @param owner The address to query.
/// @return The balance.
function balanceOf(address owner) public view virtual returns (uint256);
/// @notice Returns the owner of a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id The token ID.
function ownerOf(uint256 id) public view virtual returns (address);
/* -------------------------------------------------------------------------- */
/* INTERNAL LOGIC */
/* -------------------------------------------------------------------------- */
/// @dev Returns whether a token ID exists.
/// Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
/// Tokens start existing when they are minted.
/// @param id Token ID to query.
function _exists(uint256 id) internal view virtual returns (bool);
/// @dev Transfers `id` from `from` to `to`.
/// Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function _transfer(
address from,
address to,
uint256 id
) internal virtual;
/// @dev Mints `amount` tokens to `to`.
/// Requirements:
/// - there must be `amount` tokens remaining unminted in the total collection.
/// - `to` cannot be the zero address.
/// Emits `amount` {Transfer} events.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _mint(address to, uint256 amount) internal virtual;
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// If `to` is a contract it must implement {ERC721TokenReceiver.onERC721Received}
/// that returns {ERC721TokenReceiver.onERC721Received.selector}.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _safeMint(address to, uint256 amount) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// Requirements:
/// - `id` must not exist.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver.onERC721Received}, which is called upon a safe transfer.
/// Additionally passes `data` in the callback.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
/// @param data The calldata to pass in the {ERC721TokenReceiver.onERC721Received} callback.
function _safeMint(
address to,
uint256 amount,
bytes memory data
) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/* -------------------------------------------------------------------------- */
/* UTILS */
/* -------------------------------------------------------------------------- */
/// @notice Converts a `uint256` to its ASCII `string` decimal representation.
/// @dev https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Strings.sol
function toString(uint256 value) internal pure virtual returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
} | transferFrom | function transferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
}
| /// @notice Transfers `id` token from `from` to `to`.
/// WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer. | NatSpecSingleLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
7562,
7678
]
} | 6,020 |
||||
Mingoes | contracts/src/ERC721/ERC721.sol | 0xe6f475c11ad693e48455fcaf7bca33fe84ce71b0 | Solidity | ERC721 | abstract contract ERC721 {
/* -------------------------------------------------------------------------- */
/* EVENTS */
/* -------------------------------------------------------------------------- */
/// @dev Emitted when `id` token is transferred from `from` to `to`.
event Transfer(address indexed from, address indexed to, uint256 indexed id);
/// @dev Emitted when `owner` enables `approved` to manage the `id` token.
event Approval(address indexed owner, address indexed spender, uint256 indexed id);
/// @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/* -------------------------------------------------------------------------- */
/* METADATA STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev The collection name.
string private _name;
/// @dev The collection symbol.
string private _symbol;
/* -------------------------------------------------------------------------- */
/* ERC721 STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev ID => spender
mapping(uint256 => address) internal _tokenApprovals;
/// @dev owner => operator => approved
mapping(address => mapping(address => bool)) internal _operatorApprovals;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
/// @param name_ The collection name.
/// @param symbol_ The collection symbol.
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/* -------------------------------------------------------------------------- */
/* ERC165 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns true if this contract implements an interface from its ID.
/// @dev See the corresponding
/// [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
/// to learn more about how these IDs are created.
/// @return The implementation status.
function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool) {
return
interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721
interfaceId == 0x5b5e139f || // ERC165 Interface ID for ERC721Metadata
interfaceId == 0x780e9d63; // ERC165 Interface ID for ERC721Enumerable
}
/* -------------------------------------------------------------------------- */
/* METADATA LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the collection name.
/// @return The collection name.
function name() public view virtual returns (string memory) {
return _name;
}
/// @notice Returns the collection symbol.
/// @return The collection symbol.
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/// @notice Returns the Uniform Resource Identifier (URI) for `id` token.
/// @param id The token ID.
/// @return The URI.
function tokenURI(uint256 id) public view virtual returns (string memory);
/* -------------------------------------------------------------------------- */
/* ENUMERABLE LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the total amount of tokens stored by the contract.
/// @return The token supply.
function totalSupply() public view virtual returns (uint256);
/// @notice Returns a token ID owned by `owner` at a given `index` of its token list.
/// @dev Use along with {balanceOf} to enumerate all of `owner`'s tokens.
/// @param owner The address to query.
/// @param index The index to query.
/// @return The token ID.
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256);
/// @notice Returns a token ID at a given `index` of all the tokens stored by the contract.
/// @dev Use along with {totalSupply} to enumerate all tokens.
/// @param index The index to query.
/// @return The token ID.
function tokenByIndex(uint256 index) public view virtual returns (uint256);
/* -------------------------------------------------------------------------- */
/* ERC721 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the account approved for a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id Token ID to query.
/// @return The account approved for `id` token.
function getApproved(uint256 id) public virtual returns (address) {
require(_exists(id), "NONEXISTENT_TOKEN");
return _tokenApprovals[id];
}
/// @notice Returns if the `operator` is allowed to manage all of the assets of `owner`.
/// @param owner The address of the owner.
/// @param operator The address of the operator.
/// @return True if `operator` was approved by `owner`.
function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
return _operatorApprovals[owner][operator];
}
/// @notice Gives permission to `to` to transfer `id` token to another account.
/// @dev The approval is cleared when the token is transferred.
/// Only a single account can be approved at a time, so approving the zero address clears previous approvals.
/// Requirements:
/// - The caller must own the token or be an approved operator.
/// - `id` must exist.
/// Emits an {Approval} event.
/// @param spender The address of the spender to approve to.
/// @param id The token ID to approve.
function approve(address spender, uint256 id) public virtual {
address owner = ownerOf(id);
require(isApprovedForAll(owner, msg.sender) || msg.sender == owner, "NOT_AUTHORIZED");
_tokenApprovals[id] = spender;
emit Approval(owner, spender, id);
}
/// @notice Approve or remove `operator` as an operator for the caller.
/// @dev Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
/// Emits an {ApprovalForAll} event.
/// @param operator The address of the operator to approve.
/// @param approved The status to set.
function setApprovalForAll(address operator, bool approved) public virtual {
_operatorApprovals[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
/// @notice Transfers `id` token from `from` to `to`.
/// WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function transferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function safeTransferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// Additionally passes `data` in the callback.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
/// @param data The calldata to pass in the {ERC721TokenReceiver-onERC721Received} callback.
function safeTransferFrom(
address from,
address to,
uint256 id,
bytes memory data
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Returns the number of tokens in an account.
/// @param owner The address to query.
/// @return The balance.
function balanceOf(address owner) public view virtual returns (uint256);
/// @notice Returns the owner of a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id The token ID.
function ownerOf(uint256 id) public view virtual returns (address);
/* -------------------------------------------------------------------------- */
/* INTERNAL LOGIC */
/* -------------------------------------------------------------------------- */
/// @dev Returns whether a token ID exists.
/// Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
/// Tokens start existing when they are minted.
/// @param id Token ID to query.
function _exists(uint256 id) internal view virtual returns (bool);
/// @dev Transfers `id` from `from` to `to`.
/// Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function _transfer(
address from,
address to,
uint256 id
) internal virtual;
/// @dev Mints `amount` tokens to `to`.
/// Requirements:
/// - there must be `amount` tokens remaining unminted in the total collection.
/// - `to` cannot be the zero address.
/// Emits `amount` {Transfer} events.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _mint(address to, uint256 amount) internal virtual;
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// If `to` is a contract it must implement {ERC721TokenReceiver.onERC721Received}
/// that returns {ERC721TokenReceiver.onERC721Received.selector}.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _safeMint(address to, uint256 amount) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// Requirements:
/// - `id` must not exist.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver.onERC721Received}, which is called upon a safe transfer.
/// Additionally passes `data` in the callback.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
/// @param data The calldata to pass in the {ERC721TokenReceiver.onERC721Received} callback.
function _safeMint(
address to,
uint256 amount,
bytes memory data
) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/* -------------------------------------------------------------------------- */
/* UTILS */
/* -------------------------------------------------------------------------- */
/// @notice Converts a `uint256` to its ASCII `string` decimal representation.
/// @dev https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Strings.sol
function toString(uint256 value) internal pure virtual returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
} | safeTransferFrom | function safeTransferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
| /// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer. | NatSpecSingleLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
8279,
8571
]
} | 6,021 |
||||
Mingoes | contracts/src/ERC721/ERC721.sol | 0xe6f475c11ad693e48455fcaf7bca33fe84ce71b0 | Solidity | ERC721 | abstract contract ERC721 {
/* -------------------------------------------------------------------------- */
/* EVENTS */
/* -------------------------------------------------------------------------- */
/// @dev Emitted when `id` token is transferred from `from` to `to`.
event Transfer(address indexed from, address indexed to, uint256 indexed id);
/// @dev Emitted when `owner` enables `approved` to manage the `id` token.
event Approval(address indexed owner, address indexed spender, uint256 indexed id);
/// @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/* -------------------------------------------------------------------------- */
/* METADATA STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev The collection name.
string private _name;
/// @dev The collection symbol.
string private _symbol;
/* -------------------------------------------------------------------------- */
/* ERC721 STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev ID => spender
mapping(uint256 => address) internal _tokenApprovals;
/// @dev owner => operator => approved
mapping(address => mapping(address => bool)) internal _operatorApprovals;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
/// @param name_ The collection name.
/// @param symbol_ The collection symbol.
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/* -------------------------------------------------------------------------- */
/* ERC165 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns true if this contract implements an interface from its ID.
/// @dev See the corresponding
/// [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
/// to learn more about how these IDs are created.
/// @return The implementation status.
function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool) {
return
interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721
interfaceId == 0x5b5e139f || // ERC165 Interface ID for ERC721Metadata
interfaceId == 0x780e9d63; // ERC165 Interface ID for ERC721Enumerable
}
/* -------------------------------------------------------------------------- */
/* METADATA LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the collection name.
/// @return The collection name.
function name() public view virtual returns (string memory) {
return _name;
}
/// @notice Returns the collection symbol.
/// @return The collection symbol.
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/// @notice Returns the Uniform Resource Identifier (URI) for `id` token.
/// @param id The token ID.
/// @return The URI.
function tokenURI(uint256 id) public view virtual returns (string memory);
/* -------------------------------------------------------------------------- */
/* ENUMERABLE LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the total amount of tokens stored by the contract.
/// @return The token supply.
function totalSupply() public view virtual returns (uint256);
/// @notice Returns a token ID owned by `owner` at a given `index` of its token list.
/// @dev Use along with {balanceOf} to enumerate all of `owner`'s tokens.
/// @param owner The address to query.
/// @param index The index to query.
/// @return The token ID.
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256);
/// @notice Returns a token ID at a given `index` of all the tokens stored by the contract.
/// @dev Use along with {totalSupply} to enumerate all tokens.
/// @param index The index to query.
/// @return The token ID.
function tokenByIndex(uint256 index) public view virtual returns (uint256);
/* -------------------------------------------------------------------------- */
/* ERC721 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the account approved for a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id Token ID to query.
/// @return The account approved for `id` token.
function getApproved(uint256 id) public virtual returns (address) {
require(_exists(id), "NONEXISTENT_TOKEN");
return _tokenApprovals[id];
}
/// @notice Returns if the `operator` is allowed to manage all of the assets of `owner`.
/// @param owner The address of the owner.
/// @param operator The address of the operator.
/// @return True if `operator` was approved by `owner`.
function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
return _operatorApprovals[owner][operator];
}
/// @notice Gives permission to `to` to transfer `id` token to another account.
/// @dev The approval is cleared when the token is transferred.
/// Only a single account can be approved at a time, so approving the zero address clears previous approvals.
/// Requirements:
/// - The caller must own the token or be an approved operator.
/// - `id` must exist.
/// Emits an {Approval} event.
/// @param spender The address of the spender to approve to.
/// @param id The token ID to approve.
function approve(address spender, uint256 id) public virtual {
address owner = ownerOf(id);
require(isApprovedForAll(owner, msg.sender) || msg.sender == owner, "NOT_AUTHORIZED");
_tokenApprovals[id] = spender;
emit Approval(owner, spender, id);
}
/// @notice Approve or remove `operator` as an operator for the caller.
/// @dev Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
/// Emits an {ApprovalForAll} event.
/// @param operator The address of the operator to approve.
/// @param approved The status to set.
function setApprovalForAll(address operator, bool approved) public virtual {
_operatorApprovals[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
/// @notice Transfers `id` token from `from` to `to`.
/// WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function transferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function safeTransferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// Additionally passes `data` in the callback.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
/// @param data The calldata to pass in the {ERC721TokenReceiver-onERC721Received} callback.
function safeTransferFrom(
address from,
address to,
uint256 id,
bytes memory data
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Returns the number of tokens in an account.
/// @param owner The address to query.
/// @return The balance.
function balanceOf(address owner) public view virtual returns (uint256);
/// @notice Returns the owner of a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id The token ID.
function ownerOf(uint256 id) public view virtual returns (address);
/* -------------------------------------------------------------------------- */
/* INTERNAL LOGIC */
/* -------------------------------------------------------------------------- */
/// @dev Returns whether a token ID exists.
/// Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
/// Tokens start existing when they are minted.
/// @param id Token ID to query.
function _exists(uint256 id) internal view virtual returns (bool);
/// @dev Transfers `id` from `from` to `to`.
/// Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function _transfer(
address from,
address to,
uint256 id
) internal virtual;
/// @dev Mints `amount` tokens to `to`.
/// Requirements:
/// - there must be `amount` tokens remaining unminted in the total collection.
/// - `to` cannot be the zero address.
/// Emits `amount` {Transfer} events.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _mint(address to, uint256 amount) internal virtual;
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// If `to` is a contract it must implement {ERC721TokenReceiver.onERC721Received}
/// that returns {ERC721TokenReceiver.onERC721Received.selector}.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _safeMint(address to, uint256 amount) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// Requirements:
/// - `id` must not exist.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver.onERC721Received}, which is called upon a safe transfer.
/// Additionally passes `data` in the callback.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
/// @param data The calldata to pass in the {ERC721TokenReceiver.onERC721Received} callback.
function _safeMint(
address to,
uint256 amount,
bytes memory data
) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/* -------------------------------------------------------------------------- */
/* UTILS */
/* -------------------------------------------------------------------------- */
/// @notice Converts a `uint256` to its ASCII `string` decimal representation.
/// @dev https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Strings.sol
function toString(uint256 value) internal pure virtual returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
} | safeTransferFrom | function safeTransferFrom(
address from,
address to,
uint256 id,
bytes memory data
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
| /// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// Additionally passes `data` in the callback.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
/// @param data The calldata to pass in the {ERC721TokenReceiver-onERC721Received} callback. | NatSpecSingleLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
9315,
9630
]
} | 6,022 |
||||
Mingoes | contracts/src/ERC721/ERC721.sol | 0xe6f475c11ad693e48455fcaf7bca33fe84ce71b0 | Solidity | ERC721 | abstract contract ERC721 {
/* -------------------------------------------------------------------------- */
/* EVENTS */
/* -------------------------------------------------------------------------- */
/// @dev Emitted when `id` token is transferred from `from` to `to`.
event Transfer(address indexed from, address indexed to, uint256 indexed id);
/// @dev Emitted when `owner` enables `approved` to manage the `id` token.
event Approval(address indexed owner, address indexed spender, uint256 indexed id);
/// @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/* -------------------------------------------------------------------------- */
/* METADATA STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev The collection name.
string private _name;
/// @dev The collection symbol.
string private _symbol;
/* -------------------------------------------------------------------------- */
/* ERC721 STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev ID => spender
mapping(uint256 => address) internal _tokenApprovals;
/// @dev owner => operator => approved
mapping(address => mapping(address => bool)) internal _operatorApprovals;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
/// @param name_ The collection name.
/// @param symbol_ The collection symbol.
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/* -------------------------------------------------------------------------- */
/* ERC165 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns true if this contract implements an interface from its ID.
/// @dev See the corresponding
/// [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
/// to learn more about how these IDs are created.
/// @return The implementation status.
function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool) {
return
interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721
interfaceId == 0x5b5e139f || // ERC165 Interface ID for ERC721Metadata
interfaceId == 0x780e9d63; // ERC165 Interface ID for ERC721Enumerable
}
/* -------------------------------------------------------------------------- */
/* METADATA LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the collection name.
/// @return The collection name.
function name() public view virtual returns (string memory) {
return _name;
}
/// @notice Returns the collection symbol.
/// @return The collection symbol.
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/// @notice Returns the Uniform Resource Identifier (URI) for `id` token.
/// @param id The token ID.
/// @return The URI.
function tokenURI(uint256 id) public view virtual returns (string memory);
/* -------------------------------------------------------------------------- */
/* ENUMERABLE LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the total amount of tokens stored by the contract.
/// @return The token supply.
function totalSupply() public view virtual returns (uint256);
/// @notice Returns a token ID owned by `owner` at a given `index` of its token list.
/// @dev Use along with {balanceOf} to enumerate all of `owner`'s tokens.
/// @param owner The address to query.
/// @param index The index to query.
/// @return The token ID.
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256);
/// @notice Returns a token ID at a given `index` of all the tokens stored by the contract.
/// @dev Use along with {totalSupply} to enumerate all tokens.
/// @param index The index to query.
/// @return The token ID.
function tokenByIndex(uint256 index) public view virtual returns (uint256);
/* -------------------------------------------------------------------------- */
/* ERC721 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the account approved for a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id Token ID to query.
/// @return The account approved for `id` token.
function getApproved(uint256 id) public virtual returns (address) {
require(_exists(id), "NONEXISTENT_TOKEN");
return _tokenApprovals[id];
}
/// @notice Returns if the `operator` is allowed to manage all of the assets of `owner`.
/// @param owner The address of the owner.
/// @param operator The address of the operator.
/// @return True if `operator` was approved by `owner`.
function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
return _operatorApprovals[owner][operator];
}
/// @notice Gives permission to `to` to transfer `id` token to another account.
/// @dev The approval is cleared when the token is transferred.
/// Only a single account can be approved at a time, so approving the zero address clears previous approvals.
/// Requirements:
/// - The caller must own the token or be an approved operator.
/// - `id` must exist.
/// Emits an {Approval} event.
/// @param spender The address of the spender to approve to.
/// @param id The token ID to approve.
function approve(address spender, uint256 id) public virtual {
address owner = ownerOf(id);
require(isApprovedForAll(owner, msg.sender) || msg.sender == owner, "NOT_AUTHORIZED");
_tokenApprovals[id] = spender;
emit Approval(owner, spender, id);
}
/// @notice Approve or remove `operator` as an operator for the caller.
/// @dev Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
/// Emits an {ApprovalForAll} event.
/// @param operator The address of the operator to approve.
/// @param approved The status to set.
function setApprovalForAll(address operator, bool approved) public virtual {
_operatorApprovals[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
/// @notice Transfers `id` token from `from` to `to`.
/// WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function transferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function safeTransferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// Additionally passes `data` in the callback.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
/// @param data The calldata to pass in the {ERC721TokenReceiver-onERC721Received} callback.
function safeTransferFrom(
address from,
address to,
uint256 id,
bytes memory data
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Returns the number of tokens in an account.
/// @param owner The address to query.
/// @return The balance.
function balanceOf(address owner) public view virtual returns (uint256);
/// @notice Returns the owner of a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id The token ID.
function ownerOf(uint256 id) public view virtual returns (address);
/* -------------------------------------------------------------------------- */
/* INTERNAL LOGIC */
/* -------------------------------------------------------------------------- */
/// @dev Returns whether a token ID exists.
/// Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
/// Tokens start existing when they are minted.
/// @param id Token ID to query.
function _exists(uint256 id) internal view virtual returns (bool);
/// @dev Transfers `id` from `from` to `to`.
/// Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function _transfer(
address from,
address to,
uint256 id
) internal virtual;
/// @dev Mints `amount` tokens to `to`.
/// Requirements:
/// - there must be `amount` tokens remaining unminted in the total collection.
/// - `to` cannot be the zero address.
/// Emits `amount` {Transfer} events.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _mint(address to, uint256 amount) internal virtual;
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// If `to` is a contract it must implement {ERC721TokenReceiver.onERC721Received}
/// that returns {ERC721TokenReceiver.onERC721Received.selector}.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _safeMint(address to, uint256 amount) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// Requirements:
/// - `id` must not exist.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver.onERC721Received}, which is called upon a safe transfer.
/// Additionally passes `data` in the callback.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
/// @param data The calldata to pass in the {ERC721TokenReceiver.onERC721Received} callback.
function _safeMint(
address to,
uint256 amount,
bytes memory data
) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/* -------------------------------------------------------------------------- */
/* UTILS */
/* -------------------------------------------------------------------------- */
/// @notice Converts a `uint256` to its ASCII `string` decimal representation.
/// @dev https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Strings.sol
function toString(uint256 value) internal pure virtual returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
} | balanceOf | function balanceOf(address owner) public view virtual returns (uint256);
| /// @notice Returns the number of tokens in an account.
/// @param owner The address to query.
/// @return The balance. | NatSpecSingleLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
9755,
9828
]
} | 6,023 |
||||
Mingoes | contracts/src/ERC721/ERC721.sol | 0xe6f475c11ad693e48455fcaf7bca33fe84ce71b0 | Solidity | ERC721 | abstract contract ERC721 {
/* -------------------------------------------------------------------------- */
/* EVENTS */
/* -------------------------------------------------------------------------- */
/// @dev Emitted when `id` token is transferred from `from` to `to`.
event Transfer(address indexed from, address indexed to, uint256 indexed id);
/// @dev Emitted when `owner` enables `approved` to manage the `id` token.
event Approval(address indexed owner, address indexed spender, uint256 indexed id);
/// @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/* -------------------------------------------------------------------------- */
/* METADATA STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev The collection name.
string private _name;
/// @dev The collection symbol.
string private _symbol;
/* -------------------------------------------------------------------------- */
/* ERC721 STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev ID => spender
mapping(uint256 => address) internal _tokenApprovals;
/// @dev owner => operator => approved
mapping(address => mapping(address => bool)) internal _operatorApprovals;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
/// @param name_ The collection name.
/// @param symbol_ The collection symbol.
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/* -------------------------------------------------------------------------- */
/* ERC165 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns true if this contract implements an interface from its ID.
/// @dev See the corresponding
/// [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
/// to learn more about how these IDs are created.
/// @return The implementation status.
function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool) {
return
interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721
interfaceId == 0x5b5e139f || // ERC165 Interface ID for ERC721Metadata
interfaceId == 0x780e9d63; // ERC165 Interface ID for ERC721Enumerable
}
/* -------------------------------------------------------------------------- */
/* METADATA LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the collection name.
/// @return The collection name.
function name() public view virtual returns (string memory) {
return _name;
}
/// @notice Returns the collection symbol.
/// @return The collection symbol.
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/// @notice Returns the Uniform Resource Identifier (URI) for `id` token.
/// @param id The token ID.
/// @return The URI.
function tokenURI(uint256 id) public view virtual returns (string memory);
/* -------------------------------------------------------------------------- */
/* ENUMERABLE LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the total amount of tokens stored by the contract.
/// @return The token supply.
function totalSupply() public view virtual returns (uint256);
/// @notice Returns a token ID owned by `owner` at a given `index` of its token list.
/// @dev Use along with {balanceOf} to enumerate all of `owner`'s tokens.
/// @param owner The address to query.
/// @param index The index to query.
/// @return The token ID.
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256);
/// @notice Returns a token ID at a given `index` of all the tokens stored by the contract.
/// @dev Use along with {totalSupply} to enumerate all tokens.
/// @param index The index to query.
/// @return The token ID.
function tokenByIndex(uint256 index) public view virtual returns (uint256);
/* -------------------------------------------------------------------------- */
/* ERC721 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the account approved for a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id Token ID to query.
/// @return The account approved for `id` token.
function getApproved(uint256 id) public virtual returns (address) {
require(_exists(id), "NONEXISTENT_TOKEN");
return _tokenApprovals[id];
}
/// @notice Returns if the `operator` is allowed to manage all of the assets of `owner`.
/// @param owner The address of the owner.
/// @param operator The address of the operator.
/// @return True if `operator` was approved by `owner`.
function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
return _operatorApprovals[owner][operator];
}
/// @notice Gives permission to `to` to transfer `id` token to another account.
/// @dev The approval is cleared when the token is transferred.
/// Only a single account can be approved at a time, so approving the zero address clears previous approvals.
/// Requirements:
/// - The caller must own the token or be an approved operator.
/// - `id` must exist.
/// Emits an {Approval} event.
/// @param spender The address of the spender to approve to.
/// @param id The token ID to approve.
function approve(address spender, uint256 id) public virtual {
address owner = ownerOf(id);
require(isApprovedForAll(owner, msg.sender) || msg.sender == owner, "NOT_AUTHORIZED");
_tokenApprovals[id] = spender;
emit Approval(owner, spender, id);
}
/// @notice Approve or remove `operator` as an operator for the caller.
/// @dev Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
/// Emits an {ApprovalForAll} event.
/// @param operator The address of the operator to approve.
/// @param approved The status to set.
function setApprovalForAll(address operator, bool approved) public virtual {
_operatorApprovals[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
/// @notice Transfers `id` token from `from` to `to`.
/// WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function transferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function safeTransferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// Additionally passes `data` in the callback.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
/// @param data The calldata to pass in the {ERC721TokenReceiver-onERC721Received} callback.
function safeTransferFrom(
address from,
address to,
uint256 id,
bytes memory data
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Returns the number of tokens in an account.
/// @param owner The address to query.
/// @return The balance.
function balanceOf(address owner) public view virtual returns (uint256);
/// @notice Returns the owner of a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id The token ID.
function ownerOf(uint256 id) public view virtual returns (address);
/* -------------------------------------------------------------------------- */
/* INTERNAL LOGIC */
/* -------------------------------------------------------------------------- */
/// @dev Returns whether a token ID exists.
/// Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
/// Tokens start existing when they are minted.
/// @param id Token ID to query.
function _exists(uint256 id) internal view virtual returns (bool);
/// @dev Transfers `id` from `from` to `to`.
/// Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function _transfer(
address from,
address to,
uint256 id
) internal virtual;
/// @dev Mints `amount` tokens to `to`.
/// Requirements:
/// - there must be `amount` tokens remaining unminted in the total collection.
/// - `to` cannot be the zero address.
/// Emits `amount` {Transfer} events.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _mint(address to, uint256 amount) internal virtual;
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// If `to` is a contract it must implement {ERC721TokenReceiver.onERC721Received}
/// that returns {ERC721TokenReceiver.onERC721Received.selector}.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _safeMint(address to, uint256 amount) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// Requirements:
/// - `id` must not exist.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver.onERC721Received}, which is called upon a safe transfer.
/// Additionally passes `data` in the callback.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
/// @param data The calldata to pass in the {ERC721TokenReceiver.onERC721Received} callback.
function _safeMint(
address to,
uint256 amount,
bytes memory data
) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/* -------------------------------------------------------------------------- */
/* UTILS */
/* -------------------------------------------------------------------------- */
/// @notice Converts a `uint256` to its ASCII `string` decimal representation.
/// @dev https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Strings.sol
function toString(uint256 value) internal pure virtual returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
} | ownerOf | function ownerOf(uint256 id) public view virtual returns (address);
| /// @notice Returns the owner of a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id The token ID. | NatSpecSingleLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
9953,
10021
]
} | 6,024 |
||||
Mingoes | contracts/src/ERC721/ERC721.sol | 0xe6f475c11ad693e48455fcaf7bca33fe84ce71b0 | Solidity | ERC721 | abstract contract ERC721 {
/* -------------------------------------------------------------------------- */
/* EVENTS */
/* -------------------------------------------------------------------------- */
/// @dev Emitted when `id` token is transferred from `from` to `to`.
event Transfer(address indexed from, address indexed to, uint256 indexed id);
/// @dev Emitted when `owner` enables `approved` to manage the `id` token.
event Approval(address indexed owner, address indexed spender, uint256 indexed id);
/// @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/* -------------------------------------------------------------------------- */
/* METADATA STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev The collection name.
string private _name;
/// @dev The collection symbol.
string private _symbol;
/* -------------------------------------------------------------------------- */
/* ERC721 STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev ID => spender
mapping(uint256 => address) internal _tokenApprovals;
/// @dev owner => operator => approved
mapping(address => mapping(address => bool)) internal _operatorApprovals;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
/// @param name_ The collection name.
/// @param symbol_ The collection symbol.
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/* -------------------------------------------------------------------------- */
/* ERC165 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns true if this contract implements an interface from its ID.
/// @dev See the corresponding
/// [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
/// to learn more about how these IDs are created.
/// @return The implementation status.
function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool) {
return
interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721
interfaceId == 0x5b5e139f || // ERC165 Interface ID for ERC721Metadata
interfaceId == 0x780e9d63; // ERC165 Interface ID for ERC721Enumerable
}
/* -------------------------------------------------------------------------- */
/* METADATA LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the collection name.
/// @return The collection name.
function name() public view virtual returns (string memory) {
return _name;
}
/// @notice Returns the collection symbol.
/// @return The collection symbol.
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/// @notice Returns the Uniform Resource Identifier (URI) for `id` token.
/// @param id The token ID.
/// @return The URI.
function tokenURI(uint256 id) public view virtual returns (string memory);
/* -------------------------------------------------------------------------- */
/* ENUMERABLE LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the total amount of tokens stored by the contract.
/// @return The token supply.
function totalSupply() public view virtual returns (uint256);
/// @notice Returns a token ID owned by `owner` at a given `index` of its token list.
/// @dev Use along with {balanceOf} to enumerate all of `owner`'s tokens.
/// @param owner The address to query.
/// @param index The index to query.
/// @return The token ID.
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256);
/// @notice Returns a token ID at a given `index` of all the tokens stored by the contract.
/// @dev Use along with {totalSupply} to enumerate all tokens.
/// @param index The index to query.
/// @return The token ID.
function tokenByIndex(uint256 index) public view virtual returns (uint256);
/* -------------------------------------------------------------------------- */
/* ERC721 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the account approved for a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id Token ID to query.
/// @return The account approved for `id` token.
function getApproved(uint256 id) public virtual returns (address) {
require(_exists(id), "NONEXISTENT_TOKEN");
return _tokenApprovals[id];
}
/// @notice Returns if the `operator` is allowed to manage all of the assets of `owner`.
/// @param owner The address of the owner.
/// @param operator The address of the operator.
/// @return True if `operator` was approved by `owner`.
function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
return _operatorApprovals[owner][operator];
}
/// @notice Gives permission to `to` to transfer `id` token to another account.
/// @dev The approval is cleared when the token is transferred.
/// Only a single account can be approved at a time, so approving the zero address clears previous approvals.
/// Requirements:
/// - The caller must own the token or be an approved operator.
/// - `id` must exist.
/// Emits an {Approval} event.
/// @param spender The address of the spender to approve to.
/// @param id The token ID to approve.
function approve(address spender, uint256 id) public virtual {
address owner = ownerOf(id);
require(isApprovedForAll(owner, msg.sender) || msg.sender == owner, "NOT_AUTHORIZED");
_tokenApprovals[id] = spender;
emit Approval(owner, spender, id);
}
/// @notice Approve or remove `operator` as an operator for the caller.
/// @dev Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
/// Emits an {ApprovalForAll} event.
/// @param operator The address of the operator to approve.
/// @param approved The status to set.
function setApprovalForAll(address operator, bool approved) public virtual {
_operatorApprovals[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
/// @notice Transfers `id` token from `from` to `to`.
/// WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function transferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function safeTransferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// Additionally passes `data` in the callback.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
/// @param data The calldata to pass in the {ERC721TokenReceiver-onERC721Received} callback.
function safeTransferFrom(
address from,
address to,
uint256 id,
bytes memory data
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Returns the number of tokens in an account.
/// @param owner The address to query.
/// @return The balance.
function balanceOf(address owner) public view virtual returns (uint256);
/// @notice Returns the owner of a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id The token ID.
function ownerOf(uint256 id) public view virtual returns (address);
/* -------------------------------------------------------------------------- */
/* INTERNAL LOGIC */
/* -------------------------------------------------------------------------- */
/// @dev Returns whether a token ID exists.
/// Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
/// Tokens start existing when they are minted.
/// @param id Token ID to query.
function _exists(uint256 id) internal view virtual returns (bool);
/// @dev Transfers `id` from `from` to `to`.
/// Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function _transfer(
address from,
address to,
uint256 id
) internal virtual;
/// @dev Mints `amount` tokens to `to`.
/// Requirements:
/// - there must be `amount` tokens remaining unminted in the total collection.
/// - `to` cannot be the zero address.
/// Emits `amount` {Transfer} events.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _mint(address to, uint256 amount) internal virtual;
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// If `to` is a contract it must implement {ERC721TokenReceiver.onERC721Received}
/// that returns {ERC721TokenReceiver.onERC721Received.selector}.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _safeMint(address to, uint256 amount) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// Requirements:
/// - `id` must not exist.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver.onERC721Received}, which is called upon a safe transfer.
/// Additionally passes `data` in the callback.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
/// @param data The calldata to pass in the {ERC721TokenReceiver.onERC721Received} callback.
function _safeMint(
address to,
uint256 amount,
bytes memory data
) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/* -------------------------------------------------------------------------- */
/* UTILS */
/* -------------------------------------------------------------------------- */
/// @notice Converts a `uint256` to its ASCII `string` decimal representation.
/// @dev https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Strings.sol
function toString(uint256 value) internal pure virtual returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
} | _exists | function _exists(uint256 id) internal view virtual returns (bool);
| /// @dev Returns whether a token ID exists.
/// Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
/// Tokens start existing when they are minted.
/// @param id Token ID to query. | NatSpecSingleLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
10499,
10566
]
} | 6,025 |
||||
Mingoes | contracts/src/ERC721/ERC721.sol | 0xe6f475c11ad693e48455fcaf7bca33fe84ce71b0 | Solidity | ERC721 | abstract contract ERC721 {
/* -------------------------------------------------------------------------- */
/* EVENTS */
/* -------------------------------------------------------------------------- */
/// @dev Emitted when `id` token is transferred from `from` to `to`.
event Transfer(address indexed from, address indexed to, uint256 indexed id);
/// @dev Emitted when `owner` enables `approved` to manage the `id` token.
event Approval(address indexed owner, address indexed spender, uint256 indexed id);
/// @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/* -------------------------------------------------------------------------- */
/* METADATA STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev The collection name.
string private _name;
/// @dev The collection symbol.
string private _symbol;
/* -------------------------------------------------------------------------- */
/* ERC721 STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev ID => spender
mapping(uint256 => address) internal _tokenApprovals;
/// @dev owner => operator => approved
mapping(address => mapping(address => bool)) internal _operatorApprovals;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
/// @param name_ The collection name.
/// @param symbol_ The collection symbol.
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/* -------------------------------------------------------------------------- */
/* ERC165 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns true if this contract implements an interface from its ID.
/// @dev See the corresponding
/// [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
/// to learn more about how these IDs are created.
/// @return The implementation status.
function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool) {
return
interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721
interfaceId == 0x5b5e139f || // ERC165 Interface ID for ERC721Metadata
interfaceId == 0x780e9d63; // ERC165 Interface ID for ERC721Enumerable
}
/* -------------------------------------------------------------------------- */
/* METADATA LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the collection name.
/// @return The collection name.
function name() public view virtual returns (string memory) {
return _name;
}
/// @notice Returns the collection symbol.
/// @return The collection symbol.
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/// @notice Returns the Uniform Resource Identifier (URI) for `id` token.
/// @param id The token ID.
/// @return The URI.
function tokenURI(uint256 id) public view virtual returns (string memory);
/* -------------------------------------------------------------------------- */
/* ENUMERABLE LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the total amount of tokens stored by the contract.
/// @return The token supply.
function totalSupply() public view virtual returns (uint256);
/// @notice Returns a token ID owned by `owner` at a given `index` of its token list.
/// @dev Use along with {balanceOf} to enumerate all of `owner`'s tokens.
/// @param owner The address to query.
/// @param index The index to query.
/// @return The token ID.
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256);
/// @notice Returns a token ID at a given `index` of all the tokens stored by the contract.
/// @dev Use along with {totalSupply} to enumerate all tokens.
/// @param index The index to query.
/// @return The token ID.
function tokenByIndex(uint256 index) public view virtual returns (uint256);
/* -------------------------------------------------------------------------- */
/* ERC721 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the account approved for a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id Token ID to query.
/// @return The account approved for `id` token.
function getApproved(uint256 id) public virtual returns (address) {
require(_exists(id), "NONEXISTENT_TOKEN");
return _tokenApprovals[id];
}
/// @notice Returns if the `operator` is allowed to manage all of the assets of `owner`.
/// @param owner The address of the owner.
/// @param operator The address of the operator.
/// @return True if `operator` was approved by `owner`.
function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
return _operatorApprovals[owner][operator];
}
/// @notice Gives permission to `to` to transfer `id` token to another account.
/// @dev The approval is cleared when the token is transferred.
/// Only a single account can be approved at a time, so approving the zero address clears previous approvals.
/// Requirements:
/// - The caller must own the token or be an approved operator.
/// - `id` must exist.
/// Emits an {Approval} event.
/// @param spender The address of the spender to approve to.
/// @param id The token ID to approve.
function approve(address spender, uint256 id) public virtual {
address owner = ownerOf(id);
require(isApprovedForAll(owner, msg.sender) || msg.sender == owner, "NOT_AUTHORIZED");
_tokenApprovals[id] = spender;
emit Approval(owner, spender, id);
}
/// @notice Approve or remove `operator` as an operator for the caller.
/// @dev Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
/// Emits an {ApprovalForAll} event.
/// @param operator The address of the operator to approve.
/// @param approved The status to set.
function setApprovalForAll(address operator, bool approved) public virtual {
_operatorApprovals[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
/// @notice Transfers `id` token from `from` to `to`.
/// WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function transferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function safeTransferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// Additionally passes `data` in the callback.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
/// @param data The calldata to pass in the {ERC721TokenReceiver-onERC721Received} callback.
function safeTransferFrom(
address from,
address to,
uint256 id,
bytes memory data
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Returns the number of tokens in an account.
/// @param owner The address to query.
/// @return The balance.
function balanceOf(address owner) public view virtual returns (uint256);
/// @notice Returns the owner of a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id The token ID.
function ownerOf(uint256 id) public view virtual returns (address);
/* -------------------------------------------------------------------------- */
/* INTERNAL LOGIC */
/* -------------------------------------------------------------------------- */
/// @dev Returns whether a token ID exists.
/// Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
/// Tokens start existing when they are minted.
/// @param id Token ID to query.
function _exists(uint256 id) internal view virtual returns (bool);
/// @dev Transfers `id` from `from` to `to`.
/// Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function _transfer(
address from,
address to,
uint256 id
) internal virtual;
/// @dev Mints `amount` tokens to `to`.
/// Requirements:
/// - there must be `amount` tokens remaining unminted in the total collection.
/// - `to` cannot be the zero address.
/// Emits `amount` {Transfer} events.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _mint(address to, uint256 amount) internal virtual;
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// If `to` is a contract it must implement {ERC721TokenReceiver.onERC721Received}
/// that returns {ERC721TokenReceiver.onERC721Received.selector}.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _safeMint(address to, uint256 amount) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// Requirements:
/// - `id` must not exist.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver.onERC721Received}, which is called upon a safe transfer.
/// Additionally passes `data` in the callback.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
/// @param data The calldata to pass in the {ERC721TokenReceiver.onERC721Received} callback.
function _safeMint(
address to,
uint256 amount,
bytes memory data
) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/* -------------------------------------------------------------------------- */
/* UTILS */
/* -------------------------------------------------------------------------- */
/// @notice Converts a `uint256` to its ASCII `string` decimal representation.
/// @dev https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Strings.sol
function toString(uint256 value) internal pure virtual returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
} | _transfer | function _transfer(
address from,
address to,
uint256 id
) internal virtual;
| /// @dev Transfers `id` from `from` to `to`.
/// Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer. | NatSpecSingleLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
10878,
10962
]
} | 6,026 |
||||
Mingoes | contracts/src/ERC721/ERC721.sol | 0xe6f475c11ad693e48455fcaf7bca33fe84ce71b0 | Solidity | ERC721 | abstract contract ERC721 {
/* -------------------------------------------------------------------------- */
/* EVENTS */
/* -------------------------------------------------------------------------- */
/// @dev Emitted when `id` token is transferred from `from` to `to`.
event Transfer(address indexed from, address indexed to, uint256 indexed id);
/// @dev Emitted when `owner` enables `approved` to manage the `id` token.
event Approval(address indexed owner, address indexed spender, uint256 indexed id);
/// @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/* -------------------------------------------------------------------------- */
/* METADATA STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev The collection name.
string private _name;
/// @dev The collection symbol.
string private _symbol;
/* -------------------------------------------------------------------------- */
/* ERC721 STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev ID => spender
mapping(uint256 => address) internal _tokenApprovals;
/// @dev owner => operator => approved
mapping(address => mapping(address => bool)) internal _operatorApprovals;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
/// @param name_ The collection name.
/// @param symbol_ The collection symbol.
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/* -------------------------------------------------------------------------- */
/* ERC165 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns true if this contract implements an interface from its ID.
/// @dev See the corresponding
/// [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
/// to learn more about how these IDs are created.
/// @return The implementation status.
function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool) {
return
interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721
interfaceId == 0x5b5e139f || // ERC165 Interface ID for ERC721Metadata
interfaceId == 0x780e9d63; // ERC165 Interface ID for ERC721Enumerable
}
/* -------------------------------------------------------------------------- */
/* METADATA LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the collection name.
/// @return The collection name.
function name() public view virtual returns (string memory) {
return _name;
}
/// @notice Returns the collection symbol.
/// @return The collection symbol.
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/// @notice Returns the Uniform Resource Identifier (URI) for `id` token.
/// @param id The token ID.
/// @return The URI.
function tokenURI(uint256 id) public view virtual returns (string memory);
/* -------------------------------------------------------------------------- */
/* ENUMERABLE LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the total amount of tokens stored by the contract.
/// @return The token supply.
function totalSupply() public view virtual returns (uint256);
/// @notice Returns a token ID owned by `owner` at a given `index` of its token list.
/// @dev Use along with {balanceOf} to enumerate all of `owner`'s tokens.
/// @param owner The address to query.
/// @param index The index to query.
/// @return The token ID.
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256);
/// @notice Returns a token ID at a given `index` of all the tokens stored by the contract.
/// @dev Use along with {totalSupply} to enumerate all tokens.
/// @param index The index to query.
/// @return The token ID.
function tokenByIndex(uint256 index) public view virtual returns (uint256);
/* -------------------------------------------------------------------------- */
/* ERC721 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the account approved for a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id Token ID to query.
/// @return The account approved for `id` token.
function getApproved(uint256 id) public virtual returns (address) {
require(_exists(id), "NONEXISTENT_TOKEN");
return _tokenApprovals[id];
}
/// @notice Returns if the `operator` is allowed to manage all of the assets of `owner`.
/// @param owner The address of the owner.
/// @param operator The address of the operator.
/// @return True if `operator` was approved by `owner`.
function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
return _operatorApprovals[owner][operator];
}
/// @notice Gives permission to `to` to transfer `id` token to another account.
/// @dev The approval is cleared when the token is transferred.
/// Only a single account can be approved at a time, so approving the zero address clears previous approvals.
/// Requirements:
/// - The caller must own the token or be an approved operator.
/// - `id` must exist.
/// Emits an {Approval} event.
/// @param spender The address of the spender to approve to.
/// @param id The token ID to approve.
function approve(address spender, uint256 id) public virtual {
address owner = ownerOf(id);
require(isApprovedForAll(owner, msg.sender) || msg.sender == owner, "NOT_AUTHORIZED");
_tokenApprovals[id] = spender;
emit Approval(owner, spender, id);
}
/// @notice Approve or remove `operator` as an operator for the caller.
/// @dev Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
/// Emits an {ApprovalForAll} event.
/// @param operator The address of the operator to approve.
/// @param approved The status to set.
function setApprovalForAll(address operator, bool approved) public virtual {
_operatorApprovals[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
/// @notice Transfers `id` token from `from` to `to`.
/// WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function transferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function safeTransferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// Additionally passes `data` in the callback.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
/// @param data The calldata to pass in the {ERC721TokenReceiver-onERC721Received} callback.
function safeTransferFrom(
address from,
address to,
uint256 id,
bytes memory data
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Returns the number of tokens in an account.
/// @param owner The address to query.
/// @return The balance.
function balanceOf(address owner) public view virtual returns (uint256);
/// @notice Returns the owner of a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id The token ID.
function ownerOf(uint256 id) public view virtual returns (address);
/* -------------------------------------------------------------------------- */
/* INTERNAL LOGIC */
/* -------------------------------------------------------------------------- */
/// @dev Returns whether a token ID exists.
/// Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
/// Tokens start existing when they are minted.
/// @param id Token ID to query.
function _exists(uint256 id) internal view virtual returns (bool);
/// @dev Transfers `id` from `from` to `to`.
/// Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function _transfer(
address from,
address to,
uint256 id
) internal virtual;
/// @dev Mints `amount` tokens to `to`.
/// Requirements:
/// - there must be `amount` tokens remaining unminted in the total collection.
/// - `to` cannot be the zero address.
/// Emits `amount` {Transfer} events.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _mint(address to, uint256 amount) internal virtual;
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// If `to` is a contract it must implement {ERC721TokenReceiver.onERC721Received}
/// that returns {ERC721TokenReceiver.onERC721Received.selector}.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _safeMint(address to, uint256 amount) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// Requirements:
/// - `id` must not exist.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver.onERC721Received}, which is called upon a safe transfer.
/// Additionally passes `data` in the callback.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
/// @param data The calldata to pass in the {ERC721TokenReceiver.onERC721Received} callback.
function _safeMint(
address to,
uint256 amount,
bytes memory data
) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/* -------------------------------------------------------------------------- */
/* UTILS */
/* -------------------------------------------------------------------------- */
/// @notice Converts a `uint256` to its ASCII `string` decimal representation.
/// @dev https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Strings.sol
function toString(uint256 value) internal pure virtual returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
} | _mint | function _mint(address to, uint256 amount) internal virtual;
| /// @dev Mints `amount` tokens to `to`.
/// Requirements:
/// - there must be `amount` tokens remaining unminted in the total collection.
/// - `to` cannot be the zero address.
/// Emits `amount` {Transfer} events.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint. | NatSpecSingleLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
11272,
11333
]
} | 6,027 |
||||
Mingoes | contracts/src/ERC721/ERC721.sol | 0xe6f475c11ad693e48455fcaf7bca33fe84ce71b0 | Solidity | ERC721 | abstract contract ERC721 {
/* -------------------------------------------------------------------------- */
/* EVENTS */
/* -------------------------------------------------------------------------- */
/// @dev Emitted when `id` token is transferred from `from` to `to`.
event Transfer(address indexed from, address indexed to, uint256 indexed id);
/// @dev Emitted when `owner` enables `approved` to manage the `id` token.
event Approval(address indexed owner, address indexed spender, uint256 indexed id);
/// @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/* -------------------------------------------------------------------------- */
/* METADATA STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev The collection name.
string private _name;
/// @dev The collection symbol.
string private _symbol;
/* -------------------------------------------------------------------------- */
/* ERC721 STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev ID => spender
mapping(uint256 => address) internal _tokenApprovals;
/// @dev owner => operator => approved
mapping(address => mapping(address => bool)) internal _operatorApprovals;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
/// @param name_ The collection name.
/// @param symbol_ The collection symbol.
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/* -------------------------------------------------------------------------- */
/* ERC165 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns true if this contract implements an interface from its ID.
/// @dev See the corresponding
/// [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
/// to learn more about how these IDs are created.
/// @return The implementation status.
function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool) {
return
interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721
interfaceId == 0x5b5e139f || // ERC165 Interface ID for ERC721Metadata
interfaceId == 0x780e9d63; // ERC165 Interface ID for ERC721Enumerable
}
/* -------------------------------------------------------------------------- */
/* METADATA LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the collection name.
/// @return The collection name.
function name() public view virtual returns (string memory) {
return _name;
}
/// @notice Returns the collection symbol.
/// @return The collection symbol.
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/// @notice Returns the Uniform Resource Identifier (URI) for `id` token.
/// @param id The token ID.
/// @return The URI.
function tokenURI(uint256 id) public view virtual returns (string memory);
/* -------------------------------------------------------------------------- */
/* ENUMERABLE LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the total amount of tokens stored by the contract.
/// @return The token supply.
function totalSupply() public view virtual returns (uint256);
/// @notice Returns a token ID owned by `owner` at a given `index` of its token list.
/// @dev Use along with {balanceOf} to enumerate all of `owner`'s tokens.
/// @param owner The address to query.
/// @param index The index to query.
/// @return The token ID.
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256);
/// @notice Returns a token ID at a given `index` of all the tokens stored by the contract.
/// @dev Use along with {totalSupply} to enumerate all tokens.
/// @param index The index to query.
/// @return The token ID.
function tokenByIndex(uint256 index) public view virtual returns (uint256);
/* -------------------------------------------------------------------------- */
/* ERC721 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the account approved for a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id Token ID to query.
/// @return The account approved for `id` token.
function getApproved(uint256 id) public virtual returns (address) {
require(_exists(id), "NONEXISTENT_TOKEN");
return _tokenApprovals[id];
}
/// @notice Returns if the `operator` is allowed to manage all of the assets of `owner`.
/// @param owner The address of the owner.
/// @param operator The address of the operator.
/// @return True if `operator` was approved by `owner`.
function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
return _operatorApprovals[owner][operator];
}
/// @notice Gives permission to `to` to transfer `id` token to another account.
/// @dev The approval is cleared when the token is transferred.
/// Only a single account can be approved at a time, so approving the zero address clears previous approvals.
/// Requirements:
/// - The caller must own the token or be an approved operator.
/// - `id` must exist.
/// Emits an {Approval} event.
/// @param spender The address of the spender to approve to.
/// @param id The token ID to approve.
function approve(address spender, uint256 id) public virtual {
address owner = ownerOf(id);
require(isApprovedForAll(owner, msg.sender) || msg.sender == owner, "NOT_AUTHORIZED");
_tokenApprovals[id] = spender;
emit Approval(owner, spender, id);
}
/// @notice Approve or remove `operator` as an operator for the caller.
/// @dev Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
/// Emits an {ApprovalForAll} event.
/// @param operator The address of the operator to approve.
/// @param approved The status to set.
function setApprovalForAll(address operator, bool approved) public virtual {
_operatorApprovals[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
/// @notice Transfers `id` token from `from` to `to`.
/// WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function transferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function safeTransferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// Additionally passes `data` in the callback.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
/// @param data The calldata to pass in the {ERC721TokenReceiver-onERC721Received} callback.
function safeTransferFrom(
address from,
address to,
uint256 id,
bytes memory data
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Returns the number of tokens in an account.
/// @param owner The address to query.
/// @return The balance.
function balanceOf(address owner) public view virtual returns (uint256);
/// @notice Returns the owner of a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id The token ID.
function ownerOf(uint256 id) public view virtual returns (address);
/* -------------------------------------------------------------------------- */
/* INTERNAL LOGIC */
/* -------------------------------------------------------------------------- */
/// @dev Returns whether a token ID exists.
/// Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
/// Tokens start existing when they are minted.
/// @param id Token ID to query.
function _exists(uint256 id) internal view virtual returns (bool);
/// @dev Transfers `id` from `from` to `to`.
/// Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function _transfer(
address from,
address to,
uint256 id
) internal virtual;
/// @dev Mints `amount` tokens to `to`.
/// Requirements:
/// - there must be `amount` tokens remaining unminted in the total collection.
/// - `to` cannot be the zero address.
/// Emits `amount` {Transfer} events.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _mint(address to, uint256 amount) internal virtual;
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// If `to` is a contract it must implement {ERC721TokenReceiver.onERC721Received}
/// that returns {ERC721TokenReceiver.onERC721Received.selector}.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _safeMint(address to, uint256 amount) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// Requirements:
/// - `id` must not exist.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver.onERC721Received}, which is called upon a safe transfer.
/// Additionally passes `data` in the callback.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
/// @param data The calldata to pass in the {ERC721TokenReceiver.onERC721Received} callback.
function _safeMint(
address to,
uint256 amount,
bytes memory data
) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/* -------------------------------------------------------------------------- */
/* UTILS */
/* -------------------------------------------------------------------------- */
/// @notice Converts a `uint256` to its ASCII `string` decimal representation.
/// @dev https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Strings.sol
function toString(uint256 value) internal pure virtual returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
} | _safeMint | function _safeMint(address to, uint256 amount) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
| /// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// If `to` is a contract it must implement {ERC721TokenReceiver.onERC721Received}
/// that returns {ERC721TokenReceiver.onERC721Received.selector}.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint. | NatSpecSingleLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
11644,
11928
]
} | 6,028 |
||||
Mingoes | contracts/src/ERC721/ERC721.sol | 0xe6f475c11ad693e48455fcaf7bca33fe84ce71b0 | Solidity | ERC721 | abstract contract ERC721 {
/* -------------------------------------------------------------------------- */
/* EVENTS */
/* -------------------------------------------------------------------------- */
/// @dev Emitted when `id` token is transferred from `from` to `to`.
event Transfer(address indexed from, address indexed to, uint256 indexed id);
/// @dev Emitted when `owner` enables `approved` to manage the `id` token.
event Approval(address indexed owner, address indexed spender, uint256 indexed id);
/// @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/* -------------------------------------------------------------------------- */
/* METADATA STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev The collection name.
string private _name;
/// @dev The collection symbol.
string private _symbol;
/* -------------------------------------------------------------------------- */
/* ERC721 STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev ID => spender
mapping(uint256 => address) internal _tokenApprovals;
/// @dev owner => operator => approved
mapping(address => mapping(address => bool)) internal _operatorApprovals;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
/// @param name_ The collection name.
/// @param symbol_ The collection symbol.
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/* -------------------------------------------------------------------------- */
/* ERC165 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns true if this contract implements an interface from its ID.
/// @dev See the corresponding
/// [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
/// to learn more about how these IDs are created.
/// @return The implementation status.
function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool) {
return
interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721
interfaceId == 0x5b5e139f || // ERC165 Interface ID for ERC721Metadata
interfaceId == 0x780e9d63; // ERC165 Interface ID for ERC721Enumerable
}
/* -------------------------------------------------------------------------- */
/* METADATA LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the collection name.
/// @return The collection name.
function name() public view virtual returns (string memory) {
return _name;
}
/// @notice Returns the collection symbol.
/// @return The collection symbol.
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/// @notice Returns the Uniform Resource Identifier (URI) for `id` token.
/// @param id The token ID.
/// @return The URI.
function tokenURI(uint256 id) public view virtual returns (string memory);
/* -------------------------------------------------------------------------- */
/* ENUMERABLE LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the total amount of tokens stored by the contract.
/// @return The token supply.
function totalSupply() public view virtual returns (uint256);
/// @notice Returns a token ID owned by `owner` at a given `index` of its token list.
/// @dev Use along with {balanceOf} to enumerate all of `owner`'s tokens.
/// @param owner The address to query.
/// @param index The index to query.
/// @return The token ID.
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256);
/// @notice Returns a token ID at a given `index` of all the tokens stored by the contract.
/// @dev Use along with {totalSupply} to enumerate all tokens.
/// @param index The index to query.
/// @return The token ID.
function tokenByIndex(uint256 index) public view virtual returns (uint256);
/* -------------------------------------------------------------------------- */
/* ERC721 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the account approved for a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id Token ID to query.
/// @return The account approved for `id` token.
function getApproved(uint256 id) public virtual returns (address) {
require(_exists(id), "NONEXISTENT_TOKEN");
return _tokenApprovals[id];
}
/// @notice Returns if the `operator` is allowed to manage all of the assets of `owner`.
/// @param owner The address of the owner.
/// @param operator The address of the operator.
/// @return True if `operator` was approved by `owner`.
function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
return _operatorApprovals[owner][operator];
}
/// @notice Gives permission to `to` to transfer `id` token to another account.
/// @dev The approval is cleared when the token is transferred.
/// Only a single account can be approved at a time, so approving the zero address clears previous approvals.
/// Requirements:
/// - The caller must own the token or be an approved operator.
/// - `id` must exist.
/// Emits an {Approval} event.
/// @param spender The address of the spender to approve to.
/// @param id The token ID to approve.
function approve(address spender, uint256 id) public virtual {
address owner = ownerOf(id);
require(isApprovedForAll(owner, msg.sender) || msg.sender == owner, "NOT_AUTHORIZED");
_tokenApprovals[id] = spender;
emit Approval(owner, spender, id);
}
/// @notice Approve or remove `operator` as an operator for the caller.
/// @dev Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
/// Emits an {ApprovalForAll} event.
/// @param operator The address of the operator to approve.
/// @param approved The status to set.
function setApprovalForAll(address operator, bool approved) public virtual {
_operatorApprovals[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
/// @notice Transfers `id` token from `from` to `to`.
/// WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function transferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function safeTransferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// Additionally passes `data` in the callback.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
/// @param data The calldata to pass in the {ERC721TokenReceiver-onERC721Received} callback.
function safeTransferFrom(
address from,
address to,
uint256 id,
bytes memory data
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Returns the number of tokens in an account.
/// @param owner The address to query.
/// @return The balance.
function balanceOf(address owner) public view virtual returns (uint256);
/// @notice Returns the owner of a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id The token ID.
function ownerOf(uint256 id) public view virtual returns (address);
/* -------------------------------------------------------------------------- */
/* INTERNAL LOGIC */
/* -------------------------------------------------------------------------- */
/// @dev Returns whether a token ID exists.
/// Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
/// Tokens start existing when they are minted.
/// @param id Token ID to query.
function _exists(uint256 id) internal view virtual returns (bool);
/// @dev Transfers `id` from `from` to `to`.
/// Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function _transfer(
address from,
address to,
uint256 id
) internal virtual;
/// @dev Mints `amount` tokens to `to`.
/// Requirements:
/// - there must be `amount` tokens remaining unminted in the total collection.
/// - `to` cannot be the zero address.
/// Emits `amount` {Transfer} events.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _mint(address to, uint256 amount) internal virtual;
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// If `to` is a contract it must implement {ERC721TokenReceiver.onERC721Received}
/// that returns {ERC721TokenReceiver.onERC721Received.selector}.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _safeMint(address to, uint256 amount) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// Requirements:
/// - `id` must not exist.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver.onERC721Received}, which is called upon a safe transfer.
/// Additionally passes `data` in the callback.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
/// @param data The calldata to pass in the {ERC721TokenReceiver.onERC721Received} callback.
function _safeMint(
address to,
uint256 amount,
bytes memory data
) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/* -------------------------------------------------------------------------- */
/* UTILS */
/* -------------------------------------------------------------------------- */
/// @notice Converts a `uint256` to its ASCII `string` decimal representation.
/// @dev https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Strings.sol
function toString(uint256 value) internal pure virtual returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
} | _safeMint | function _safeMint(
address to,
uint256 amount,
bytes memory data
) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
| /// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// Requirements:
/// - `id` must not exist.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver.onERC721Received}, which is called upon a safe transfer.
/// Additionally passes `data` in the callback.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
/// @param data The calldata to pass in the {ERC721TokenReceiver.onERC721Received} callback. | NatSpecSingleLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
12417,
12731
]
} | 6,029 |
||||
Mingoes | contracts/src/ERC721/ERC721.sol | 0xe6f475c11ad693e48455fcaf7bca33fe84ce71b0 | Solidity | ERC721 | abstract contract ERC721 {
/* -------------------------------------------------------------------------- */
/* EVENTS */
/* -------------------------------------------------------------------------- */
/// @dev Emitted when `id` token is transferred from `from` to `to`.
event Transfer(address indexed from, address indexed to, uint256 indexed id);
/// @dev Emitted when `owner` enables `approved` to manage the `id` token.
event Approval(address indexed owner, address indexed spender, uint256 indexed id);
/// @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/* -------------------------------------------------------------------------- */
/* METADATA STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev The collection name.
string private _name;
/// @dev The collection symbol.
string private _symbol;
/* -------------------------------------------------------------------------- */
/* ERC721 STORAGE */
/* -------------------------------------------------------------------------- */
/// @dev ID => spender
mapping(uint256 => address) internal _tokenApprovals;
/// @dev owner => operator => approved
mapping(address => mapping(address => bool)) internal _operatorApprovals;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
/// @param name_ The collection name.
/// @param symbol_ The collection symbol.
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/* -------------------------------------------------------------------------- */
/* ERC165 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns true if this contract implements an interface from its ID.
/// @dev See the corresponding
/// [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
/// to learn more about how these IDs are created.
/// @return The implementation status.
function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool) {
return
interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721
interfaceId == 0x5b5e139f || // ERC165 Interface ID for ERC721Metadata
interfaceId == 0x780e9d63; // ERC165 Interface ID for ERC721Enumerable
}
/* -------------------------------------------------------------------------- */
/* METADATA LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the collection name.
/// @return The collection name.
function name() public view virtual returns (string memory) {
return _name;
}
/// @notice Returns the collection symbol.
/// @return The collection symbol.
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/// @notice Returns the Uniform Resource Identifier (URI) for `id` token.
/// @param id The token ID.
/// @return The URI.
function tokenURI(uint256 id) public view virtual returns (string memory);
/* -------------------------------------------------------------------------- */
/* ENUMERABLE LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the total amount of tokens stored by the contract.
/// @return The token supply.
function totalSupply() public view virtual returns (uint256);
/// @notice Returns a token ID owned by `owner` at a given `index` of its token list.
/// @dev Use along with {balanceOf} to enumerate all of `owner`'s tokens.
/// @param owner The address to query.
/// @param index The index to query.
/// @return The token ID.
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256);
/// @notice Returns a token ID at a given `index` of all the tokens stored by the contract.
/// @dev Use along with {totalSupply} to enumerate all tokens.
/// @param index The index to query.
/// @return The token ID.
function tokenByIndex(uint256 index) public view virtual returns (uint256);
/* -------------------------------------------------------------------------- */
/* ERC721 LOGIC */
/* -------------------------------------------------------------------------- */
/// @notice Returns the account approved for a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id Token ID to query.
/// @return The account approved for `id` token.
function getApproved(uint256 id) public virtual returns (address) {
require(_exists(id), "NONEXISTENT_TOKEN");
return _tokenApprovals[id];
}
/// @notice Returns if the `operator` is allowed to manage all of the assets of `owner`.
/// @param owner The address of the owner.
/// @param operator The address of the operator.
/// @return True if `operator` was approved by `owner`.
function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
return _operatorApprovals[owner][operator];
}
/// @notice Gives permission to `to` to transfer `id` token to another account.
/// @dev The approval is cleared when the token is transferred.
/// Only a single account can be approved at a time, so approving the zero address clears previous approvals.
/// Requirements:
/// - The caller must own the token or be an approved operator.
/// - `id` must exist.
/// Emits an {Approval} event.
/// @param spender The address of the spender to approve to.
/// @param id The token ID to approve.
function approve(address spender, uint256 id) public virtual {
address owner = ownerOf(id);
require(isApprovedForAll(owner, msg.sender) || msg.sender == owner, "NOT_AUTHORIZED");
_tokenApprovals[id] = spender;
emit Approval(owner, spender, id);
}
/// @notice Approve or remove `operator` as an operator for the caller.
/// @dev Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
/// Emits an {ApprovalForAll} event.
/// @param operator The address of the operator to approve.
/// @param approved The status to set.
function setApprovalForAll(address operator, bool approved) public virtual {
_operatorApprovals[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
/// @notice Transfers `id` token from `from` to `to`.
/// WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function transferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function safeTransferFrom(
address from,
address to,
uint256 id
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Safely transfers `id` token from `from` to `to`.
/// @dev Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must exist and be owned by `from`.
/// - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver-onERC721Received}, which is called upon a safe transfer.
/// Emits a {Transfer} event.
/// Additionally passes `data` in the callback.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
/// @param data The calldata to pass in the {ERC721TokenReceiver-onERC721Received} callback.
function safeTransferFrom(
address from,
address to,
uint256 id,
bytes memory data
) public virtual {
_transfer(from, to, id);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @notice Returns the number of tokens in an account.
/// @param owner The address to query.
/// @return The balance.
function balanceOf(address owner) public view virtual returns (uint256);
/// @notice Returns the owner of a token ID.
/// @dev Requirements:
/// - `id` must exist.
/// @param id The token ID.
function ownerOf(uint256 id) public view virtual returns (address);
/* -------------------------------------------------------------------------- */
/* INTERNAL LOGIC */
/* -------------------------------------------------------------------------- */
/// @dev Returns whether a token ID exists.
/// Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
/// Tokens start existing when they are minted.
/// @param id Token ID to query.
function _exists(uint256 id) internal view virtual returns (bool);
/// @dev Transfers `id` from `from` to `to`.
/// Requirements:
/// - `to` cannot be the zero address.
/// - `id` token must be owned by `from`.
/// Emits a {Transfer} event.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param id The token ID to transfer.
function _transfer(
address from,
address to,
uint256 id
) internal virtual;
/// @dev Mints `amount` tokens to `to`.
/// Requirements:
/// - there must be `amount` tokens remaining unminted in the total collection.
/// - `to` cannot be the zero address.
/// Emits `amount` {Transfer} events.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _mint(address to, uint256 amount) internal virtual;
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// If `to` is a contract it must implement {ERC721TokenReceiver.onERC721Received}
/// that returns {ERC721TokenReceiver.onERC721Received.selector}.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
function _safeMint(address to, uint256 amount) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, "") == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/// @dev Safely mints `amount` of tokens and transfers them to `to`.
/// Requirements:
/// - `id` must not exist.
/// - If `to` refers to a smart contract, it must implement {ERC721TokenReceiver.onERC721Received}, which is called upon a safe transfer.
/// Additionally passes `data` in the callback.
/// @param to The address to mint to.
/// @param amount The amount of tokens to mint.
/// @param data The calldata to pass in the {ERC721TokenReceiver.onERC721Received} callback.
function _safeMint(
address to,
uint256 amount,
bytes memory data
) internal virtual {
_mint(to, amount);
require(to.code.length == 0 || ERC721TokenReceiver(to).onERC721Received(address(0), to, totalSupply() - amount + 1, data) == ERC721TokenReceiver.onERC721Received.selector, "UNSAFE_RECIPIENT");
}
/* -------------------------------------------------------------------------- */
/* UTILS */
/* -------------------------------------------------------------------------- */
/// @notice Converts a `uint256` to its ASCII `string` decimal representation.
/// @dev https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Strings.sol
function toString(uint256 value) internal pure virtual returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
} | toString | function toString(uint256 value) internal pure virtual returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
| /// @notice Converts a `uint256` to its ASCII `string` decimal representation.
/// @dev https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Strings.sol | NatSpecSingleLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
13165,
13748
]
} | 6,030 |
||||
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | add | function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
| /**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
251,
437
]
} | 6,031 |
||
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | sub | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
| /**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
707,
848
]
} | 6,032 |
||
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | sub | function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
| /**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
1138,
1335
]
} | 6,033 |
||
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | mul | function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
| /**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
1581,
2057
]
} | 6,034 |
||
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | div | function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
| /**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
2520,
2657
]
} | 6,035 |
||
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | div | function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
| /**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
3140,
3423
]
} | 6,036 |
||
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | mod | function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
| /**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
3875,
4010
]
} | 6,037 |
||
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | mod | function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
| /**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
4482,
4653
]
} | 6,038 |
||
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
} | isContract | function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
| /**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
606,
1230
]
} | 6,039 |
||
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20MinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | totalSupply | function totalSupply() external view returns (uint256);
| /**
* @dev Returns the amount of tokens in existence.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
94,
154
]
} | 6,040 |
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20MinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | balanceOf | function balanceOf(address account) external view returns (uint256);
| /**
* @dev Returns the amount of tokens owned by `account`.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
237,
310
]
} | 6,041 |
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20MinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | transfer | function transfer(address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
534,
616
]
} | 6,042 |
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20MinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | allowance | function allowance(address owner, address spender) external view returns (uint256);
| /**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
895,
983
]
} | 6,043 |
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20MinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | approve | function approve(address spender, uint256 amount) external returns (bool);
| /**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
1647,
1726
]
} | 6,044 |
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20MinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | transferFrom | function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
2039,
2141
]
} | 6,045 |
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | name | function name() public view returns (string memory) {
return _name;
}
| /**
* @dev Returns the name of the token.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
902,
990
]
} | 6,046 |
||
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | symbol | function symbol() public view returns (string memory) {
return _symbol;
}
| /**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
1104,
1196
]
} | 6,047 |
||
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | decimals | function decimals() public view returns (uint8) {
return _decimals;
}
| /**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
1829,
1917
]
} | 6,048 |
||
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | totalSupply | function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
| /**
* @dev See {IERC20-totalSupply}.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
1977,
2082
]
} | 6,049 |
||
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | balanceOf | function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
| /**
* @dev See {IERC20-balanceOf}.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
2140,
2264
]
} | 6,050 |
||
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | transfer | function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
| /**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
2472,
2652
]
} | 6,051 |
||
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | allowance | function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
| /**
* @dev See {IERC20-allowance}.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
2710,
2866
]
} | 6,052 |
||
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | approve | function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
| /**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
3008,
3182
]
} | 6,053 |
||
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | transferFrom | function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
| /**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
3651,
3977
]
} | 6,054 |
||
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | increaseAllowance | function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
| /**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
4381,
4604
]
} | 6,055 |
||
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | decreaseAllowance | function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
| /**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
5102,
5376
]
} | 6,056 |
||
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | _transfer | function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
| /**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
5861,
6405
]
} | 6,057 |
||
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | _mint | function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
| /** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
6681,
7064
]
} | 6,058 |
||
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | _burn | function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
| /**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
7391,
7814
]
} | 6,059 |
||
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | _approve | function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
| /**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
8249,
8600
]
} | 6,060 |
||
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | _setupDecimals | function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
| /**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
8927,
9022
]
} | 6,061 |
||
Camouflage | Camouflage.sol | 0x0bb7db697567178c590efa64a7dcb2ce6213768c | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | _beforeTokenTransfer | function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
| /**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/ | NatSpecMultiLine | v0.6.0+commit.26b70077 | GNU GPLv2 | ipfs://ed2bbb414fc83aeb430340251c3e73c2ad927dddf3b739f6c723a3cbbd85c6ad | {
"func_code_index": [
9620,
9717
]
} | 6,062 |
||
KakashiInu | KakashiInu.sol | 0x2afe947da357679ae3e7d3b54bab4fa904d21c65 | Solidity | KakashiInu | contract KakashiInu 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 = "Kakashi-Inu";
string private constant _symbol = "HATAKE";
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;
uint256 public maxWalletAmount;
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 * 400;
_rOwned[address(this)] = _rTotal / 1000 * 600;
maxTransactionAmount = _tTotal * 5 / 1000; // 0.5% maxTransactionAmountTxn
maxWalletAmount = _tTotal * 15 / 1000; // 1.5% maxWalletAmount
minimumTokensBeforeSwap = _tTotal * 5 / 10000; // 0.05% swap tokens amount
marketingAddress = payable(0xdD54C821566a6119B5A894A43ee33F80FAA4A60F); // Marketing Address
devAddress = payable(0xc23062d9b7d1048119a29C59EFeC76C2Fec0Ba68); // Dev Address
liquidityAddress = payable(owner());
_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 * 400 / 1000);
emit Transfer(address(0), address(this), _tTotal * 600 / 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 (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] * (10 ** _decimals);
_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);
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 {
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 is 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 && _holderLastTransferTimestamp[tx.origin] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed.");
_holderLastTransferTimestamp[to] = block.number;
_holderLastTransferTimestamp[tx.origin] = 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.");
}
if (!_isExcludedMaxTransactionAmount[to]) {
require(balanceOf(to) + amount <= maxWalletAmount, "Max wallet exceeded");
}
}
}
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 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 gos 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 BNB 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 | MIT | ipfs://26fe8cb0c3133224ff4fc393f1c7aff93c2e83eba46b8c78781d2ce471ee7178 | {
"func_code_index": [
8419,
8616
]
} | 6,063 |
||
KakashiInu | KakashiInu.sol | 0x2afe947da357679ae3e7d3b54bab4fa904d21c65 | Solidity | KakashiInu | contract KakashiInu 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 = "Kakashi-Inu";
string private constant _symbol = "HATAKE";
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;
uint256 public maxWalletAmount;
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 * 400;
_rOwned[address(this)] = _rTotal / 1000 * 600;
maxTransactionAmount = _tTotal * 5 / 1000; // 0.5% maxTransactionAmountTxn
maxWalletAmount = _tTotal * 15 / 1000; // 1.5% maxWalletAmount
minimumTokensBeforeSwap = _tTotal * 5 / 10000; // 0.05% swap tokens amount
marketingAddress = payable(0xdD54C821566a6119B5A894A43ee33F80FAA4A60F); // Marketing Address
devAddress = payable(0xc23062d9b7d1048119a29C59EFeC76C2Fec0Ba68); // Dev Address
liquidityAddress = payable(owner());
_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 * 400 / 1000);
emit Transfer(address(0), address(this), _tTotal * 600 / 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 (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] * (10 ** _decimals);
_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);
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 {
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 is 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 && _holderLastTransferTimestamp[tx.origin] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed.");
_holderLastTransferTimestamp[to] = block.number;
_holderLastTransferTimestamp[tx.origin] = 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.");
}
if (!_isExcludedMaxTransactionAmount[to]) {
require(balanceOf(to) + amount <= maxWalletAmount, "Max wallet exceeded");
}
}
}
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 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 gos 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 BNB 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 | MIT | ipfs://26fe8cb0c3133224ff4fc393f1c7aff93c2e83eba46b8c78781d2ce471ee7178 | {
"func_code_index": [
8654,
8793
]
} | 6,064 |
||
KakashiInu | KakashiInu.sol | 0x2afe947da357679ae3e7d3b54bab4fa904d21c65 | Solidity | KakashiInu | contract KakashiInu 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 = "Kakashi-Inu";
string private constant _symbol = "HATAKE";
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;
uint256 public maxWalletAmount;
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 * 400;
_rOwned[address(this)] = _rTotal / 1000 * 600;
maxTransactionAmount = _tTotal * 5 / 1000; // 0.5% maxTransactionAmountTxn
maxWalletAmount = _tTotal * 15 / 1000; // 1.5% maxWalletAmount
minimumTokensBeforeSwap = _tTotal * 5 / 10000; // 0.05% swap tokens amount
marketingAddress = payable(0xdD54C821566a6119B5A894A43ee33F80FAA4A60F); // Marketing Address
devAddress = payable(0xc23062d9b7d1048119a29C59EFeC76C2Fec0Ba68); // Dev Address
liquidityAddress = payable(owner());
_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 * 400 / 1000);
emit Transfer(address(0), address(this), _tTotal * 600 / 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 (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] * (10 ** _decimals);
_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);
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 {
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 is 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 && _holderLastTransferTimestamp[tx.origin] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed.");
_holderLastTransferTimestamp[to] = block.number;
_holderLastTransferTimestamp[tx.origin] = 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.");
}
if (!_isExcludedMaxTransactionAmount[to]) {
require(balanceOf(to) + amount <= maxWalletAmount, "Max wallet exceeded");
}
}
}
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 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 gos 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 BNB 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 | MIT | ipfs://26fe8cb0c3133224ff4fc393f1c7aff93c2e83eba46b8c78781d2ce471ee7178 | {
"func_code_index": [
9002,
9231
]
} | 6,065 |
||
KakashiInu | KakashiInu.sol | 0x2afe947da357679ae3e7d3b54bab4fa904d21c65 | Solidity | KakashiInu | contract KakashiInu 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 = "Kakashi-Inu";
string private constant _symbol = "HATAKE";
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;
uint256 public maxWalletAmount;
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 * 400;
_rOwned[address(this)] = _rTotal / 1000 * 600;
maxTransactionAmount = _tTotal * 5 / 1000; // 0.5% maxTransactionAmountTxn
maxWalletAmount = _tTotal * 15 / 1000; // 1.5% maxWalletAmount
minimumTokensBeforeSwap = _tTotal * 5 / 10000; // 0.05% swap tokens amount
marketingAddress = payable(0xdD54C821566a6119B5A894A43ee33F80FAA4A60F); // Marketing Address
devAddress = payable(0xc23062d9b7d1048119a29C59EFeC76C2Fec0Ba68); // Dev Address
liquidityAddress = payable(owner());
_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 * 400 / 1000);
emit Transfer(address(0), address(this), _tTotal * 600 / 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 (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] * (10 ** _decimals);
_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);
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 {
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 is 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 && _holderLastTransferTimestamp[tx.origin] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed.");
_holderLastTransferTimestamp[to] = block.number;
_holderLastTransferTimestamp[tx.origin] = 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.");
}
if (!_isExcludedMaxTransactionAmount[to]) {
require(balanceOf(to) + amount <= maxWalletAmount, "Max wallet exceeded");
}
}
}
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 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 gos 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 BNB 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] * (10 ** _decimals);
_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);
return true;
}
| // send tokens and ETH for liquidity to contract directly, then call this (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 | MIT | ipfs://26fe8cb0c3133224ff4fc393f1c7aff93c2e83eba46b8c78781d2ce471ee7178 | {
"func_code_index": [
9468,
10864
]
} | 6,066 |
||
KakashiInu | KakashiInu.sol | 0x2afe947da357679ae3e7d3b54bab4fa904d21c65 | Solidity | KakashiInu | contract KakashiInu 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 = "Kakashi-Inu";
string private constant _symbol = "HATAKE";
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;
uint256 public maxWalletAmount;
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 * 400;
_rOwned[address(this)] = _rTotal / 1000 * 600;
maxTransactionAmount = _tTotal * 5 / 1000; // 0.5% maxTransactionAmountTxn
maxWalletAmount = _tTotal * 15 / 1000; // 1.5% maxWalletAmount
minimumTokensBeforeSwap = _tTotal * 5 / 10000; // 0.05% swap tokens amount
marketingAddress = payable(0xdD54C821566a6119B5A894A43ee33F80FAA4A60F); // Marketing Address
devAddress = payable(0xc23062d9b7d1048119a29C59EFeC76C2Fec0Ba68); // Dev Address
liquidityAddress = payable(owner());
_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 * 400 / 1000);
emit Transfer(address(0), address(this), _tTotal * 600 / 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 (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] * (10 ** _decimals);
_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);
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 {
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 is 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 && _holderLastTransferTimestamp[tx.origin] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed.");
_holderLastTransferTimestamp[to] = block.number;
_holderLastTransferTimestamp[tx.origin] = 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.");
}
if (!_isExcludedMaxTransactionAmount[to]) {
require(balanceOf(to) + amount <= maxWalletAmount, "Max wallet exceeded");
}
}
}
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 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 gos 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 BNB 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 | MIT | ipfs://26fe8cb0c3133224ff4fc393f1c7aff93c2e83eba46b8c78781d2ce471ee7178 | {
"func_code_index": [
20542,
20851
]
} | 6,067 |
||
KakashiInu | KakashiInu.sol | 0x2afe947da357679ae3e7d3b54bab4fa904d21c65 | Solidity | KakashiInu | contract KakashiInu 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 = "Kakashi-Inu";
string private constant _symbol = "HATAKE";
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;
uint256 public maxWalletAmount;
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 * 400;
_rOwned[address(this)] = _rTotal / 1000 * 600;
maxTransactionAmount = _tTotal * 5 / 1000; // 0.5% maxTransactionAmountTxn
maxWalletAmount = _tTotal * 15 / 1000; // 1.5% maxWalletAmount
minimumTokensBeforeSwap = _tTotal * 5 / 10000; // 0.05% swap tokens amount
marketingAddress = payable(0xdD54C821566a6119B5A894A43ee33F80FAA4A60F); // Marketing Address
devAddress = payable(0xc23062d9b7d1048119a29C59EFeC76C2Fec0Ba68); // Dev Address
liquidityAddress = payable(owner());
_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 * 400 / 1000);
emit Transfer(address(0), address(this), _tTotal * 600 / 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 (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] * (10 ** _decimals);
_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);
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 {
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 is 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 && _holderLastTransferTimestamp[tx.origin] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed.");
_holderLastTransferTimestamp[to] = block.number;
_holderLastTransferTimestamp[tx.origin] = 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.");
}
if (!_isExcludedMaxTransactionAmount[to]) {
require(balanceOf(to) + amount <= maxWalletAmount, "Max wallet exceeded");
}
}
}
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 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 gos 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 BNB 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 | MIT | ipfs://26fe8cb0c3133224ff4fc393f1c7aff93c2e83eba46b8c78781d2ce471ee7178 | {
"func_code_index": [
32004,
32038
]
} | 6,068 |
||||
KakashiInu | KakashiInu.sol | 0x2afe947da357679ae3e7d3b54bab4fa904d21c65 | Solidity | KakashiInu | contract KakashiInu 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 = "Kakashi-Inu";
string private constant _symbol = "HATAKE";
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;
uint256 public maxWalletAmount;
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 * 400;
_rOwned[address(this)] = _rTotal / 1000 * 600;
maxTransactionAmount = _tTotal * 5 / 1000; // 0.5% maxTransactionAmountTxn
maxWalletAmount = _tTotal * 15 / 1000; // 1.5% maxWalletAmount
minimumTokensBeforeSwap = _tTotal * 5 / 10000; // 0.05% swap tokens amount
marketingAddress = payable(0xdD54C821566a6119B5A894A43ee33F80FAA4A60F); // Marketing Address
devAddress = payable(0xc23062d9b7d1048119a29C59EFeC76C2Fec0Ba68); // Dev Address
liquidityAddress = payable(owner());
_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 * 400 / 1000);
emit Transfer(address(0), address(this), _tTotal * 600 / 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 (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] * (10 ** _decimals);
_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);
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 {
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 is 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 && _holderLastTransferTimestamp[tx.origin] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed.");
_holderLastTransferTimestamp[to] = block.number;
_holderLastTransferTimestamp[tx.origin] = 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.");
}
if (!_isExcludedMaxTransactionAmount[to]) {
require(balanceOf(to) + amount <= maxWalletAmount, "Max wallet exceeded");
}
}
}
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 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 gos 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 BNB 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 | MIT | ipfs://26fe8cb0c3133224ff4fc393f1c7aff93c2e83eba46b8c78781d2ce471ee7178 | {
"func_code_index": [
32585,
32831
]
} | 6,069 |
||
DeltaChainToken | DeltaChainToken.sol | 0xec82fffd7c1961904fdbb4cbd98f06d9dd0870a8 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
* Name : DeltaChain (Delta)
* Decimals : 8
* TotalSupply : 30000000000
*
*
*
*
*/ | NatSpecMultiLine | mul | function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
| /**
* @dev Multiplies two numbers, throws on overflow.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://0c08fd3a8699c778f6d6ad96a488e82381f843d586d74388e5b7495eec5d88ca | {
"func_code_index": [
95,
302
]
} | 6,070 |
|
DeltaChainToken | DeltaChainToken.sol | 0xec82fffd7c1961904fdbb4cbd98f06d9dd0870a8 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
* Name : DeltaChain (Delta)
* Decimals : 8
* TotalSupply : 30000000000
*
*
*
*
*/ | NatSpecMultiLine | div | function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
| /**
* @dev Integer division of two numbers, truncating the quotient.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://0c08fd3a8699c778f6d6ad96a488e82381f843d586d74388e5b7495eec5d88ca | {
"func_code_index": [
392,
692
]
} | 6,071 |
|
DeltaChainToken | DeltaChainToken.sol | 0xec82fffd7c1961904fdbb4cbd98f06d9dd0870a8 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
* Name : DeltaChain (Delta)
* Decimals : 8
* TotalSupply : 30000000000
*
*
*
*
*/ | NatSpecMultiLine | sub | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
| /**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://0c08fd3a8699c778f6d6ad96a488e82381f843d586d74388e5b7495eec5d88ca | {
"func_code_index": [
812,
940
]
} | 6,072 |
|
DeltaChainToken | DeltaChainToken.sol | 0xec82fffd7c1961904fdbb4cbd98f06d9dd0870a8 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
* Name : DeltaChain (Delta)
* Decimals : 8
* TotalSupply : 30000000000
*
*
*
*
*/ | NatSpecMultiLine | add | function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
| /**
* @dev Adds two numbers, throws on overflow.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://0c08fd3a8699c778f6d6ad96a488e82381f843d586d74388e5b7495eec5d88ca | {
"func_code_index": [
1010,
1156
]
} | 6,073 |
|
Mingoes | contracts/src/Mingoes.sol | 0xe6f475c11ad693e48455fcaf7bca33fe84ce71b0 | Solidity | Mingoes | contract Mingoes is ERC721M, ERC721Tradable, Ownable {
uint256 public constant PRICE = 0.04 ether;
uint256 public constant MAX_SUPPLY = 10000;
uint256 public constant MAX_RESERVE = 300;
uint256 public constant MAX_PUBLIC = 9700; // MAX_SUPPLY - MAX_RESERVE
uint256 public constant MAX_FREE = 200;
uint256 public constant MAX_TX = 20;
uint256 public reservesMinted;
string public baseURI;
bool public isSaleActive;
mapping (address => bool) public hasClaimed;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
constructor(
address _openSeaProxyRegistry,
address _looksRareTransferManager,
string memory _baseURI
) payable ERC721M("Mingoes", "MINGOES") ERC721Tradable(_openSeaProxyRegistry, _looksRareTransferManager) {
baseURI = _baseURI;
}
/* -------------------------------------------------------------------------- */
/* USER */
/* -------------------------------------------------------------------------- */
/// @notice Mints an amount of tokens and transfers them to the caller during the public sale.
/// @param amount The amount of tokens to mint.
function publicMint(uint256 amount) external payable {
require(isSaleActive, "Sale is not active");
require(msg.sender == tx.origin, "No contracts allowed");
uint256 _totalSupply = totalSupply();
if (_totalSupply < MAX_FREE) {
require(!hasClaimed[msg.sender], "Already claimed");
hasClaimed[msg.sender] = true;
_mint(msg.sender, 1);
return;
}
require(msg.value == PRICE * amount, "Wrong ether amount");
require(amount <= MAX_TX, "Amount exceeds tx limit");
require(_totalSupply + amount <= MAX_PUBLIC, "Max public supply reached");
_mint(msg.sender, amount);
}
/* -------------------------------------------------------------------------- */
/* OWNER */
/* -------------------------------------------------------------------------- */
/// @notice Enables or disables minting through {publicMint}.
/// @dev Requirements:
/// - Caller must be the owner.
function setIsSaleActive(bool _isSaleActive) external onlyOwner {
isSaleActive = _isSaleActive;
}
/// @notice Mints tokens to multiple addresses.
/// @dev Requirements:
/// - Caller must be the owner.
/// @param recipients The addresses to mint the tokens to.
/// @param amounts The amounts of tokens to mint.
function reserveMint(address[] calldata recipients, uint256[] calldata amounts) external onlyOwner {
unchecked {
uint256 sum;
uint256 length = recipients.length;
for (uint256 i; i < length; i++) {
address to = recipients[i];
require(to != address(0), "Invalid recipient");
uint256 amount = amounts[i];
_mint(to, amount);
sum += amount;
}
uint256 totalReserves = reservesMinted + sum;
require(totalSupply() <= MAX_SUPPLY, "Max supply reached");
require(totalReserves <= MAX_RESERVE, "Amount exceeds reserve limit");
reservesMinted = totalReserves;
}
}
/// @notice Sets the base Uniform Resource Identifier (URI) for token metadata.
/// @dev Requirements:
/// - Caller must be the owner.
/// @param _baseURI The base URI.
function setBaseURI(string calldata _baseURI) external onlyOwner {
baseURI = _baseURI;
}
/// @notice Withdraws all contract balance to the caller.
/// @dev Requirements:
/// - Caller must be the owner.
function withdrawETH() external onlyOwner {
_transferETH(msg.sender, address(this).balance);
}
/// @dev Requirements:
/// - Caller must be the owner.
/// @inheritdoc ERC721Tradable
function setMarketplaceApprovalForAll(bool approved) public override onlyOwner {
marketPlaceApprovalForAll = approved;
}
/* -------------------------------------------------------------------------- */
/* SOLIDITY OVERRIDES */
/* -------------------------------------------------------------------------- */
/// @inheritdoc ERC721
function tokenURI(uint256 id) public view override returns (string memory) {
require(_exists(id), "NONEXISTENT_TOKEN");
string memory _baseURI = baseURI;
return bytes(_baseURI).length == 0 ? "" : string(abi.encodePacked(_baseURI, toString(id)));
}
/// @inheritdoc ERC721Tradable
function isApprovedForAll(address owner, address operator) public view override(ERC721, ERC721Tradable) returns (bool) {
return ERC721Tradable.isApprovedForAll(owner, operator);
}
/* -------------------------------------------------------------------------- */
/* UTILS */
/* -------------------------------------------------------------------------- */
function _transferETH(address to, uint256 value) internal {
// solhint-disable-next-line avoid-low-level-calls
(bool success, ) = to.call{ value: value }("");
require(success, "ETH transfer failed");
}
} | publicMint | function publicMint(uint256 amount) external payable {
require(isSaleActive, "Sale is not active");
require(msg.sender == tx.origin, "No contracts allowed");
uint256 _totalSupply = totalSupply();
if (_totalSupply < MAX_FREE) {
require(!hasClaimed[msg.sender], "Already claimed");
hasClaimed[msg.sender] = true;
_mint(msg.sender, 1);
return;
}
require(msg.value == PRICE * amount, "Wrong ether amount");
require(amount <= MAX_TX, "Amount exceeds tx limit");
require(_totalSupply + amount <= MAX_PUBLIC, "Max public supply reached");
_mint(msg.sender, amount);
}
| /// @notice Mints an amount of tokens and transfers them to the caller during the public sale.
/// @param amount The amount of tokens to mint. | NatSpecSingleLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
1358,
1964
]
} | 6,074 |
||||
Mingoes | contracts/src/Mingoes.sol | 0xe6f475c11ad693e48455fcaf7bca33fe84ce71b0 | Solidity | Mingoes | contract Mingoes is ERC721M, ERC721Tradable, Ownable {
uint256 public constant PRICE = 0.04 ether;
uint256 public constant MAX_SUPPLY = 10000;
uint256 public constant MAX_RESERVE = 300;
uint256 public constant MAX_PUBLIC = 9700; // MAX_SUPPLY - MAX_RESERVE
uint256 public constant MAX_FREE = 200;
uint256 public constant MAX_TX = 20;
uint256 public reservesMinted;
string public baseURI;
bool public isSaleActive;
mapping (address => bool) public hasClaimed;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
constructor(
address _openSeaProxyRegistry,
address _looksRareTransferManager,
string memory _baseURI
) payable ERC721M("Mingoes", "MINGOES") ERC721Tradable(_openSeaProxyRegistry, _looksRareTransferManager) {
baseURI = _baseURI;
}
/* -------------------------------------------------------------------------- */
/* USER */
/* -------------------------------------------------------------------------- */
/// @notice Mints an amount of tokens and transfers them to the caller during the public sale.
/// @param amount The amount of tokens to mint.
function publicMint(uint256 amount) external payable {
require(isSaleActive, "Sale is not active");
require(msg.sender == tx.origin, "No contracts allowed");
uint256 _totalSupply = totalSupply();
if (_totalSupply < MAX_FREE) {
require(!hasClaimed[msg.sender], "Already claimed");
hasClaimed[msg.sender] = true;
_mint(msg.sender, 1);
return;
}
require(msg.value == PRICE * amount, "Wrong ether amount");
require(amount <= MAX_TX, "Amount exceeds tx limit");
require(_totalSupply + amount <= MAX_PUBLIC, "Max public supply reached");
_mint(msg.sender, amount);
}
/* -------------------------------------------------------------------------- */
/* OWNER */
/* -------------------------------------------------------------------------- */
/// @notice Enables or disables minting through {publicMint}.
/// @dev Requirements:
/// - Caller must be the owner.
function setIsSaleActive(bool _isSaleActive) external onlyOwner {
isSaleActive = _isSaleActive;
}
/// @notice Mints tokens to multiple addresses.
/// @dev Requirements:
/// - Caller must be the owner.
/// @param recipients The addresses to mint the tokens to.
/// @param amounts The amounts of tokens to mint.
function reserveMint(address[] calldata recipients, uint256[] calldata amounts) external onlyOwner {
unchecked {
uint256 sum;
uint256 length = recipients.length;
for (uint256 i; i < length; i++) {
address to = recipients[i];
require(to != address(0), "Invalid recipient");
uint256 amount = amounts[i];
_mint(to, amount);
sum += amount;
}
uint256 totalReserves = reservesMinted + sum;
require(totalSupply() <= MAX_SUPPLY, "Max supply reached");
require(totalReserves <= MAX_RESERVE, "Amount exceeds reserve limit");
reservesMinted = totalReserves;
}
}
/// @notice Sets the base Uniform Resource Identifier (URI) for token metadata.
/// @dev Requirements:
/// - Caller must be the owner.
/// @param _baseURI The base URI.
function setBaseURI(string calldata _baseURI) external onlyOwner {
baseURI = _baseURI;
}
/// @notice Withdraws all contract balance to the caller.
/// @dev Requirements:
/// - Caller must be the owner.
function withdrawETH() external onlyOwner {
_transferETH(msg.sender, address(this).balance);
}
/// @dev Requirements:
/// - Caller must be the owner.
/// @inheritdoc ERC721Tradable
function setMarketplaceApprovalForAll(bool approved) public override onlyOwner {
marketPlaceApprovalForAll = approved;
}
/* -------------------------------------------------------------------------- */
/* SOLIDITY OVERRIDES */
/* -------------------------------------------------------------------------- */
/// @inheritdoc ERC721
function tokenURI(uint256 id) public view override returns (string memory) {
require(_exists(id), "NONEXISTENT_TOKEN");
string memory _baseURI = baseURI;
return bytes(_baseURI).length == 0 ? "" : string(abi.encodePacked(_baseURI, toString(id)));
}
/// @inheritdoc ERC721Tradable
function isApprovedForAll(address owner, address operator) public view override(ERC721, ERC721Tradable) returns (bool) {
return ERC721Tradable.isApprovedForAll(owner, operator);
}
/* -------------------------------------------------------------------------- */
/* UTILS */
/* -------------------------------------------------------------------------- */
function _transferETH(address to, uint256 value) internal {
// solhint-disable-next-line avoid-low-level-calls
(bool success, ) = to.call{ value: value }("");
require(success, "ETH transfer failed");
}
} | setIsSaleActive | function setIsSaleActive(bool _isSaleActive) external onlyOwner {
isSaleActive = _isSaleActive;
}
| /// @notice Enables or disables minting through {publicMint}.
/// @dev Requirements:
/// - Caller must be the owner. | NatSpecSingleLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
2333,
2434
]
} | 6,075 |
||||
Mingoes | contracts/src/Mingoes.sol | 0xe6f475c11ad693e48455fcaf7bca33fe84ce71b0 | Solidity | Mingoes | contract Mingoes is ERC721M, ERC721Tradable, Ownable {
uint256 public constant PRICE = 0.04 ether;
uint256 public constant MAX_SUPPLY = 10000;
uint256 public constant MAX_RESERVE = 300;
uint256 public constant MAX_PUBLIC = 9700; // MAX_SUPPLY - MAX_RESERVE
uint256 public constant MAX_FREE = 200;
uint256 public constant MAX_TX = 20;
uint256 public reservesMinted;
string public baseURI;
bool public isSaleActive;
mapping (address => bool) public hasClaimed;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
constructor(
address _openSeaProxyRegistry,
address _looksRareTransferManager,
string memory _baseURI
) payable ERC721M("Mingoes", "MINGOES") ERC721Tradable(_openSeaProxyRegistry, _looksRareTransferManager) {
baseURI = _baseURI;
}
/* -------------------------------------------------------------------------- */
/* USER */
/* -------------------------------------------------------------------------- */
/// @notice Mints an amount of tokens and transfers them to the caller during the public sale.
/// @param amount The amount of tokens to mint.
function publicMint(uint256 amount) external payable {
require(isSaleActive, "Sale is not active");
require(msg.sender == tx.origin, "No contracts allowed");
uint256 _totalSupply = totalSupply();
if (_totalSupply < MAX_FREE) {
require(!hasClaimed[msg.sender], "Already claimed");
hasClaimed[msg.sender] = true;
_mint(msg.sender, 1);
return;
}
require(msg.value == PRICE * amount, "Wrong ether amount");
require(amount <= MAX_TX, "Amount exceeds tx limit");
require(_totalSupply + amount <= MAX_PUBLIC, "Max public supply reached");
_mint(msg.sender, amount);
}
/* -------------------------------------------------------------------------- */
/* OWNER */
/* -------------------------------------------------------------------------- */
/// @notice Enables or disables minting through {publicMint}.
/// @dev Requirements:
/// - Caller must be the owner.
function setIsSaleActive(bool _isSaleActive) external onlyOwner {
isSaleActive = _isSaleActive;
}
/// @notice Mints tokens to multiple addresses.
/// @dev Requirements:
/// - Caller must be the owner.
/// @param recipients The addresses to mint the tokens to.
/// @param amounts The amounts of tokens to mint.
function reserveMint(address[] calldata recipients, uint256[] calldata amounts) external onlyOwner {
unchecked {
uint256 sum;
uint256 length = recipients.length;
for (uint256 i; i < length; i++) {
address to = recipients[i];
require(to != address(0), "Invalid recipient");
uint256 amount = amounts[i];
_mint(to, amount);
sum += amount;
}
uint256 totalReserves = reservesMinted + sum;
require(totalSupply() <= MAX_SUPPLY, "Max supply reached");
require(totalReserves <= MAX_RESERVE, "Amount exceeds reserve limit");
reservesMinted = totalReserves;
}
}
/// @notice Sets the base Uniform Resource Identifier (URI) for token metadata.
/// @dev Requirements:
/// - Caller must be the owner.
/// @param _baseURI The base URI.
function setBaseURI(string calldata _baseURI) external onlyOwner {
baseURI = _baseURI;
}
/// @notice Withdraws all contract balance to the caller.
/// @dev Requirements:
/// - Caller must be the owner.
function withdrawETH() external onlyOwner {
_transferETH(msg.sender, address(this).balance);
}
/// @dev Requirements:
/// - Caller must be the owner.
/// @inheritdoc ERC721Tradable
function setMarketplaceApprovalForAll(bool approved) public override onlyOwner {
marketPlaceApprovalForAll = approved;
}
/* -------------------------------------------------------------------------- */
/* SOLIDITY OVERRIDES */
/* -------------------------------------------------------------------------- */
/// @inheritdoc ERC721
function tokenURI(uint256 id) public view override returns (string memory) {
require(_exists(id), "NONEXISTENT_TOKEN");
string memory _baseURI = baseURI;
return bytes(_baseURI).length == 0 ? "" : string(abi.encodePacked(_baseURI, toString(id)));
}
/// @inheritdoc ERC721Tradable
function isApprovedForAll(address owner, address operator) public view override(ERC721, ERC721Tradable) returns (bool) {
return ERC721Tradable.isApprovedForAll(owner, operator);
}
/* -------------------------------------------------------------------------- */
/* UTILS */
/* -------------------------------------------------------------------------- */
function _transferETH(address to, uint256 value) internal {
// solhint-disable-next-line avoid-low-level-calls
(bool success, ) = to.call{ value: value }("");
require(success, "ETH transfer failed");
}
} | reserveMint | function reserveMint(address[] calldata recipients, uint256[] calldata amounts) external onlyOwner {
unchecked {
uint256 sum;
uint256 length = recipients.length;
for (uint256 i; i < length; i++) {
address to = recipients[i];
require(to != address(0), "Invalid recipient");
uint256 amount = amounts[i];
_mint(to, amount);
sum += amount;
}
uint256 totalReserves = reservesMinted + sum;
require(totalSupply() <= MAX_SUPPLY, "Max supply reached");
require(totalReserves <= MAX_RESERVE, "Amount exceeds reserve limit");
reservesMinted = totalReserves;
}
}
| /// @notice Mints tokens to multiple addresses.
/// @dev Requirements:
/// - Caller must be the owner.
/// @param recipients The addresses to mint the tokens to.
/// @param amounts The amounts of tokens to mint. | NatSpecSingleLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
2653,
3257
]
} | 6,076 |
||||
Mingoes | contracts/src/Mingoes.sol | 0xe6f475c11ad693e48455fcaf7bca33fe84ce71b0 | Solidity | Mingoes | contract Mingoes is ERC721M, ERC721Tradable, Ownable {
uint256 public constant PRICE = 0.04 ether;
uint256 public constant MAX_SUPPLY = 10000;
uint256 public constant MAX_RESERVE = 300;
uint256 public constant MAX_PUBLIC = 9700; // MAX_SUPPLY - MAX_RESERVE
uint256 public constant MAX_FREE = 200;
uint256 public constant MAX_TX = 20;
uint256 public reservesMinted;
string public baseURI;
bool public isSaleActive;
mapping (address => bool) public hasClaimed;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
constructor(
address _openSeaProxyRegistry,
address _looksRareTransferManager,
string memory _baseURI
) payable ERC721M("Mingoes", "MINGOES") ERC721Tradable(_openSeaProxyRegistry, _looksRareTransferManager) {
baseURI = _baseURI;
}
/* -------------------------------------------------------------------------- */
/* USER */
/* -------------------------------------------------------------------------- */
/// @notice Mints an amount of tokens and transfers them to the caller during the public sale.
/// @param amount The amount of tokens to mint.
function publicMint(uint256 amount) external payable {
require(isSaleActive, "Sale is not active");
require(msg.sender == tx.origin, "No contracts allowed");
uint256 _totalSupply = totalSupply();
if (_totalSupply < MAX_FREE) {
require(!hasClaimed[msg.sender], "Already claimed");
hasClaimed[msg.sender] = true;
_mint(msg.sender, 1);
return;
}
require(msg.value == PRICE * amount, "Wrong ether amount");
require(amount <= MAX_TX, "Amount exceeds tx limit");
require(_totalSupply + amount <= MAX_PUBLIC, "Max public supply reached");
_mint(msg.sender, amount);
}
/* -------------------------------------------------------------------------- */
/* OWNER */
/* -------------------------------------------------------------------------- */
/// @notice Enables or disables minting through {publicMint}.
/// @dev Requirements:
/// - Caller must be the owner.
function setIsSaleActive(bool _isSaleActive) external onlyOwner {
isSaleActive = _isSaleActive;
}
/// @notice Mints tokens to multiple addresses.
/// @dev Requirements:
/// - Caller must be the owner.
/// @param recipients The addresses to mint the tokens to.
/// @param amounts The amounts of tokens to mint.
function reserveMint(address[] calldata recipients, uint256[] calldata amounts) external onlyOwner {
unchecked {
uint256 sum;
uint256 length = recipients.length;
for (uint256 i; i < length; i++) {
address to = recipients[i];
require(to != address(0), "Invalid recipient");
uint256 amount = amounts[i];
_mint(to, amount);
sum += amount;
}
uint256 totalReserves = reservesMinted + sum;
require(totalSupply() <= MAX_SUPPLY, "Max supply reached");
require(totalReserves <= MAX_RESERVE, "Amount exceeds reserve limit");
reservesMinted = totalReserves;
}
}
/// @notice Sets the base Uniform Resource Identifier (URI) for token metadata.
/// @dev Requirements:
/// - Caller must be the owner.
/// @param _baseURI The base URI.
function setBaseURI(string calldata _baseURI) external onlyOwner {
baseURI = _baseURI;
}
/// @notice Withdraws all contract balance to the caller.
/// @dev Requirements:
/// - Caller must be the owner.
function withdrawETH() external onlyOwner {
_transferETH(msg.sender, address(this).balance);
}
/// @dev Requirements:
/// - Caller must be the owner.
/// @inheritdoc ERC721Tradable
function setMarketplaceApprovalForAll(bool approved) public override onlyOwner {
marketPlaceApprovalForAll = approved;
}
/* -------------------------------------------------------------------------- */
/* SOLIDITY OVERRIDES */
/* -------------------------------------------------------------------------- */
/// @inheritdoc ERC721
function tokenURI(uint256 id) public view override returns (string memory) {
require(_exists(id), "NONEXISTENT_TOKEN");
string memory _baseURI = baseURI;
return bytes(_baseURI).length == 0 ? "" : string(abi.encodePacked(_baseURI, toString(id)));
}
/// @inheritdoc ERC721Tradable
function isApprovedForAll(address owner, address operator) public view override(ERC721, ERC721Tradable) returns (bool) {
return ERC721Tradable.isApprovedForAll(owner, operator);
}
/* -------------------------------------------------------------------------- */
/* UTILS */
/* -------------------------------------------------------------------------- */
function _transferETH(address to, uint256 value) internal {
// solhint-disable-next-line avoid-low-level-calls
(bool success, ) = to.call{ value: value }("");
require(success, "ETH transfer failed");
}
} | setBaseURI | function setBaseURI(string calldata _baseURI) external onlyOwner {
baseURI = _baseURI;
}
| /// @notice Sets the base Uniform Resource Identifier (URI) for token metadata.
/// @dev Requirements:
/// - Caller must be the owner.
/// @param _baseURI The base URI. | NatSpecSingleLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
3432,
3524
]
} | 6,077 |
||||
Mingoes | contracts/src/Mingoes.sol | 0xe6f475c11ad693e48455fcaf7bca33fe84ce71b0 | Solidity | Mingoes | contract Mingoes is ERC721M, ERC721Tradable, Ownable {
uint256 public constant PRICE = 0.04 ether;
uint256 public constant MAX_SUPPLY = 10000;
uint256 public constant MAX_RESERVE = 300;
uint256 public constant MAX_PUBLIC = 9700; // MAX_SUPPLY - MAX_RESERVE
uint256 public constant MAX_FREE = 200;
uint256 public constant MAX_TX = 20;
uint256 public reservesMinted;
string public baseURI;
bool public isSaleActive;
mapping (address => bool) public hasClaimed;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
constructor(
address _openSeaProxyRegistry,
address _looksRareTransferManager,
string memory _baseURI
) payable ERC721M("Mingoes", "MINGOES") ERC721Tradable(_openSeaProxyRegistry, _looksRareTransferManager) {
baseURI = _baseURI;
}
/* -------------------------------------------------------------------------- */
/* USER */
/* -------------------------------------------------------------------------- */
/// @notice Mints an amount of tokens and transfers them to the caller during the public sale.
/// @param amount The amount of tokens to mint.
function publicMint(uint256 amount) external payable {
require(isSaleActive, "Sale is not active");
require(msg.sender == tx.origin, "No contracts allowed");
uint256 _totalSupply = totalSupply();
if (_totalSupply < MAX_FREE) {
require(!hasClaimed[msg.sender], "Already claimed");
hasClaimed[msg.sender] = true;
_mint(msg.sender, 1);
return;
}
require(msg.value == PRICE * amount, "Wrong ether amount");
require(amount <= MAX_TX, "Amount exceeds tx limit");
require(_totalSupply + amount <= MAX_PUBLIC, "Max public supply reached");
_mint(msg.sender, amount);
}
/* -------------------------------------------------------------------------- */
/* OWNER */
/* -------------------------------------------------------------------------- */
/// @notice Enables or disables minting through {publicMint}.
/// @dev Requirements:
/// - Caller must be the owner.
function setIsSaleActive(bool _isSaleActive) external onlyOwner {
isSaleActive = _isSaleActive;
}
/// @notice Mints tokens to multiple addresses.
/// @dev Requirements:
/// - Caller must be the owner.
/// @param recipients The addresses to mint the tokens to.
/// @param amounts The amounts of tokens to mint.
function reserveMint(address[] calldata recipients, uint256[] calldata amounts) external onlyOwner {
unchecked {
uint256 sum;
uint256 length = recipients.length;
for (uint256 i; i < length; i++) {
address to = recipients[i];
require(to != address(0), "Invalid recipient");
uint256 amount = amounts[i];
_mint(to, amount);
sum += amount;
}
uint256 totalReserves = reservesMinted + sum;
require(totalSupply() <= MAX_SUPPLY, "Max supply reached");
require(totalReserves <= MAX_RESERVE, "Amount exceeds reserve limit");
reservesMinted = totalReserves;
}
}
/// @notice Sets the base Uniform Resource Identifier (URI) for token metadata.
/// @dev Requirements:
/// - Caller must be the owner.
/// @param _baseURI The base URI.
function setBaseURI(string calldata _baseURI) external onlyOwner {
baseURI = _baseURI;
}
/// @notice Withdraws all contract balance to the caller.
/// @dev Requirements:
/// - Caller must be the owner.
function withdrawETH() external onlyOwner {
_transferETH(msg.sender, address(this).balance);
}
/// @dev Requirements:
/// - Caller must be the owner.
/// @inheritdoc ERC721Tradable
function setMarketplaceApprovalForAll(bool approved) public override onlyOwner {
marketPlaceApprovalForAll = approved;
}
/* -------------------------------------------------------------------------- */
/* SOLIDITY OVERRIDES */
/* -------------------------------------------------------------------------- */
/// @inheritdoc ERC721
function tokenURI(uint256 id) public view override returns (string memory) {
require(_exists(id), "NONEXISTENT_TOKEN");
string memory _baseURI = baseURI;
return bytes(_baseURI).length == 0 ? "" : string(abi.encodePacked(_baseURI, toString(id)));
}
/// @inheritdoc ERC721Tradable
function isApprovedForAll(address owner, address operator) public view override(ERC721, ERC721Tradable) returns (bool) {
return ERC721Tradable.isApprovedForAll(owner, operator);
}
/* -------------------------------------------------------------------------- */
/* UTILS */
/* -------------------------------------------------------------------------- */
function _transferETH(address to, uint256 value) internal {
// solhint-disable-next-line avoid-low-level-calls
(bool success, ) = to.call{ value: value }("");
require(success, "ETH transfer failed");
}
} | withdrawETH | function withdrawETH() external onlyOwner {
_transferETH(msg.sender, address(this).balance);
}
| /// @notice Withdraws all contract balance to the caller.
/// @dev Requirements:
/// - Caller must be the owner. | NatSpecSingleLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
3642,
3740
]
} | 6,078 |
||||
Mingoes | contracts/src/Mingoes.sol | 0xe6f475c11ad693e48455fcaf7bca33fe84ce71b0 | Solidity | Mingoes | contract Mingoes is ERC721M, ERC721Tradable, Ownable {
uint256 public constant PRICE = 0.04 ether;
uint256 public constant MAX_SUPPLY = 10000;
uint256 public constant MAX_RESERVE = 300;
uint256 public constant MAX_PUBLIC = 9700; // MAX_SUPPLY - MAX_RESERVE
uint256 public constant MAX_FREE = 200;
uint256 public constant MAX_TX = 20;
uint256 public reservesMinted;
string public baseURI;
bool public isSaleActive;
mapping (address => bool) public hasClaimed;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
constructor(
address _openSeaProxyRegistry,
address _looksRareTransferManager,
string memory _baseURI
) payable ERC721M("Mingoes", "MINGOES") ERC721Tradable(_openSeaProxyRegistry, _looksRareTransferManager) {
baseURI = _baseURI;
}
/* -------------------------------------------------------------------------- */
/* USER */
/* -------------------------------------------------------------------------- */
/// @notice Mints an amount of tokens and transfers them to the caller during the public sale.
/// @param amount The amount of tokens to mint.
function publicMint(uint256 amount) external payable {
require(isSaleActive, "Sale is not active");
require(msg.sender == tx.origin, "No contracts allowed");
uint256 _totalSupply = totalSupply();
if (_totalSupply < MAX_FREE) {
require(!hasClaimed[msg.sender], "Already claimed");
hasClaimed[msg.sender] = true;
_mint(msg.sender, 1);
return;
}
require(msg.value == PRICE * amount, "Wrong ether amount");
require(amount <= MAX_TX, "Amount exceeds tx limit");
require(_totalSupply + amount <= MAX_PUBLIC, "Max public supply reached");
_mint(msg.sender, amount);
}
/* -------------------------------------------------------------------------- */
/* OWNER */
/* -------------------------------------------------------------------------- */
/// @notice Enables or disables minting through {publicMint}.
/// @dev Requirements:
/// - Caller must be the owner.
function setIsSaleActive(bool _isSaleActive) external onlyOwner {
isSaleActive = _isSaleActive;
}
/// @notice Mints tokens to multiple addresses.
/// @dev Requirements:
/// - Caller must be the owner.
/// @param recipients The addresses to mint the tokens to.
/// @param amounts The amounts of tokens to mint.
function reserveMint(address[] calldata recipients, uint256[] calldata amounts) external onlyOwner {
unchecked {
uint256 sum;
uint256 length = recipients.length;
for (uint256 i; i < length; i++) {
address to = recipients[i];
require(to != address(0), "Invalid recipient");
uint256 amount = amounts[i];
_mint(to, amount);
sum += amount;
}
uint256 totalReserves = reservesMinted + sum;
require(totalSupply() <= MAX_SUPPLY, "Max supply reached");
require(totalReserves <= MAX_RESERVE, "Amount exceeds reserve limit");
reservesMinted = totalReserves;
}
}
/// @notice Sets the base Uniform Resource Identifier (URI) for token metadata.
/// @dev Requirements:
/// - Caller must be the owner.
/// @param _baseURI The base URI.
function setBaseURI(string calldata _baseURI) external onlyOwner {
baseURI = _baseURI;
}
/// @notice Withdraws all contract balance to the caller.
/// @dev Requirements:
/// - Caller must be the owner.
function withdrawETH() external onlyOwner {
_transferETH(msg.sender, address(this).balance);
}
/// @dev Requirements:
/// - Caller must be the owner.
/// @inheritdoc ERC721Tradable
function setMarketplaceApprovalForAll(bool approved) public override onlyOwner {
marketPlaceApprovalForAll = approved;
}
/* -------------------------------------------------------------------------- */
/* SOLIDITY OVERRIDES */
/* -------------------------------------------------------------------------- */
/// @inheritdoc ERC721
function tokenURI(uint256 id) public view override returns (string memory) {
require(_exists(id), "NONEXISTENT_TOKEN");
string memory _baseURI = baseURI;
return bytes(_baseURI).length == 0 ? "" : string(abi.encodePacked(_baseURI, toString(id)));
}
/// @inheritdoc ERC721Tradable
function isApprovedForAll(address owner, address operator) public view override(ERC721, ERC721Tradable) returns (bool) {
return ERC721Tradable.isApprovedForAll(owner, operator);
}
/* -------------------------------------------------------------------------- */
/* UTILS */
/* -------------------------------------------------------------------------- */
function _transferETH(address to, uint256 value) internal {
// solhint-disable-next-line avoid-low-level-calls
(bool success, ) = to.call{ value: value }("");
require(success, "ETH transfer failed");
}
} | setMarketplaceApprovalForAll | function setMarketplaceApprovalForAll(bool approved) public override onlyOwner {
marketPlaceApprovalForAll = approved;
}
| /// @dev Requirements:
/// - Caller must be the owner.
/// @inheritdoc ERC721Tradable | NatSpecSingleLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
3831,
3955
]
} | 6,079 |
||||
Mingoes | contracts/src/Mingoes.sol | 0xe6f475c11ad693e48455fcaf7bca33fe84ce71b0 | Solidity | Mingoes | contract Mingoes is ERC721M, ERC721Tradable, Ownable {
uint256 public constant PRICE = 0.04 ether;
uint256 public constant MAX_SUPPLY = 10000;
uint256 public constant MAX_RESERVE = 300;
uint256 public constant MAX_PUBLIC = 9700; // MAX_SUPPLY - MAX_RESERVE
uint256 public constant MAX_FREE = 200;
uint256 public constant MAX_TX = 20;
uint256 public reservesMinted;
string public baseURI;
bool public isSaleActive;
mapping (address => bool) public hasClaimed;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
constructor(
address _openSeaProxyRegistry,
address _looksRareTransferManager,
string memory _baseURI
) payable ERC721M("Mingoes", "MINGOES") ERC721Tradable(_openSeaProxyRegistry, _looksRareTransferManager) {
baseURI = _baseURI;
}
/* -------------------------------------------------------------------------- */
/* USER */
/* -------------------------------------------------------------------------- */
/// @notice Mints an amount of tokens and transfers them to the caller during the public sale.
/// @param amount The amount of tokens to mint.
function publicMint(uint256 amount) external payable {
require(isSaleActive, "Sale is not active");
require(msg.sender == tx.origin, "No contracts allowed");
uint256 _totalSupply = totalSupply();
if (_totalSupply < MAX_FREE) {
require(!hasClaimed[msg.sender], "Already claimed");
hasClaimed[msg.sender] = true;
_mint(msg.sender, 1);
return;
}
require(msg.value == PRICE * amount, "Wrong ether amount");
require(amount <= MAX_TX, "Amount exceeds tx limit");
require(_totalSupply + amount <= MAX_PUBLIC, "Max public supply reached");
_mint(msg.sender, amount);
}
/* -------------------------------------------------------------------------- */
/* OWNER */
/* -------------------------------------------------------------------------- */
/// @notice Enables or disables minting through {publicMint}.
/// @dev Requirements:
/// - Caller must be the owner.
function setIsSaleActive(bool _isSaleActive) external onlyOwner {
isSaleActive = _isSaleActive;
}
/// @notice Mints tokens to multiple addresses.
/// @dev Requirements:
/// - Caller must be the owner.
/// @param recipients The addresses to mint the tokens to.
/// @param amounts The amounts of tokens to mint.
function reserveMint(address[] calldata recipients, uint256[] calldata amounts) external onlyOwner {
unchecked {
uint256 sum;
uint256 length = recipients.length;
for (uint256 i; i < length; i++) {
address to = recipients[i];
require(to != address(0), "Invalid recipient");
uint256 amount = amounts[i];
_mint(to, amount);
sum += amount;
}
uint256 totalReserves = reservesMinted + sum;
require(totalSupply() <= MAX_SUPPLY, "Max supply reached");
require(totalReserves <= MAX_RESERVE, "Amount exceeds reserve limit");
reservesMinted = totalReserves;
}
}
/// @notice Sets the base Uniform Resource Identifier (URI) for token metadata.
/// @dev Requirements:
/// - Caller must be the owner.
/// @param _baseURI The base URI.
function setBaseURI(string calldata _baseURI) external onlyOwner {
baseURI = _baseURI;
}
/// @notice Withdraws all contract balance to the caller.
/// @dev Requirements:
/// - Caller must be the owner.
function withdrawETH() external onlyOwner {
_transferETH(msg.sender, address(this).balance);
}
/// @dev Requirements:
/// - Caller must be the owner.
/// @inheritdoc ERC721Tradable
function setMarketplaceApprovalForAll(bool approved) public override onlyOwner {
marketPlaceApprovalForAll = approved;
}
/* -------------------------------------------------------------------------- */
/* SOLIDITY OVERRIDES */
/* -------------------------------------------------------------------------- */
/// @inheritdoc ERC721
function tokenURI(uint256 id) public view override returns (string memory) {
require(_exists(id), "NONEXISTENT_TOKEN");
string memory _baseURI = baseURI;
return bytes(_baseURI).length == 0 ? "" : string(abi.encodePacked(_baseURI, toString(id)));
}
/// @inheritdoc ERC721Tradable
function isApprovedForAll(address owner, address operator) public view override(ERC721, ERC721Tradable) returns (bool) {
return ERC721Tradable.isApprovedForAll(owner, operator);
}
/* -------------------------------------------------------------------------- */
/* UTILS */
/* -------------------------------------------------------------------------- */
function _transferETH(address to, uint256 value) internal {
// solhint-disable-next-line avoid-low-level-calls
(bool success, ) = to.call{ value: value }("");
require(success, "ETH transfer failed");
}
} | tokenURI | function tokenURI(uint256 id) public view override returns (string memory) {
require(_exists(id), "NONEXISTENT_TOKEN");
string memory _baseURI = baseURI;
return bytes(_baseURI).length == 0 ? "" : string(abi.encodePacked(_baseURI, toString(id)));
}
| /// @inheritdoc ERC721 | NatSpecSingleLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
4228,
4483
]
} | 6,080 |
||||
Mingoes | contracts/src/Mingoes.sol | 0xe6f475c11ad693e48455fcaf7bca33fe84ce71b0 | Solidity | Mingoes | contract Mingoes is ERC721M, ERC721Tradable, Ownable {
uint256 public constant PRICE = 0.04 ether;
uint256 public constant MAX_SUPPLY = 10000;
uint256 public constant MAX_RESERVE = 300;
uint256 public constant MAX_PUBLIC = 9700; // MAX_SUPPLY - MAX_RESERVE
uint256 public constant MAX_FREE = 200;
uint256 public constant MAX_TX = 20;
uint256 public reservesMinted;
string public baseURI;
bool public isSaleActive;
mapping (address => bool) public hasClaimed;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
constructor(
address _openSeaProxyRegistry,
address _looksRareTransferManager,
string memory _baseURI
) payable ERC721M("Mingoes", "MINGOES") ERC721Tradable(_openSeaProxyRegistry, _looksRareTransferManager) {
baseURI = _baseURI;
}
/* -------------------------------------------------------------------------- */
/* USER */
/* -------------------------------------------------------------------------- */
/// @notice Mints an amount of tokens and transfers them to the caller during the public sale.
/// @param amount The amount of tokens to mint.
function publicMint(uint256 amount) external payable {
require(isSaleActive, "Sale is not active");
require(msg.sender == tx.origin, "No contracts allowed");
uint256 _totalSupply = totalSupply();
if (_totalSupply < MAX_FREE) {
require(!hasClaimed[msg.sender], "Already claimed");
hasClaimed[msg.sender] = true;
_mint(msg.sender, 1);
return;
}
require(msg.value == PRICE * amount, "Wrong ether amount");
require(amount <= MAX_TX, "Amount exceeds tx limit");
require(_totalSupply + amount <= MAX_PUBLIC, "Max public supply reached");
_mint(msg.sender, amount);
}
/* -------------------------------------------------------------------------- */
/* OWNER */
/* -------------------------------------------------------------------------- */
/// @notice Enables or disables minting through {publicMint}.
/// @dev Requirements:
/// - Caller must be the owner.
function setIsSaleActive(bool _isSaleActive) external onlyOwner {
isSaleActive = _isSaleActive;
}
/// @notice Mints tokens to multiple addresses.
/// @dev Requirements:
/// - Caller must be the owner.
/// @param recipients The addresses to mint the tokens to.
/// @param amounts The amounts of tokens to mint.
function reserveMint(address[] calldata recipients, uint256[] calldata amounts) external onlyOwner {
unchecked {
uint256 sum;
uint256 length = recipients.length;
for (uint256 i; i < length; i++) {
address to = recipients[i];
require(to != address(0), "Invalid recipient");
uint256 amount = amounts[i];
_mint(to, amount);
sum += amount;
}
uint256 totalReserves = reservesMinted + sum;
require(totalSupply() <= MAX_SUPPLY, "Max supply reached");
require(totalReserves <= MAX_RESERVE, "Amount exceeds reserve limit");
reservesMinted = totalReserves;
}
}
/// @notice Sets the base Uniform Resource Identifier (URI) for token metadata.
/// @dev Requirements:
/// - Caller must be the owner.
/// @param _baseURI The base URI.
function setBaseURI(string calldata _baseURI) external onlyOwner {
baseURI = _baseURI;
}
/// @notice Withdraws all contract balance to the caller.
/// @dev Requirements:
/// - Caller must be the owner.
function withdrawETH() external onlyOwner {
_transferETH(msg.sender, address(this).balance);
}
/// @dev Requirements:
/// - Caller must be the owner.
/// @inheritdoc ERC721Tradable
function setMarketplaceApprovalForAll(bool approved) public override onlyOwner {
marketPlaceApprovalForAll = approved;
}
/* -------------------------------------------------------------------------- */
/* SOLIDITY OVERRIDES */
/* -------------------------------------------------------------------------- */
/// @inheritdoc ERC721
function tokenURI(uint256 id) public view override returns (string memory) {
require(_exists(id), "NONEXISTENT_TOKEN");
string memory _baseURI = baseURI;
return bytes(_baseURI).length == 0 ? "" : string(abi.encodePacked(_baseURI, toString(id)));
}
/// @inheritdoc ERC721Tradable
function isApprovedForAll(address owner, address operator) public view override(ERC721, ERC721Tradable) returns (bool) {
return ERC721Tradable.isApprovedForAll(owner, operator);
}
/* -------------------------------------------------------------------------- */
/* UTILS */
/* -------------------------------------------------------------------------- */
function _transferETH(address to, uint256 value) internal {
// solhint-disable-next-line avoid-low-level-calls
(bool success, ) = to.call{ value: value }("");
require(success, "ETH transfer failed");
}
} | isApprovedForAll | function isApprovedForAll(address owner, address operator) public view override(ERC721, ERC721Tradable) returns (bool) {
return ERC721Tradable.isApprovedForAll(owner, operator);
}
| /// @inheritdoc ERC721Tradable | NatSpecSingleLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
4517,
4700
]
} | 6,081 |
||||
Mingoes | contracts/src/Mingoes.sol | 0xe6f475c11ad693e48455fcaf7bca33fe84ce71b0 | Solidity | Mingoes | contract Mingoes is ERC721M, ERC721Tradable, Ownable {
uint256 public constant PRICE = 0.04 ether;
uint256 public constant MAX_SUPPLY = 10000;
uint256 public constant MAX_RESERVE = 300;
uint256 public constant MAX_PUBLIC = 9700; // MAX_SUPPLY - MAX_RESERVE
uint256 public constant MAX_FREE = 200;
uint256 public constant MAX_TX = 20;
uint256 public reservesMinted;
string public baseURI;
bool public isSaleActive;
mapping (address => bool) public hasClaimed;
/* -------------------------------------------------------------------------- */
/* CONSTRUCTOR */
/* -------------------------------------------------------------------------- */
constructor(
address _openSeaProxyRegistry,
address _looksRareTransferManager,
string memory _baseURI
) payable ERC721M("Mingoes", "MINGOES") ERC721Tradable(_openSeaProxyRegistry, _looksRareTransferManager) {
baseURI = _baseURI;
}
/* -------------------------------------------------------------------------- */
/* USER */
/* -------------------------------------------------------------------------- */
/// @notice Mints an amount of tokens and transfers them to the caller during the public sale.
/// @param amount The amount of tokens to mint.
function publicMint(uint256 amount) external payable {
require(isSaleActive, "Sale is not active");
require(msg.sender == tx.origin, "No contracts allowed");
uint256 _totalSupply = totalSupply();
if (_totalSupply < MAX_FREE) {
require(!hasClaimed[msg.sender], "Already claimed");
hasClaimed[msg.sender] = true;
_mint(msg.sender, 1);
return;
}
require(msg.value == PRICE * amount, "Wrong ether amount");
require(amount <= MAX_TX, "Amount exceeds tx limit");
require(_totalSupply + amount <= MAX_PUBLIC, "Max public supply reached");
_mint(msg.sender, amount);
}
/* -------------------------------------------------------------------------- */
/* OWNER */
/* -------------------------------------------------------------------------- */
/// @notice Enables or disables minting through {publicMint}.
/// @dev Requirements:
/// - Caller must be the owner.
function setIsSaleActive(bool _isSaleActive) external onlyOwner {
isSaleActive = _isSaleActive;
}
/// @notice Mints tokens to multiple addresses.
/// @dev Requirements:
/// - Caller must be the owner.
/// @param recipients The addresses to mint the tokens to.
/// @param amounts The amounts of tokens to mint.
function reserveMint(address[] calldata recipients, uint256[] calldata amounts) external onlyOwner {
unchecked {
uint256 sum;
uint256 length = recipients.length;
for (uint256 i; i < length; i++) {
address to = recipients[i];
require(to != address(0), "Invalid recipient");
uint256 amount = amounts[i];
_mint(to, amount);
sum += amount;
}
uint256 totalReserves = reservesMinted + sum;
require(totalSupply() <= MAX_SUPPLY, "Max supply reached");
require(totalReserves <= MAX_RESERVE, "Amount exceeds reserve limit");
reservesMinted = totalReserves;
}
}
/// @notice Sets the base Uniform Resource Identifier (URI) for token metadata.
/// @dev Requirements:
/// - Caller must be the owner.
/// @param _baseURI The base URI.
function setBaseURI(string calldata _baseURI) external onlyOwner {
baseURI = _baseURI;
}
/// @notice Withdraws all contract balance to the caller.
/// @dev Requirements:
/// - Caller must be the owner.
function withdrawETH() external onlyOwner {
_transferETH(msg.sender, address(this).balance);
}
/// @dev Requirements:
/// - Caller must be the owner.
/// @inheritdoc ERC721Tradable
function setMarketplaceApprovalForAll(bool approved) public override onlyOwner {
marketPlaceApprovalForAll = approved;
}
/* -------------------------------------------------------------------------- */
/* SOLIDITY OVERRIDES */
/* -------------------------------------------------------------------------- */
/// @inheritdoc ERC721
function tokenURI(uint256 id) public view override returns (string memory) {
require(_exists(id), "NONEXISTENT_TOKEN");
string memory _baseURI = baseURI;
return bytes(_baseURI).length == 0 ? "" : string(abi.encodePacked(_baseURI, toString(id)));
}
/// @inheritdoc ERC721Tradable
function isApprovedForAll(address owner, address operator) public view override(ERC721, ERC721Tradable) returns (bool) {
return ERC721Tradable.isApprovedForAll(owner, operator);
}
/* -------------------------------------------------------------------------- */
/* UTILS */
/* -------------------------------------------------------------------------- */
function _transferETH(address to, uint256 value) internal {
// solhint-disable-next-line avoid-low-level-calls
(bool success, ) = to.call{ value: value }("");
require(success, "ETH transfer failed");
}
} | _transferETH | function _transferETH(address to, uint256 value) internal {
// solhint-disable-next-line avoid-low-level-calls
(bool success, ) = to.call{ value: value }("");
require(success, "ETH transfer failed");
}
| /* -------------------------------------------------------------------------- */ | Comment | v0.8.11+commit.d7f03943 | {
"func_code_index": [
4949,
5158
]
} | 6,082 |
||||
IAMEPrivateSale | IAMEPrivateSale.sol | 0xedb7f6c49e26c4602b109755246155c522dd4032 | Solidity | IAMEPrivateSale | contract IAMEPrivateSale is Owned {
// -------------------------------------------------------------------------------------
// TODO Before deployment of contract to Mainnet
// 1. Confirm MINIMUM_PARTICIPATION_AMOUNT below
// 2. Adjust PRIVATESALE_START_DATE and confirm the Private Sale period
// 3. Test the deployment to a dev blockchain or Testnet
// 4. A stable version of Solidity has been used. Check for any major bugs in the
// Solidity release announcements after this version.
// -------------------------------------------------------------------------------------
// Keep track of the total funding amount
uint256 public totalFunding;
// Minimum amount per transaction for public participants
uint256 public constant MINIMUM_PARTICIPATION_AMOUNT = 1 ether;
// Private Sale period
uint256 public PRIVATESALE_START_DATE;
uint256 public PRIVATESALE_END_DATE;
/// @notice This is the constructor to set the dates
function IAMEPrivateSale() public{
PRIVATESALE_START_DATE = now + 5 days; // 'now' is the block timestamp
PRIVATESALE_END_DATE = now + 40 days;
}
/// @notice Keep track of all participants contributions, including both the
/// preallocation and public phases
/// @dev Name complies with ERC20 token standard, etherscan for example will recognize
/// this and show the balances of the address
mapping (address => uint256) public balanceOf;
/// @notice Log an event for each funding contributed during the public phase
event LogParticipation(address indexed sender, uint256 value, uint256 timestamp);
/// @notice A participant sends a contribution to the contract's address
/// between the PRIVATESALE_STATE_DATE and the PRIVATESALE_END_DATE
/// @notice Only contributions bigger than the MINIMUM_PARTICIPATION_AMOUNT
/// are accepted. Otherwise the transaction
/// is rejected and contributed amount is returned to the participant's
/// account
/// @notice A participant's contribution will be rejected if the Private Sale
/// has been funded to the maximum amount
function () public payable {
// A participant cannot send funds before the Private Sale Start Date
if (now < PRIVATESALE_START_DATE) revert();
// A participant cannot send funds after the Private Sale End Date
if (now > PRIVATESALE_END_DATE) revert();
// A participant cannot send less than the minimum amount
if (msg.value < MINIMUM_PARTICIPATION_AMOUNT) revert();
// Register the participant's contribution
addBalance(msg.sender, msg.value);
}
/// @notice The owner can withdraw ethers already during Private Sale,
function ownerWithdraw(uint256 value) external onlyOwner {
if (!owner.send(value)) revert();
}
/// @dev Keep track of participants contributions and the total funding amount
function addBalance(address participant, uint256 value) private {
// Participant's balance is increased by the sent amount
balanceOf[participant] = safeIncrement(balanceOf[participant], value);
// Keep track of the total funding amount
totalFunding = safeIncrement(totalFunding, value);
// Log an event of the participant's contribution
LogParticipation(participant, value, now);
}
/// @dev Add a number to a base value. Detect overflows by checking the result is larger
/// than the original base value.
function safeIncrement(uint256 base, uint256 increment) private pure returns (uint256) {
uint256 result = base + increment;
if (result < base) revert();
return result;
}
} | /// ----------------------------------------------------------------------------------------
/// @title IAME Private Sale Contract
/// @author IAME Ltd
/// @dev Changes to this contract will invalidate any security audits done before.
/// ---------------------------------------------------------------------------------------- | NatSpecSingleLine | IAMEPrivateSale | function IAMEPrivateSale() public{
PRIVATESALE_START_DATE = now + 5 days; // 'now' is the block timestamp
PRIVATESALE_END_DATE = now + 40 days;
}
| /// @notice This is the constructor to set the dates | NatSpecSingleLine | v0.4.21+commit.dfe3193c | bzzr://b78abb8ea18f9451ff8269daa03671b966fa8f6212d172cd2bc0fa56cdc72ce7 | {
"func_code_index": [
982,
1143
]
} | 6,083 |
|
IAMEPrivateSale | IAMEPrivateSale.sol | 0xedb7f6c49e26c4602b109755246155c522dd4032 | Solidity | IAMEPrivateSale | contract IAMEPrivateSale is Owned {
// -------------------------------------------------------------------------------------
// TODO Before deployment of contract to Mainnet
// 1. Confirm MINIMUM_PARTICIPATION_AMOUNT below
// 2. Adjust PRIVATESALE_START_DATE and confirm the Private Sale period
// 3. Test the deployment to a dev blockchain or Testnet
// 4. A stable version of Solidity has been used. Check for any major bugs in the
// Solidity release announcements after this version.
// -------------------------------------------------------------------------------------
// Keep track of the total funding amount
uint256 public totalFunding;
// Minimum amount per transaction for public participants
uint256 public constant MINIMUM_PARTICIPATION_AMOUNT = 1 ether;
// Private Sale period
uint256 public PRIVATESALE_START_DATE;
uint256 public PRIVATESALE_END_DATE;
/// @notice This is the constructor to set the dates
function IAMEPrivateSale() public{
PRIVATESALE_START_DATE = now + 5 days; // 'now' is the block timestamp
PRIVATESALE_END_DATE = now + 40 days;
}
/// @notice Keep track of all participants contributions, including both the
/// preallocation and public phases
/// @dev Name complies with ERC20 token standard, etherscan for example will recognize
/// this and show the balances of the address
mapping (address => uint256) public balanceOf;
/// @notice Log an event for each funding contributed during the public phase
event LogParticipation(address indexed sender, uint256 value, uint256 timestamp);
/// @notice A participant sends a contribution to the contract's address
/// between the PRIVATESALE_STATE_DATE and the PRIVATESALE_END_DATE
/// @notice Only contributions bigger than the MINIMUM_PARTICIPATION_AMOUNT
/// are accepted. Otherwise the transaction
/// is rejected and contributed amount is returned to the participant's
/// account
/// @notice A participant's contribution will be rejected if the Private Sale
/// has been funded to the maximum amount
function () public payable {
// A participant cannot send funds before the Private Sale Start Date
if (now < PRIVATESALE_START_DATE) revert();
// A participant cannot send funds after the Private Sale End Date
if (now > PRIVATESALE_END_DATE) revert();
// A participant cannot send less than the minimum amount
if (msg.value < MINIMUM_PARTICIPATION_AMOUNT) revert();
// Register the participant's contribution
addBalance(msg.sender, msg.value);
}
/// @notice The owner can withdraw ethers already during Private Sale,
function ownerWithdraw(uint256 value) external onlyOwner {
if (!owner.send(value)) revert();
}
/// @dev Keep track of participants contributions and the total funding amount
function addBalance(address participant, uint256 value) private {
// Participant's balance is increased by the sent amount
balanceOf[participant] = safeIncrement(balanceOf[participant], value);
// Keep track of the total funding amount
totalFunding = safeIncrement(totalFunding, value);
// Log an event of the participant's contribution
LogParticipation(participant, value, now);
}
/// @dev Add a number to a base value. Detect overflows by checking the result is larger
/// than the original base value.
function safeIncrement(uint256 base, uint256 increment) private pure returns (uint256) {
uint256 result = base + increment;
if (result < base) revert();
return result;
}
} | /// ----------------------------------------------------------------------------------------
/// @title IAME Private Sale Contract
/// @author IAME Ltd
/// @dev Changes to this contract will invalidate any security audits done before.
/// ---------------------------------------------------------------------------------------- | NatSpecSingleLine | function () public payable {
// A participant cannot send funds before the Private Sale Start Date
if (now < PRIVATESALE_START_DATE) revert();
// A participant cannot send funds after the Private Sale End Date
if (now > PRIVATESALE_END_DATE) revert();
// A participant cannot send less than the minimum amount
if (msg.value < MINIMUM_PARTICIPATION_AMOUNT) revert();
// Register the participant's contribution
addBalance(msg.sender, msg.value);
}
| /// @notice A participant sends a contribution to the contract's address
/// between the PRIVATESALE_STATE_DATE and the PRIVATESALE_END_DATE
/// @notice Only contributions bigger than the MINIMUM_PARTICIPATION_AMOUNT
/// are accepted. Otherwise the transaction
/// is rejected and contributed amount is returned to the participant's
/// account
/// @notice A participant's contribution will be rejected if the Private Sale
/// has been funded to the maximum amount | NatSpecSingleLine | v0.4.21+commit.dfe3193c | bzzr://b78abb8ea18f9451ff8269daa03671b966fa8f6212d172cd2bc0fa56cdc72ce7 | {
"func_code_index": [
2168,
2659
]
} | 6,084 |
||
IAMEPrivateSale | IAMEPrivateSale.sol | 0xedb7f6c49e26c4602b109755246155c522dd4032 | Solidity | IAMEPrivateSale | contract IAMEPrivateSale is Owned {
// -------------------------------------------------------------------------------------
// TODO Before deployment of contract to Mainnet
// 1. Confirm MINIMUM_PARTICIPATION_AMOUNT below
// 2. Adjust PRIVATESALE_START_DATE and confirm the Private Sale period
// 3. Test the deployment to a dev blockchain or Testnet
// 4. A stable version of Solidity has been used. Check for any major bugs in the
// Solidity release announcements after this version.
// -------------------------------------------------------------------------------------
// Keep track of the total funding amount
uint256 public totalFunding;
// Minimum amount per transaction for public participants
uint256 public constant MINIMUM_PARTICIPATION_AMOUNT = 1 ether;
// Private Sale period
uint256 public PRIVATESALE_START_DATE;
uint256 public PRIVATESALE_END_DATE;
/// @notice This is the constructor to set the dates
function IAMEPrivateSale() public{
PRIVATESALE_START_DATE = now + 5 days; // 'now' is the block timestamp
PRIVATESALE_END_DATE = now + 40 days;
}
/// @notice Keep track of all participants contributions, including both the
/// preallocation and public phases
/// @dev Name complies with ERC20 token standard, etherscan for example will recognize
/// this and show the balances of the address
mapping (address => uint256) public balanceOf;
/// @notice Log an event for each funding contributed during the public phase
event LogParticipation(address indexed sender, uint256 value, uint256 timestamp);
/// @notice A participant sends a contribution to the contract's address
/// between the PRIVATESALE_STATE_DATE and the PRIVATESALE_END_DATE
/// @notice Only contributions bigger than the MINIMUM_PARTICIPATION_AMOUNT
/// are accepted. Otherwise the transaction
/// is rejected and contributed amount is returned to the participant's
/// account
/// @notice A participant's contribution will be rejected if the Private Sale
/// has been funded to the maximum amount
function () public payable {
// A participant cannot send funds before the Private Sale Start Date
if (now < PRIVATESALE_START_DATE) revert();
// A participant cannot send funds after the Private Sale End Date
if (now > PRIVATESALE_END_DATE) revert();
// A participant cannot send less than the minimum amount
if (msg.value < MINIMUM_PARTICIPATION_AMOUNT) revert();
// Register the participant's contribution
addBalance(msg.sender, msg.value);
}
/// @notice The owner can withdraw ethers already during Private Sale,
function ownerWithdraw(uint256 value) external onlyOwner {
if (!owner.send(value)) revert();
}
/// @dev Keep track of participants contributions and the total funding amount
function addBalance(address participant, uint256 value) private {
// Participant's balance is increased by the sent amount
balanceOf[participant] = safeIncrement(balanceOf[participant], value);
// Keep track of the total funding amount
totalFunding = safeIncrement(totalFunding, value);
// Log an event of the participant's contribution
LogParticipation(participant, value, now);
}
/// @dev Add a number to a base value. Detect overflows by checking the result is larger
/// than the original base value.
function safeIncrement(uint256 base, uint256 increment) private pure returns (uint256) {
uint256 result = base + increment;
if (result < base) revert();
return result;
}
} | /// ----------------------------------------------------------------------------------------
/// @title IAME Private Sale Contract
/// @author IAME Ltd
/// @dev Changes to this contract will invalidate any security audits done before.
/// ---------------------------------------------------------------------------------------- | NatSpecSingleLine | ownerWithdraw | function ownerWithdraw(uint256 value) external onlyOwner {
if (!owner.send(value)) revert();
}
| /// @notice The owner can withdraw ethers already during Private Sale, | NatSpecSingleLine | v0.4.21+commit.dfe3193c | bzzr://b78abb8ea18f9451ff8269daa03671b966fa8f6212d172cd2bc0fa56cdc72ce7 | {
"func_code_index": [
2736,
2841
]
} | 6,085 |
|
IAMEPrivateSale | IAMEPrivateSale.sol | 0xedb7f6c49e26c4602b109755246155c522dd4032 | Solidity | IAMEPrivateSale | contract IAMEPrivateSale is Owned {
// -------------------------------------------------------------------------------------
// TODO Before deployment of contract to Mainnet
// 1. Confirm MINIMUM_PARTICIPATION_AMOUNT below
// 2. Adjust PRIVATESALE_START_DATE and confirm the Private Sale period
// 3. Test the deployment to a dev blockchain or Testnet
// 4. A stable version of Solidity has been used. Check for any major bugs in the
// Solidity release announcements after this version.
// -------------------------------------------------------------------------------------
// Keep track of the total funding amount
uint256 public totalFunding;
// Minimum amount per transaction for public participants
uint256 public constant MINIMUM_PARTICIPATION_AMOUNT = 1 ether;
// Private Sale period
uint256 public PRIVATESALE_START_DATE;
uint256 public PRIVATESALE_END_DATE;
/// @notice This is the constructor to set the dates
function IAMEPrivateSale() public{
PRIVATESALE_START_DATE = now + 5 days; // 'now' is the block timestamp
PRIVATESALE_END_DATE = now + 40 days;
}
/// @notice Keep track of all participants contributions, including both the
/// preallocation and public phases
/// @dev Name complies with ERC20 token standard, etherscan for example will recognize
/// this and show the balances of the address
mapping (address => uint256) public balanceOf;
/// @notice Log an event for each funding contributed during the public phase
event LogParticipation(address indexed sender, uint256 value, uint256 timestamp);
/// @notice A participant sends a contribution to the contract's address
/// between the PRIVATESALE_STATE_DATE and the PRIVATESALE_END_DATE
/// @notice Only contributions bigger than the MINIMUM_PARTICIPATION_AMOUNT
/// are accepted. Otherwise the transaction
/// is rejected and contributed amount is returned to the participant's
/// account
/// @notice A participant's contribution will be rejected if the Private Sale
/// has been funded to the maximum amount
function () public payable {
// A participant cannot send funds before the Private Sale Start Date
if (now < PRIVATESALE_START_DATE) revert();
// A participant cannot send funds after the Private Sale End Date
if (now > PRIVATESALE_END_DATE) revert();
// A participant cannot send less than the minimum amount
if (msg.value < MINIMUM_PARTICIPATION_AMOUNT) revert();
// Register the participant's contribution
addBalance(msg.sender, msg.value);
}
/// @notice The owner can withdraw ethers already during Private Sale,
function ownerWithdraw(uint256 value) external onlyOwner {
if (!owner.send(value)) revert();
}
/// @dev Keep track of participants contributions and the total funding amount
function addBalance(address participant, uint256 value) private {
// Participant's balance is increased by the sent amount
balanceOf[participant] = safeIncrement(balanceOf[participant], value);
// Keep track of the total funding amount
totalFunding = safeIncrement(totalFunding, value);
// Log an event of the participant's contribution
LogParticipation(participant, value, now);
}
/// @dev Add a number to a base value. Detect overflows by checking the result is larger
/// than the original base value.
function safeIncrement(uint256 base, uint256 increment) private pure returns (uint256) {
uint256 result = base + increment;
if (result < base) revert();
return result;
}
} | /// ----------------------------------------------------------------------------------------
/// @title IAME Private Sale Contract
/// @author IAME Ltd
/// @dev Changes to this contract will invalidate any security audits done before.
/// ---------------------------------------------------------------------------------------- | NatSpecSingleLine | addBalance | function addBalance(address participant, uint256 value) private {
// Participant's balance is increased by the sent amount
balanceOf[participant] = safeIncrement(balanceOf[participant], value);
// Keep track of the total funding amount
totalFunding = safeIncrement(totalFunding, value);
// Log an event of the participant's contribution
LogParticipation(participant, value, now);
}
| /// @dev Keep track of participants contributions and the total funding amount | NatSpecSingleLine | v0.4.21+commit.dfe3193c | bzzr://b78abb8ea18f9451ff8269daa03671b966fa8f6212d172cd2bc0fa56cdc72ce7 | {
"func_code_index": [
2926,
3343
]
} | 6,086 |
|
IAMEPrivateSale | IAMEPrivateSale.sol | 0xedb7f6c49e26c4602b109755246155c522dd4032 | Solidity | IAMEPrivateSale | contract IAMEPrivateSale is Owned {
// -------------------------------------------------------------------------------------
// TODO Before deployment of contract to Mainnet
// 1. Confirm MINIMUM_PARTICIPATION_AMOUNT below
// 2. Adjust PRIVATESALE_START_DATE and confirm the Private Sale period
// 3. Test the deployment to a dev blockchain or Testnet
// 4. A stable version of Solidity has been used. Check for any major bugs in the
// Solidity release announcements after this version.
// -------------------------------------------------------------------------------------
// Keep track of the total funding amount
uint256 public totalFunding;
// Minimum amount per transaction for public participants
uint256 public constant MINIMUM_PARTICIPATION_AMOUNT = 1 ether;
// Private Sale period
uint256 public PRIVATESALE_START_DATE;
uint256 public PRIVATESALE_END_DATE;
/// @notice This is the constructor to set the dates
function IAMEPrivateSale() public{
PRIVATESALE_START_DATE = now + 5 days; // 'now' is the block timestamp
PRIVATESALE_END_DATE = now + 40 days;
}
/// @notice Keep track of all participants contributions, including both the
/// preallocation and public phases
/// @dev Name complies with ERC20 token standard, etherscan for example will recognize
/// this and show the balances of the address
mapping (address => uint256) public balanceOf;
/// @notice Log an event for each funding contributed during the public phase
event LogParticipation(address indexed sender, uint256 value, uint256 timestamp);
/// @notice A participant sends a contribution to the contract's address
/// between the PRIVATESALE_STATE_DATE and the PRIVATESALE_END_DATE
/// @notice Only contributions bigger than the MINIMUM_PARTICIPATION_AMOUNT
/// are accepted. Otherwise the transaction
/// is rejected and contributed amount is returned to the participant's
/// account
/// @notice A participant's contribution will be rejected if the Private Sale
/// has been funded to the maximum amount
function () public payable {
// A participant cannot send funds before the Private Sale Start Date
if (now < PRIVATESALE_START_DATE) revert();
// A participant cannot send funds after the Private Sale End Date
if (now > PRIVATESALE_END_DATE) revert();
// A participant cannot send less than the minimum amount
if (msg.value < MINIMUM_PARTICIPATION_AMOUNT) revert();
// Register the participant's contribution
addBalance(msg.sender, msg.value);
}
/// @notice The owner can withdraw ethers already during Private Sale,
function ownerWithdraw(uint256 value) external onlyOwner {
if (!owner.send(value)) revert();
}
/// @dev Keep track of participants contributions and the total funding amount
function addBalance(address participant, uint256 value) private {
// Participant's balance is increased by the sent amount
balanceOf[participant] = safeIncrement(balanceOf[participant], value);
// Keep track of the total funding amount
totalFunding = safeIncrement(totalFunding, value);
// Log an event of the participant's contribution
LogParticipation(participant, value, now);
}
/// @dev Add a number to a base value. Detect overflows by checking the result is larger
/// than the original base value.
function safeIncrement(uint256 base, uint256 increment) private pure returns (uint256) {
uint256 result = base + increment;
if (result < base) revert();
return result;
}
} | /// ----------------------------------------------------------------------------------------
/// @title IAME Private Sale Contract
/// @author IAME Ltd
/// @dev Changes to this contract will invalidate any security audits done before.
/// ---------------------------------------------------------------------------------------- | NatSpecSingleLine | safeIncrement | function safeIncrement(uint256 base, uint256 increment) private pure returns (uint256) {
uint256 result = base + increment;
if (result < base) revert();
return result;
}
| /// @dev Add a number to a base value. Detect overflows by checking the result is larger
/// than the original base value. | NatSpecSingleLine | v0.4.21+commit.dfe3193c | bzzr://b78abb8ea18f9451ff8269daa03671b966fa8f6212d172cd2bc0fa56cdc72ce7 | {
"func_code_index": [
3480,
3670
]
} | 6,087 |
|
hippofinance | hippofinance.sol | 0x30dbb5e8118525ef1ecdbe9589d6a3a57efefc18 | Solidity | Context | contract Context {
constructor() internal {}
// solhint-disable-previous-line no-empty-blocks
function _msgSender() internal view returns(address payable) {
return msg.sender;
}
} | _msgSender | function _msgSender() internal view returns(address payable) {
return msg.sender;
}
| // solhint-disable-previous-line no-empty-blocks | LineComment | v0.5.17+commit.d19bba13 | MIT | bzzr://8a23ea3b8f7586da7980115a1244fff4285dd2010a496f01b819b497d26be9ed | {
"func_code_index": [
105,
207
]
} | 6,088 |
||
SIMCOIN | SIMCOIN.sol | 0xef9744120c57678665be18ea519797f3feac65ff | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint256 supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint256 balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | totalSupply | function totalSupply() constant returns (uint256 supply) {}
| /// @return total amount of tokens | NatSpecSingleLine | v0.4.22+commit.4cb486ee | bzzr://e1e0d751f5b2a468562832899766d3298749739223ba6c347aa88dbba9862e26 | {
"func_code_index": [
60,
124
]
} | 6,089 |
|||
SIMCOIN | SIMCOIN.sol | 0xef9744120c57678665be18ea519797f3feac65ff | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint256 supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint256 balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | balanceOf | function balanceOf(address _owner) constant returns (uint256 balance) {}
| /// @param _owner The address from which the balance will be retrieved
/// @return The balance | NatSpecSingleLine | v0.4.22+commit.4cb486ee | bzzr://e1e0d751f5b2a468562832899766d3298749739223ba6c347aa88dbba9862e26 | {
"func_code_index": [
232,
309
]
} | 6,090 |
|||
SIMCOIN | SIMCOIN.sol | 0xef9744120c57678665be18ea519797f3feac65ff | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint256 supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint256 balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | transfer | function transfer(address _to, uint256 _value) returns (bool success) {}
| /// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not | NatSpecSingleLine | v0.4.22+commit.4cb486ee | bzzr://e1e0d751f5b2a468562832899766d3298749739223ba6c347aa88dbba9862e26 | {
"func_code_index": [
546,
623
]
} | 6,091 |
|||
SIMCOIN | SIMCOIN.sol | 0xef9744120c57678665be18ea519797f3feac65ff | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint256 supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint256 balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | transferFrom | function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
| /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not | NatSpecSingleLine | v0.4.22+commit.4cb486ee | bzzr://e1e0d751f5b2a468562832899766d3298749739223ba6c347aa88dbba9862e26 | {
"func_code_index": [
946,
1042
]
} | 6,092 |
|||
SIMCOIN | SIMCOIN.sol | 0xef9744120c57678665be18ea519797f3feac65ff | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint256 supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint256 balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | approve | function approve(address _spender, uint256 _value) returns (bool success) {}
| /// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not | NatSpecSingleLine | v0.4.22+commit.4cb486ee | bzzr://e1e0d751f5b2a468562832899766d3298749739223ba6c347aa88dbba9862e26 | {
"func_code_index": [
1326,
1407
]
} | 6,093 |
|||
SIMCOIN | SIMCOIN.sol | 0xef9744120c57678665be18ea519797f3feac65ff | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint256 supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint256 balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | allowance | function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
| /// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent | NatSpecSingleLine | v0.4.22+commit.4cb486ee | bzzr://e1e0d751f5b2a468562832899766d3298749739223ba6c347aa88dbba9862e26 | {
"func_code_index": [
1615,
1712
]
} | 6,094 |
|||
SIMCOIN | SIMCOIN.sol | 0xef9744120c57678665be18ea519797f3feac65ff | Solidity | SIMCOIN | contract SIMCOIN is StandardToken {
function () {
//if ether is sent to this address, send it back.
throw;
}
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; //fancy name: eg Simon Bucks
uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether.
string public symbol; //An identifier: eg SBX
string public version = 'H1.0'; //human 0.1 standard. Just an arbitrary versioning scheme.
function SIMCOIN(
) {
balances[msg.sender] = 10000000;
totalSupply = 10000000;
name = "SIMCOIN"; // Set the name for display purposes
decimals = 0; // Amount of decimals for display purposes
symbol = "SIM"; // Set the symbol for display purposes
}
/* Approves and then calls the receiving contract */
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
//call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this.
//receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)
//it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead.
if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; }
return true;
}
} | //name this contract whatever you'd like | LineComment | SIMCOIN | function SIMCOIN(
) {
balances[msg.sender] = 10000000;
totalSupply = 10000000;
name = "SIMCOIN"; // Set the name for display purposes
decimals = 0; // Amount of decimals for display purposes
symbol = "SIM"; // Set the symbol for display purposes
}
| //human 0.1 standard. Just an arbitrary versioning scheme. | LineComment | v0.4.22+commit.4cb486ee | bzzr://e1e0d751f5b2a468562832899766d3298749739223ba6c347aa88dbba9862e26 | {
"func_code_index": [
918,
1320
]
} | 6,095 |
|
SIMCOIN | SIMCOIN.sol | 0xef9744120c57678665be18ea519797f3feac65ff | Solidity | SIMCOIN | contract SIMCOIN is StandardToken {
function () {
//if ether is sent to this address, send it back.
throw;
}
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; //fancy name: eg Simon Bucks
uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether.
string public symbol; //An identifier: eg SBX
string public version = 'H1.0'; //human 0.1 standard. Just an arbitrary versioning scheme.
function SIMCOIN(
) {
balances[msg.sender] = 10000000;
totalSupply = 10000000;
name = "SIMCOIN"; // Set the name for display purposes
decimals = 0; // Amount of decimals for display purposes
symbol = "SIM"; // Set the symbol for display purposes
}
/* Approves and then calls the receiving contract */
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
//call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this.
//receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)
//it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead.
if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; }
return true;
}
} | //name this contract whatever you'd like | LineComment | approveAndCall | function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
//call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this.
//receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)
//it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead.
if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; }
return true;
}
| /* Approves and then calls the receiving contract */ | Comment | v0.4.22+commit.4cb486ee | bzzr://e1e0d751f5b2a468562832899766d3298749739223ba6c347aa88dbba9862e26 | {
"func_code_index": [
1381,
2186
]
} | 6,096 |
|
StrategyCurveLINKVoterProxy | StrategyCurveLINKVoterProxy.sol | 0x153fe8894a76f14bc8c8b02dd81efbb6d24e909f | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/ | NatSpecMultiLine | totalSupply | function totalSupply() external view returns (uint256);
| /**
* @dev Returns the amount of tokens in existence.
*/ | NatSpecMultiLine | v0.5.17+commit.d19bba13 | Unknown | bzzr://daf0a5f408826bee6b9553d7574de4a6d1cb04c31aa2a20140dd8677e59a2f31 | {
"func_code_index": [
94,
154
]
} | 6,097 |
StrategyCurveLINKVoterProxy | StrategyCurveLINKVoterProxy.sol | 0x153fe8894a76f14bc8c8b02dd81efbb6d24e909f | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/ | NatSpecMultiLine | balanceOf | function balanceOf(address account) external view returns (uint256);
| /**
* @dev Returns the amount of tokens owned by `account`.
*/ | NatSpecMultiLine | v0.5.17+commit.d19bba13 | Unknown | bzzr://daf0a5f408826bee6b9553d7574de4a6d1cb04c31aa2a20140dd8677e59a2f31 | {
"func_code_index": [
237,
310
]
} | 6,098 |
StrategyCurveLINKVoterProxy | StrategyCurveLINKVoterProxy.sol | 0x153fe8894a76f14bc8c8b02dd81efbb6d24e909f | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/ | NatSpecMultiLine | transfer | function transfer(address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.5.17+commit.d19bba13 | Unknown | bzzr://daf0a5f408826bee6b9553d7574de4a6d1cb04c31aa2a20140dd8677e59a2f31 | {
"func_code_index": [
534,
616
]
} | 6,099 |
StrategyCurveLINKVoterProxy | StrategyCurveLINKVoterProxy.sol | 0x153fe8894a76f14bc8c8b02dd81efbb6d24e909f | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/ | NatSpecMultiLine | allowance | function allowance(address owner, address spender) external view returns (uint256);
| /**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/ | NatSpecMultiLine | v0.5.17+commit.d19bba13 | Unknown | bzzr://daf0a5f408826bee6b9553d7574de4a6d1cb04c31aa2a20140dd8677e59a2f31 | {
"func_code_index": [
895,
983
]
} | 6,100 |
StrategyCurveLINKVoterProxy | StrategyCurveLINKVoterProxy.sol | 0x153fe8894a76f14bc8c8b02dd81efbb6d24e909f | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/ | NatSpecMultiLine | approve | function approve(address spender, uint256 amount) external returns (bool);
| /**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/ | NatSpecMultiLine | v0.5.17+commit.d19bba13 | Unknown | bzzr://daf0a5f408826bee6b9553d7574de4a6d1cb04c31aa2a20140dd8677e59a2f31 | {
"func_code_index": [
1647,
1726
]
} | 6,101 |
StrategyCurveLINKVoterProxy | StrategyCurveLINKVoterProxy.sol | 0x153fe8894a76f14bc8c8b02dd81efbb6d24e909f | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/ | NatSpecMultiLine | transferFrom | function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.5.17+commit.d19bba13 | Unknown | bzzr://daf0a5f408826bee6b9553d7574de4a6d1cb04c31aa2a20140dd8677e59a2f31 | {
"func_code_index": [
2039,
2141
]
} | 6,102 |
StrategyCurveLINKVoterProxy | StrategyCurveLINKVoterProxy.sol | 0x153fe8894a76f14bc8c8b02dd81efbb6d24e909f | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*
* _Available since v2.4.0._
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | add | function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
| /**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/ | NatSpecMultiLine | v0.5.17+commit.d19bba13 | Unknown | bzzr://daf0a5f408826bee6b9553d7574de4a6d1cb04c31aa2a20140dd8677e59a2f31 | {
"func_code_index": [
251,
437
]
} | 6,103 |
StrategyCurveLINKVoterProxy | StrategyCurveLINKVoterProxy.sol | 0x153fe8894a76f14bc8c8b02dd81efbb6d24e909f | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*
* _Available since v2.4.0._
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | sub | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
| /**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/ | NatSpecMultiLine | v0.5.17+commit.d19bba13 | Unknown | bzzr://daf0a5f408826bee6b9553d7574de4a6d1cb04c31aa2a20140dd8677e59a2f31 | {
"func_code_index": [
707,
848
]
} | 6,104 |
StrategyCurveLINKVoterProxy | StrategyCurveLINKVoterProxy.sol | 0x153fe8894a76f14bc8c8b02dd81efbb6d24e909f | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*
* _Available since v2.4.0._
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | sub | function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
| /**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*
* _Available since v2.4.0._
*/ | NatSpecMultiLine | v0.5.17+commit.d19bba13 | Unknown | bzzr://daf0a5f408826bee6b9553d7574de4a6d1cb04c31aa2a20140dd8677e59a2f31 | {
"func_code_index": [
1180,
1377
]
} | 6,105 |
StrategyCurveLINKVoterProxy | StrategyCurveLINKVoterProxy.sol | 0x153fe8894a76f14bc8c8b02dd81efbb6d24e909f | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*
* _Available since v2.4.0._
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | mul | function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
| /**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/ | NatSpecMultiLine | v0.5.17+commit.d19bba13 | Unknown | bzzr://daf0a5f408826bee6b9553d7574de4a6d1cb04c31aa2a20140dd8677e59a2f31 | {
"func_code_index": [
1623,
2099
]
} | 6,106 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.