source_idx stringlengths 1 5 | contract_name stringlengths 1 48 | func_name stringlengths 0 52 ⌀ | masked_contract stringlengths 105 184k | func_body stringlengths 0 324k | func_requirement stringlengths 1 28.3k |
|---|---|---|---|---|---|
0 | TangentStake | TangentStake | contract TangentStake is Owned {
// prevents overflows
using SafeMath for uint;
// represents a purchase object
// addr is the buying address
// amount is the number of wei in the purchase
// sf is the sum of (purchase amount / sum of previous purchase amounts)
struct Purchase {... |
tokenContract = Tangent(tokenAddress);
multiplier = 1000;
divisor = 1;
acm = 10**18;
netStakes = 0;
| constructor, sets initial rate to 1000 TAN per 1 Ether |
0 | TangentStake | revalue | contract TangentStake is Owned {
// prevents overflows
using SafeMath for uint;
// represents a purchase object
// addr is the buying address
// amount is the number of wei in the purchase
// sf is the sum of (purchase amount / sum of previous purchase amounts)
struct Purchase {... |
require( (newMul.div(newDiv)) <= (multiplier.div(divisor)) );
Revaluation(multiplier, divisor, newMul, newDiv);
multiplier = newMul;
divisor = newDiv;
return;
| decreases the rate of Tangents to Ether, the contract cannot be told
to give out more Tangents per Ether, only fewer. |
0 | TangentStake | getEarnings | contract TangentStake is Owned {
// prevents overflows
using SafeMath for uint;
// represents a purchase object
// addr is the buying address
// amount is the number of wei in the purchase
// sf is the sum of (purchase amount / sum of previous purchase amounts)
struct Purchase {... |
Purchase memory cpurchase;
Purchase memory lpurchase;
cpurchase = purchases[index];
amount = cpurchase.amount;
if (cpurchase.addr == address(0)) {
return (0, amount);
}
earnings = (index == 0) ? acm : 0;
... | returns the current amount of wei that will be given for the purchase
at purchases[index] |
0 | TangentStake | cashOut | contract TangentStake is Owned {
// prevents overflows
using SafeMath for uint;
// represents a purchase object
// addr is the buying address
// amount is the number of wei in the purchase
// sf is the sum of (purchase amount / sum of previous purchase amounts)
struct Purchase {... |
require(0 <= index && index < purchases.length);
require(purchases[index].addr == msg.sender);
uint earnings;
uint amount;
uint tangles;
(earnings, amount) = getEarnings(index);
purchases[index].addr = address(0);
require(earni... | Cash out Ether and Tangent at for the purchase at index "index".
All of the Ether and Tangent associated with with that purchase will
be sent to recipient, and no future withdrawals can be made for the
purchase. |
0 | TangentStake | contract TangentStake is Owned {
// prevents overflows
using SafeMath for uint;
// represents a purchase object
// addr is the buying address
// amount is the number of wei in the purchase
// sf is the sum of (purchase amount / sum of previous purchase amounts)
struct Purchase {... |
require(msg.value != 0);
uint index = purchases.length;
uint sf;
uint f;
if (index == 0) {
sf = 0;
} else {
f = msg.value.mul(acm).div(netStakes);
sf = purchases[index-1].sf.add(f);
}
... | The fallback function used to purchase stakes
sf is the sum of the proportions of:
(ether of current purchase / sum of ether prior to purchase)
It is used to calculate earnings upon withdrawal. | |
2 | CoFiXVaultForLP | setGovernance | contract CoFiXVaultForLP is ICoFiXVaultForLP, ReentrancyGuard {
using SafeMath for uint256;
uint256 public constant RATE_BASE = 1e18;
uint256 public constant WEIGHT_BASE = 100;
address public immutable cofiToken;
address public immutable factory;
uint256 public immutable genesisBlock;
/... |
governance = _new;
| setters for protocol governance |
2 | CoFiXVaultForLP | getEnabledPoolCnt | contract CoFiXVaultForLP is ICoFiXVaultForLP, ReentrancyGuard {
using SafeMath for uint256;
uint256 public constant RATE_BASE = 1e18;
uint256 public constant WEIGHT_BASE = 100;
address public immutable cofiToken;
address public immutable factory;
uint256 public immutable genesisBlock;
/... |
return enabledCnt;
| pools in enabled state |
3 | ERC721 | null | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string internal _name;
// Token symbol
string private _symbol;
// Base URI
string private _tokenBaseURI;
// Mapping from token ID to own... |
_name = name_;
_symbol = symbol_;
| *
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. |
3 | ERC721 | supportsInterface | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string internal _name;
// Token symbol
string private _symbol;
// Base URI
string private _tokenBaseURI;
// Mapping from token ID to own... |
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
| *
* @dev See {IERC165-supportsInterface}. |
3 | ERC721 | balanceOf | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string internal _name;
// Token symbol
string private _symbol;
// Base URI
string private _tokenBaseURI;
// Mapping from token ID to own... |
require(
owner != address(0),
"ERC721: balance query for the zero address"
);
return _balances[owner];
| *
* @dev See {IERC721-balanceOf}. |
3 | ERC721 | ownerOf | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string internal _name;
// Token symbol
string private _symbol;
// Base URI
string private _tokenBaseURI;
// Mapping from token ID to own... |
address owner = _owners[tokenId];
require(
owner != address(0),
"ERC721: owner query for nonexistent token"
);
return owner;
| *
* @dev See {IERC721-ownerOf}. |
3 | ERC721 | name | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string internal _name;
// Token symbol
string private _symbol;
// Base URI
string private _tokenBaseURI;
// Mapping from token ID to own... |
return _name;
| *
* @dev See {IERC721Metadata-name}. |
3 | ERC721 | symbol | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string internal _name;
// Token symbol
string private _symbol;
// Base URI
string private _tokenBaseURI;
// Mapping from token ID to own... |
return _symbol;
| *
* @dev See {IERC721Metadata-symbol}. |
3 | ERC721 | tokenURI | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string internal _name;
// Token symbol
string private _symbol;
// Base URI
string private _tokenBaseURI;
// Mapping from token ID to own... |
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
string memory baseURI = _baseURI();
return
bytes(baseURI).length > 0
? string(abi.encodePacked(baseURI, tokenId.toString()))
: "... | *
* @dev See {IERC721Metadata-tokenURI}. |
3 | ERC721 | _baseURI | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string internal _name;
// Token symbol
string private _symbol;
// Base URI
string private _tokenBaseURI;
// Mapping from token ID to own... |
return _tokenBaseURI;
| *
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts. |
3 | ERC721 | approve | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string internal _name;
// Token symbol
string private _symbol;
// Base URI
string private _tokenBaseURI;
// Mapping from token ID to own... |
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(... | *
* @dev See {IERC721-approve}. |
3 | ERC721 | getApproved | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string internal _name;
// Token symbol
string private _symbol;
// Base URI
string private _tokenBaseURI;
// Mapping from token ID to own... |
require(
_exists(tokenId),
"ERC721: approved query for nonexistent token"
);
return _tokenApprovals[tokenId];
| *
* @dev See {IERC721-getApproved}. |
3 | ERC721 | setApprovalForAll | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string internal _name;
// Token symbol
string private _symbol;
// Base URI
string private _tokenBaseURI;
// Mapping from token ID to own... |
_setApprovalForAll(_msgSender(), operator, approved);
| *
* @dev See {IERC721-setApprovalForAll}. |
3 | ERC721 | isApprovedForAll | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string internal _name;
// Token symbol
string private _symbol;
// Base URI
string private _tokenBaseURI;
// Mapping from token ID to own... |
return _operatorApprovals[owner][operator];
| *
* @dev See {IERC721-isApprovedForAll}. |
3 | ERC721 | transferFrom | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string internal _name;
// Token symbol
string private _symbol;
// Base URI
string private _tokenBaseURI;
// Mapping from token ID to own... |
//solhint-disable-next-line max-line-length
require(
_isApprovedOrOwner(_msgSender(), tokenId),
"ERC721: transfer caller is not owner nor approved"
);
_transfer(from, to, tokenId);
| *
* @dev See {IERC721-transferFrom}. |
3 | ERC721 | safeTransferFrom | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string internal _name;
// Token symbol
string private _symbol;
// Base URI
string private _tokenBaseURI;
// Mapping from token ID to own... |
safeTransferFrom(from, to, tokenId, "");
| *
* @dev See {IERC721-safeTransferFrom}. |
3 | ERC721 | safeTransferFrom | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string internal _name;
// Token symbol
string private _symbol;
// Base URI
string private _tokenBaseURI;
// Mapping from token ID to own... |
require(
_isApprovedOrOwner(_msgSender(), tokenId),
"ERC721: transfer caller is not owner nor approved"
);
_safeTransfer(from, to, tokenId, _data);
| *
* @dev See {IERC721-safeTransferFrom}. |
3 | ERC721 | _safeTransfer | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string internal _name;
// Token symbol
string private _symbol;
// Base URI
string private _tokenBaseURI;
// Mapping from token ID to own... |
_transfer(from, to, tokenId);
require(
_checkOnERC721Received(from, to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
| *
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This i... |
3 | ERC721 | _exists | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string internal _name;
// Token symbol
string private _symbol;
// Base URI
string private _tokenBaseURI;
// Mapping from token ID to own... |
return _owners[tokenId] != address(0);
| *
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`). |
3 | ERC721 | _isApprovedOrOwner | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string internal _name;
// Token symbol
string private _symbol;
// Base URI
string private _tokenBaseURI;
// Mapping from token ID to own... |
require(
_exists(tokenId),
"ERC721: operator query for nonexistent token"
);
address owner = ERC721.ownerOf(tokenId);
return (spender == owner ||
getApproved(tokenId) == spender ||
isApprovedForAll(owner, spender));
| *
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist. |
3 | ERC721 | _safeMint | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string internal _name;
// Token symbol
string private _symbol;
// Base URI
string private _tokenBaseURI;
// Mapping from token ID to own... |
_safeMint(to, tokenId, "");
| *
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event. |
3 | ERC721 | _safeMint | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string internal _name;
// Token symbol
string private _symbol;
// Base URI
string private _tokenBaseURI;
// Mapping from token ID to own... |
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
| *
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients. |
3 | ERC721 | _mint | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string internal _name;
// Token symbol
string private _symbol;
// Base URI
string private _tokenBaseURI;
// Mapping from token ID to own... |
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
| *
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event. |
3 | ERC721 | _burn | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string internal _name;
// Token symbol
string private _symbol;
// Base URI
string private _tokenBaseURI;
// Mapping from token ID to own... |
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
| *
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event. |
3 | ERC721 | _transfer | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string internal _name;
// Token symbol
string private _symbol;
// Base URI
string private _tokenBaseURI;
// Mapping from token ID to own... |
require(
ERC721.ownerOf(tokenId) == from,
"ERC721: transfer of token that is not own"
);
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
... | *
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event. |
3 | ERC721 | _approve | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string internal _name;
// Token symbol
string private _symbol;
// Base URI
string private _tokenBaseURI;
// Mapping from token ID to own... |
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
| *
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event. |
3 | ERC721 | _setApprovalForAll | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string internal _name;
// Token symbol
string private _symbol;
// Base URI
string private _tokenBaseURI;
// Mapping from token ID to own... |
require(owner != operator, "ERC721: approve to caller");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
| *
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits a {ApprovalForAll} event. |
3 | ERC721 | _checkOnERC721Received | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string internal _name;
// Token symbol
string private _symbol;
// Base URI
string private _tokenBaseURI;
// Mapping from token ID to own... |
if (to.isContract()) {
try
IERC721Receiver(to).onERC721Received(
_msgSender(),
from,
tokenId,
_data
)
returns (bytes4 retval) {
return retval == IERC... | *
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the to... |
3 | ERC721 | _beforeTokenTransfer | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string internal _name;
// Token symbol
string private _symbol;
// Base URI
string private _tokenBaseURI;
// Mapping from token ID to own... | *
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to... | |
4 | SafeMath | safeMul | contract SafeMath {
//internals
function safeMul(uint a, uint b) internal returns(uint) {<FILL_FUNCTION_BODY>}
function safeSub(uint a, uint b) internal returns(uint) {
assert(b <= a);
return a - b;
}
function safeAdd(uint a, uint b) internal returns(uint) {
uin... |
uint c = a * b;
assert(a == 0 || c / a == b);
return c;
| internals |
4 | Crowdsale | Crowdsale | contract Crowdsale is owned, SafeMath {
address public beneficiary;
uint public fundingGoal;
uint public amountRaised; //The amount being raised by the crowdsale
uint public deadline; /* the end date of the crowdsale*/
uint public rate; //rate for the crowdsale
uint public tokenDecimals;
... |
beneficiary = 0xe579891b98a3f58e26c4b2edb54e22250899363c;
rate = 80000; // 8.000.000 TORC/Ether
tokenDecimals=8;
fundingGoal = 2500000000 * (10 ** tokenDecimals);
start = 1536537600; //
deadline = 1539129600; //
bonusEndDate =1537156800;
... | *
* Constrctor function
*
* Setup the owner |
4 | Crowdsale | getNumTokens | contract Crowdsale is owned, SafeMath {
address public beneficiary;
uint public fundingGoal;
uint public amountRaised; //The amount being raised by the crowdsale
uint public deadline; /* the end date of the crowdsale*/
uint public rate; //rate for the crowdsale
uint public tokenDecimals;
... |
require(_value>=10000000000000000 * 1 wei); //Min amount to invest: 0.01 ETH
numTokens = safeMul(_value,rate)/(10 ** tokenDecimals); //Number of tokens to give is equal to the amount received by the rate
if(now <= bonusEndDate){
if(_value>= 1 ether && _value< 5 * 1 et... | It calculates the amount of tokens to send to the investor |
4 | Crowdsale | checkGoalReached | contract Crowdsale is owned, SafeMath {
address public beneficiary;
uint public fundingGoal;
uint public amountRaised; //The amount being raised by the crowdsale
uint public deadline; /* the end date of the crowdsale*/
uint public rate; //rate for the crowdsale
uint public tokenDecimals;
... |
require(msg.sender == owner); //Checks if the one who executes the function is the owner of the contract
if (tokensSold >=fundingGoal){
GoalReached(beneficiary, amountRaised);
}
tokenReward.burn(tokenReward.balanceOf(this)); //Burns all the remaining tokens in the contr... | *
* Check if goal was reached
*
* Checks if the goal or time limit has been reached and ends the campaign and burn the tokens |
5 | KEKEcon | KEKEcon | contract KEKEcon{
/* Public variables of the token */
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
/* This creates an array with all balances */
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address =... |
balanceOf[msg.sender] = 100000000000000000; // Give the creator all initial tokens
totalSupply = 100000000000000000; // Update total supply
name = "KEKEcon"; // Set the name for display purposes
symbol = "KEKEcon"; ... | Initializes contract with initial supply tokens to the creator of the contract |
5 | KEKEcon | _transfer | contract KEKEcon{
/* Public variables of the token */
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
/* This creates an array with all balances */
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address =... |
require (_to != 0x0); // Prevent transfer to 0x0 address. Use burn() instead
require (balanceOf[_from] >= _value); // Check if the sender has enough
require (balanceOf[_to] + _value > balanceOf[_to]); // Check for overflows
balanceOf[_fro... | Internal transfer, only can be called by this contract |
5 | KEKEcon | transfer | contract KEKEcon{
/* Public variables of the token */
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
/* This creates an array with all balances */
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address =... |
_transfer(msg.sender, _to, _value);
| / @notice Send `_value` tokens to `_to` from your account
/ @param _to The address of the recipient
/ @param _value the amount to send |
5 | KEKEcon | transferFrom | contract KEKEcon{
/* Public variables of the token */
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
/* This creates an array with all balances */
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address =... |
require (_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
| / @notice Send `_value` tokens to `_to` in behalf of `_from`
/ @param _from The address of the sender
/ @param _to The address of the recipient
/ @param _value the amount to send |
5 | KEKEcon | approve | contract KEKEcon{
/* Public variables of the token */
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
/* This creates an array with all balances */
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address =... |
allowance[msg.sender][_spender] = _value;
return true;
| / @notice Allows `_spender` to spend no more than `_value` tokens in your behalf
/ @param _spender The address authorized to spend
/ @param _value the max amount they can spend |
5 | KEKEcon | approveAndCall | contract KEKEcon{
/* Public variables of the token */
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
/* This creates an array with all balances */
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address =... |
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
| / @notice Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
/ @param _spender The address authorized to spend
/ @param _value the max amount they can spend
/ @param _extraData some extra information to send to the approved contract |
5 | KEKEcon | burn | contract KEKEcon{
/* Public variables of the token */
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
/* This creates an array with all balances */
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address =... |
require (balanceOf[msg.sender] >= _value); // Check if the sender has enough
balanceOf[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
Burn(msg.sender, _value);
r... | / @notice Remove `_value` tokens from the system irreversibly
/ @param _value the amount of money to burn |
6 | ERC20 | null | contract ERC20 is Context, IERC20, IERC20Metadata {
using SafeMath for uint256;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**... |
_name = name_;
_symbol = symbol_;
| *
* @dev Sets the values for {name} and {symbol}.
*
* The default value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction. |
6 | ERC20 | name | contract ERC20 is Context, IERC20, IERC20Metadata {
using SafeMath for uint256;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**... |
return _name;
| *
* @dev Returns the name of the token. |
6 | ERC20 | symbol | contract ERC20 is Context, IERC20, IERC20Metadata {
using SafeMath for uint256;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**... |
return _symbol;
| *
* @dev Returns the symbol of the token, usually a shorter version of the
* name. |
6 | ERC20 | decimals | contract ERC20 is Context, IERC20, IERC20Metadata {
using SafeMath for uint256;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**... |
return 18;
| *
* @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
* ... |
6 | ERC20 | totalSupply | contract ERC20 is Context, IERC20, IERC20Metadata {
using SafeMath for uint256;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**... |
return _totalSupply;
| *
* @dev See {IERC20-totalSupply}. |
6 | ERC20 | balanceOf | contract ERC20 is Context, IERC20, IERC20Metadata {
using SafeMath for uint256;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**... |
return _balances[account];
| *
* @dev See {IERC20-balanceOf}. |
6 | ERC20 | transfer | contract ERC20 is Context, IERC20, IERC20Metadata {
using SafeMath for uint256;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**... |
_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`. |
6 | ERC20 | allowance | contract ERC20 is Context, IERC20, IERC20Metadata {
using SafeMath for uint256;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**... |
return _allowances[owner][spender];
| *
* @dev See {IERC20-allowance}. |
6 | ERC20 | approve | contract ERC20 is Context, IERC20, IERC20Metadata {
using SafeMath for uint256;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**... |
_approve(_msgSender(), spender, amount);
return true;
| *
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address. |
6 | ERC20 | transferFrom | contract ERC20 is Context, IERC20, IERC20Metadata {
using SafeMath for uint256;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**... |
_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`... |
6 | ERC20 | increaseAllowance | contract ERC20 is Context, IERC20, IERC20Metadata {
using SafeMath for uint256;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**... |
_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.
*
* Requi... |
6 | ERC20 | decreaseAllowance | contract ERC20 is Context, IERC20, IERC20Metadata {
using SafeMath for uint256;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**... |
_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.
*
* Requi... |
6 | ERC20 | _transfer | contract ERC20 is Context, IERC20, IERC20Metadata {
using SafeMath for uint256;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**... |
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 bal... | *
* @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:
*
* - `s... |
6 | ERC20 | _mint | contract ERC20 is Context, IERC20, IERC20Metadata {
using SafeMath for uint256;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**... |
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:
*
* - `account` cannot be the zero address. |
6 | ERC20 | _burn | contract ERC20 is Context, IERC20, IERC20Metadata {
using SafeMath for uint256;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**... |
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(acco... | *
* @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. |
6 | ERC20 | _approve | contract ERC20 is Context, IERC20, IERC20Metadata {
using SafeMath for uint256;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**... |
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
| *
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
... |
6 | ERC20 | _beforeTokenTransfer | contract ERC20 is Context, IERC20, IERC20Metadata {
using SafeMath for uint256;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**... | *
* @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 ... | |
6 | Ownable | null | contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () {<FILL_FUNCTION_BODY>}
/**
* @d... |
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
| *
* @dev Initializes the contract setting the deployer as the initial owner. |
6 | Ownable | owner | contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () {
address msgSender = _msgSender();... |
return _owner;
| *
* @dev Returns the address of the current owner. |
6 | Ownable | renounceOwnership | contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () {
address msgSender = _msgSender();... |
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
| *
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the ... |
6 | Ownable | transferOwnership | contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () {
address msgSender = _msgSender();... |
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
| *
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner. |
6 | QTH | updateSwapTokensAtAmount | contract QTH is ERC20, Ownable {
using SafeMath for uint256;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
address public constant deadAddress = address(0xdead);
bool private swapping;
address public marketingWallet;
address public ... |
require(newAmount >= totalSupply() * 1 / 100000, "Swap amount cannot be lower than 0.001% total supply.");
require(newAmount <= totalSupply() * 5 / 1000, "Swap amount cannot be higher than 0.5% total supply.");
swapTokensAtAmount = newAmount;
return true;
| *
// once enabled, can never be turned off
function enableTrading() external onlyOwner {
tradingActive = true;
swapEnabled = true;
}
change the minimum amount of tokens to sell from fees |
6 | QTH | updateSwapEnabled | contract QTH is ERC20, Ownable {
using SafeMath for uint256;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
address public constant deadAddress = address(0xdead);
bool private swapping;
address public marketingWallet;
address public ... |
swapEnabled = enabled;
| only use to disable contract sales if absolutely necessary (emergency use only) |
6 | QTH | buyBackTokens | contract QTH is ERC20, Ownable {
using SafeMath for uint256;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
address public constant deadAddress = address(0xdead);
bool private swapping;
address public marketingWallet;
address public ... |
// generate the uniswap pair path of weth -> eth
address[] memory path = new address[](2);
path[0] = uniswapV2Router.WETH();
path[1] = address(this);
// make the swap
uniswapV2Router.swapExactETHForTokensSupportingFeeOnTransferTokens{value: bnbAmountInWei}(
... | useful for buybacks or to reclaim any BNB on the contract in a way that helps holders. |
10 | ERC721 | null | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping (uint256 => address) private _o... |
_name = name_;
_symbol = symbol_;
| *
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. |
10 | ERC721 | supportsInterface | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping (uint256 => address) private _o... |
return interfaceId == type(IERC721).interfaceId
|| interfaceId == type(IERC721Metadata).interfaceId
|| super.supportsInterface(interfaceId);
| *
* @dev See {IERC165-supportsInterface}. |
10 | ERC721 | balanceOf | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping (uint256 => address) private _o... |
require(owner != address(0), "ERC721: balance query for the zero address");
return _balances[owner];
| *
* @dev See {IERC721-balanceOf}. |
10 | ERC721 | ownerOf | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping (uint256 => address) private _o... |
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
| *
* @dev See {IERC721-ownerOf}. |
10 | ERC721 | name | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping (uint256 => address) private _o... |
return _name;
| *
* @dev See {IERC721Metadata-name}. |
10 | ERC721 | symbol | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping (uint256 => address) private _o... |
return _symbol;
| *
* @dev See {IERC721Metadata-symbol}. |
10 | ERC721 | tokenURI | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping (uint256 => address) private _o... |
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0
? string(abi.encodePacked(baseURI, tokenId.toString()))
: '';
| *
* @dev See {IERC721Metadata-tokenURI}. |
10 | ERC721 | _baseURI | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping (uint256 => address) private _o... |
return "";
| *
* @dev Base URI for computing {tokenURI}. Empty by default, can be overriden
* in child contracts. |
10 | ERC721 | approve | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping (uint256 => address) private _o... |
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
... | *
* @dev See {IERC721-approve}. |
10 | ERC721 | getApproved | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping (uint256 => address) private _o... |
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
| *
* @dev See {IERC721-getApproved}. |
10 | ERC721 | setApprovalForAll | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping (uint256 => address) private _o... |
require(operator != _msgSender(), "ERC721: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
| *
* @dev See {IERC721-setApprovalForAll}. |
10 | ERC721 | isApprovedForAll | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping (uint256 => address) private _o... |
return _operatorApprovals[owner][operator];
| *
* @dev See {IERC721-isApprovedForAll}. |
10 | ERC721 | transferFrom | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping (uint256 => address) private _o... |
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
| *
* @dev See {IERC721-transferFrom}. |
10 | ERC721 | safeTransferFrom | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping (uint256 => address) private _o... |
safeTransferFrom(from, to, tokenId, "");
| *
* @dev See {IERC721-safeTransferFrom}. |
10 | ERC721 | safeTransferFrom | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping (uint256 => address) private _o... |
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
| *
* @dev See {IERC721-safeTransferFrom}. |
10 | ERC721 | _safeTransfer | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping (uint256 => address) private _o... |
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
| *
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This i... |
10 | ERC721 | _exists | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping (uint256 => address) private _o... |
return _owners[tokenId] != address(0);
| *
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`). |
10 | ERC721 | _isApprovedOrOwner | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping (uint256 => address) private _o... |
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
| *
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist. |
10 | ERC721 | _safeMint | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping (uint256 => address) private _o... |
_safeMint(to, tokenId, "");
| *
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event. |
10 | ERC721 | _safeMint | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping (uint256 => address) private _o... |
_mint(to, tokenId);
require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
| *
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients. |
10 | ERC721 | _mint | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping (uint256 => address) private _o... |
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
| *
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event. |
10 | ERC721 | _burn | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping (uint256 => address) private _o... |
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
| *
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event. |
10 | ERC721 | _transfer | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping (uint256 => address) private _o... |
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
... | *
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event. |
10 | ERC721 | _approve | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping (uint256 => address) private _o... |
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
| *
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event. |
10 | ERC721 | _checkOnERC721Received | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping (uint256 => address) private _o... |
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
... | *
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the to... |
10 | ERC721 | _beforeTokenTransfer | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping (uint256 => address) private _o... | *
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to... | |
10 | COVIDBots | airdropMint | contract COVIDBots is Ownable, ERC721Enumerable, ReentrancyGuard {
using Counters for Counters.Counter;
using Strings for uint256;
string public imageHash;
uint256 public constant MAX_MINTABLE_AT_ONCE = 20;
string public botcontractURI;
constructor() ERC721("COVIDBots", "BOT-19") {}
u... |
require(numRolls < 21, "You should not mint more than 20 at a time.");
uint256 toMint = numRolls;
_mint(toMint, receiver);
| function to mint and send airdrop |
10 | COVIDBots | _mint | contract COVIDBots is Ownable, ERC721Enumerable, ReentrancyGuard {
using Counters for Counters.Counter;
using Strings for uint256;
string public imageHash;
uint256 public constant MAX_MINTABLE_AT_ONCE = 20;
string public botcontractURI;
constructor() ERC721("COVIDBots", "BOT-19") {}
u... |
require(_numToMint <= MAX_MINTABLE_AT_ONCE, "Minting too many at once.");
uint256 updatedNumAvailableTokens = _numAvailableTokens;
for (uint256 i = 0; i < _numToMint; i++) {
uint256 newTokenId = useRandomAvailableToken(_numToMint, i);
_safeMint(receiver, newTokenId);
updatedNumAva... | internal minting function |
10 | COVIDBots | setBaseURI | contract COVIDBots is Ownable, ERC721Enumerable, ReentrancyGuard {
using Counters for Counters.Counter;
using Strings for uint256;
string public imageHash;
uint256 public constant MAX_MINTABLE_AT_ONCE = 20;
string public botcontractURI;
constructor() ERC721("COVIDBots", "BOT-19") {}
u... |
_baseTokenURI = baseURI;
| * Owner stuff
URIs |
12 | Token | totalSupply | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint256 supply) {<FILL_FUNCTION_BODY>}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (u... | / @return total amount of tokens | |
12 | Token | balanceOf | 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) {<FI... | / @param _owner The address from which the balance will be retrieved
/ @return The balance |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.