Art Blocks
About
Stats
Public Functions
57
Event Types
4
Code Size
48,356 bytes
Library Use
Uses SafeMath for uint256.
Events (4) keyboard_arrow_up
Structs (1) keyboard_arrow_up
Project Struct
Members
name |
string help
|
artist |
string help
|
description |
string help
|
website |
string help
|
license |
string help
|
dynamic |
bool help
|
artistAddress |
address help
|
additionalPayee |
address help
|
additionalPayeePercentage |
uint256 help
|
secondMarketRoyalty |
uint256 help
|
pricePerTokenInWei |
uint256 help
|
projectBaseURI |
string help
|
projectBaseIpfsURI |
string help
|
invocations |
uint256 help
|
maxInvocations |
uint256 help
|
scriptJSON |
string help
|
scripts |
mapping(uint256 => string) help
|
scriptCount |
uint help
|
ipfsHash |
string help
|
hashes |
uint256 help
|
useIpfs |
bool help
|
active |
bool help
|
locked |
bool help
|
paused |
bool help
|
Constants (6) keyboard_arrow_up
State Variables (22) keyboard_arrow_up
Functions
balanceOf keyboard_arrow_up
Source Code
function balanceOf(address owner) public view returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _ownedTokensCount[owner].current();
}
ownerOf keyboard_arrow_up
Source Code
function ownerOf(uint256 tokenId) public view returns (address) {
address owner = _tokenOwner[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
safeTransferFrom keyboard_arrow_up
Requirements help
Source Code
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public {
safeTransferFrom(from, to, tokenId, "");
}
transferFrom keyboard_arrow_up
Requirements help
Source Code
function transferFrom(
address from,
address to,
uint256 tokenId
) public {
//solhint-disable-next-line max-line-length
require(
_isApprovedOrOwner(msg.sender, tokenId),
"ERC721: transfer caller is not owner nor approved"
);
_transferFrom(from, to, tokenId);
}
approve keyboard_arrow_up
Requirements help
Source Code
function approve(address to, uint256 tokenId) public {
address owner = ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
msg.sender == owner || isApprovedForAll(owner, msg.sender),
"ERC721: approve caller is not owner nor approved for all"
);
_tokenApprovals[tokenId] = to;
emit Approval(owner, to, tokenId);
}
getApproved keyboard_arrow_up
Requirements help
null
Source Code
function getApproved(uint256 tokenId) public view returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
setApprovalForAll keyboard_arrow_up
Requirements help
Source Code
function setApprovalForAll(address to, bool approved) public {
require(to != msg.sender, "ERC721: approve to caller");
_operatorApprovals[msg.sender][to] = approved;
emit ApprovalForAll(msg.sender, to, approved);
}
isApprovedForAll keyboard_arrow_up
safeTransferFrom keyboard_arrow_up
Requirements help
Source Code
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public {
transferFrom(from, to, tokenId);
require(
_checkOnERC721Received(from, to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
totalSupply keyboard_arrow_up
tokenOfOwnerByIndex keyboard_arrow_up
Source Code
function tokenOfOwnerByIndex(address owner, uint256 index)
public
view
returns (uint256)
{
require(
index < balanceOf(owner),
"ERC721Enumerable: owner index out of bounds"
);
return _ownedTokens[owner][index];
}
tokenByIndex keyboard_arrow_up
Requirements help
Source Code
function tokenByIndex(uint256 index) public view returns (uint256) {
require(
index < totalSupply(),
"ERC721Enumerable: global index out of bounds"
);
return _allTokens[index];
}
supportsInterface keyboard_arrow_up
name keyboard_arrow_up
symbol keyboard_arrow_up
purchase keyboard_arrow_up
Requirements help
One or more of the following:
-
the sender's address
must be equal to
undefined.artistAddress
- ORundefined.paused must not be true
Source Code
function purchase(uint256 _projectId)
public
payable
returns (uint256 _tokenId)
{
return purchaseTo(msg.sender, _projectId);
}
purchaseTo keyboard_arrow_up
Requirements help
One or more of the following:
-
the sender's address
must be equal to
undefined.artistAddress
- ORundefined.paused must not be true
Source Code
function purchaseTo(address _to, uint256 _projectId)
public
payable
returns (uint256 _tokenId)
{
require(
msg.value >= projects[_projectId].pricePerTokenInWei,
"Must send at least pricePerTokenInWei"
);
require(
projects[_projectId].invocations.add(1) <=
projects[_projectId].maxInvocations,
"Must not exceed max invocations"
);
require(
projects[_projectId].active ||
msg.sender == projects[_projectId].artistAddress,
"Project must exist and be active"
);
require(
!projects[_projectId].paused ||
msg.sender == projects[_projectId].artistAddress,
"Purchases are paused."
);
uint256 tokenId = _mintToken(_to, _projectId);
_splitFunds(_projectId);
return tokenId;
}
updateArtblocksAddress keyboard_arrow_up
Modifiers help
onlyAdmin checks for the following:
Source Code
function updateArtblocksAddress(address payable _artblocksAddress)
public
onlyAdmin
{
artblocksAddress = _artblocksAddress;
}
updateArtblocksPercentage keyboard_arrow_up
addWhitelisted keyboard_arrow_up
Modifiers help
onlyAdmin checks for the following:
Source Code
function addWhitelisted(address _address) public onlyAdmin {
isWhitelisted[_address] = true;
}
removeWhitelisted keyboard_arrow_up
Modifiers help
onlyAdmin checks for the following:
Source Code
function removeWhitelisted(address _address) public onlyAdmin {
isWhitelisted[_address] = false;
}
toggleProjectIsLocked keyboard_arrow_up
Modifiers help
onlyWhitelisted checks for the following:
onlyUnlocked checks for the following:
Source Code
function toggleProjectIsLocked(uint256 _projectId)
public
onlyWhitelisted
onlyUnlocked(_projectId)
{
projects[_projectId].locked = true;
}
toggleProjectIsActive keyboard_arrow_up
Modifiers help
onlyWhitelisted checks for the following:
Source Code
function toggleProjectIsActive(uint256 _projectId) public onlyWhitelisted {
projects[_projectId].active = !projects[_projectId].active;
}
updateProjectArtistAddress keyboard_arrow_up
Modifiers help
onlyArtistOrWhitelisted checks for the following:
Source Code
function updateProjectArtistAddress(
uint256 _projectId,
address payable _artistAddress
) public onlyArtistOrWhitelisted(_projectId) {
projects[_projectId].artistAddress = _artistAddress;
}
toggleProjectIsPaused keyboard_arrow_up
Modifiers help
onlyArtist checks for the following:
Source Code
function toggleProjectIsPaused(uint256 _projectId)
public
onlyArtist(_projectId)
{
projects[_projectId].paused = !projects[_projectId].paused;
}
addProject keyboard_arrow_up
Modifiers help
onlyWhitelisted checks for the following:
Source Code
function addProject(uint256 _pricePerTokenInWei, bool _dynamic)
public
onlyWhitelisted
{
uint256 projectId = nextProjectId;
projects[projectId].artistAddress = msg.sender;
projects[projectId].pricePerTokenInWei = _pricePerTokenInWei;
projects[projectId].paused = true;
projects[projectId].dynamic = _dynamic;
projects[projectId].maxInvocations = ONE_MILLION;
if (!_dynamic) {
projects[projectId].hashes = 0;
} else {
projects[projectId].hashes = 1;
}
nextProjectId = nextProjectId.add(1);
}
updateProjectPricePerTokenInWei keyboard_arrow_up
Modifiers help
onlyArtist checks for the following:
Source Code
function updateProjectPricePerTokenInWei(
uint256 _projectId,
uint256 _pricePerTokenInWei
) public onlyArtist(_projectId) {
projects[_projectId].pricePerTokenInWei = _pricePerTokenInWei;
}
updateProjectName keyboard_arrow_up
Modifiers help
onlyUnlocked checks for the following:
onlyArtistOrWhitelisted checks for the following:
Source Code
function updateProjectName(uint256 _projectId, string memory _projectName)
public
onlyUnlocked(_projectId)
onlyArtistOrWhitelisted(_projectId)
{
projects[_projectId].name = _projectName;
}
updateProjectArtistName keyboard_arrow_up
Modifiers help
onlyUnlocked checks for the following:
onlyArtistOrWhitelisted checks for the following:
Source Code
function updateProjectArtistName(
uint256 _projectId,
string memory _projectArtistName
) public onlyUnlocked(_projectId) onlyArtistOrWhitelisted(_projectId) {
projects[_projectId].artist = _projectArtistName;
}
updateProjectAdditionalPayeeInfo keyboard_arrow_up
Parameters help
Modifiers help
onlyArtist checks for the following:
Requirements help
Source Code
function updateProjectAdditionalPayeeInfo(
uint256 _projectId,
address payable _additionalPayee,
uint256 _additionalPayeePercentage
) public onlyArtist(_projectId) {
require(_additionalPayeePercentage <= 100, "Max of 100%");
projects[_projectId].additionalPayee = _additionalPayee;
projects[_projectId].additionalPayeePercentage = _additionalPayeePercentage;
}
updateProjectSecondaryMarketRoyaltyPercentage keyboard_arrow_up
Modifiers help
onlyArtist checks for the following:
Requirements help
Source Code
function updateProjectSecondaryMarketRoyaltyPercentage(
uint256 _projectId,
uint256 _secondMarketRoyalty
) public onlyArtist(_projectId) {
require(_secondMarketRoyalty <= 100, "Max of 100%");
projects[_projectId].secondMarketRoyalty = _secondMarketRoyalty;
}
updateProjectDescription keyboard_arrow_up
Modifiers help
onlyArtist checks for the following:
Source Code
function updateProjectDescription(
uint256 _projectId,
string memory _projectDescription
) public onlyArtist(_projectId) {
projects[_projectId].description = _projectDescription;
}
updateProjectWebsite keyboard_arrow_up
Modifiers help
onlyArtist checks for the following:
Source Code
function updateProjectWebsite(uint256 _projectId, string memory _projectWebsite)
public
onlyArtist(_projectId)
{
projects[_projectId].website = _projectWebsite;
}
updateProjectLicense keyboard_arrow_up
Modifiers help
onlyUnlocked checks for the following:
onlyArtistOrWhitelisted checks for the following:
Source Code
function updateProjectLicense(uint256 _projectId, string memory _projectLicense)
public
onlyUnlocked(_projectId)
onlyArtistOrWhitelisted(_projectId)
{
projects[_projectId].license = _projectLicense;
}
updateProjectMaxInvocations keyboard_arrow_up
Modifiers help
onlyUnlocked checks for the following:
onlyArtistOrWhitelisted checks for the following:
Requirements help
Source Code
function updateProjectMaxInvocations(
uint256 _projectId,
uint256 _maxInvocations
) public onlyUnlocked(_projectId) onlyArtistOrWhitelisted(_projectId) {
require(
_maxInvocations > projects[_projectId].invocations,
"You must set max invocations greater than current invocations"
);
require(_maxInvocations <= ONE_MILLION, "Cannot exceed 1,000,000");
projects[_projectId].maxInvocations = _maxInvocations;
}
updateProjectHashesGenerated keyboard_arrow_up
Modifiers help
onlyUnlocked checks for the following:
onlyWhitelisted checks for the following:
Requirements help
Source Code
function updateProjectHashesGenerated(uint256 _projectId, uint256 _hashes)
public
onlyUnlocked(_projectId)
onlyWhitelisted()
{
require(
projects[_projectId].invocations == 0,
"Can not modify hashes generated after a token is minted."
);
require(
projects[_projectId].dynamic,
"Can only modify hashes on dynamic projects."
);
require(
_hashes <= 100 && _hashes >= 0,
"Hashes generated must be a positive integer and max hashes per invocation are 100"
);
projects[_projectId].hashes = _hashes;
}
addProjectScript keyboard_arrow_up
Modifiers help
onlyUnlocked checks for the following:
onlyArtistOrWhitelisted checks for the following:
Source Code
function addProjectScript(uint256 _projectId, string memory _script)
public
onlyUnlocked(_projectId)
onlyArtistOrWhitelisted(_projectId)
{
projects[_projectId].scripts[projects[_projectId].scriptCount] = _script;
projects[_projectId].scriptCount = projects[_projectId].scriptCount.add(1);
}
updateProjectScript keyboard_arrow_up
Modifiers help
onlyUnlocked checks for the following:
onlyArtistOrWhitelisted checks for the following:
Requirements help
Source Code
function updateProjectScript(
uint256 _projectId,
uint256 _scriptId,
string memory _script
) public onlyUnlocked(_projectId) onlyArtistOrWhitelisted(_projectId) {
require(
_scriptId < projects[_projectId].scriptCount,
"scriptId out of range"
);
projects[_projectId].scripts[_scriptId] = _script;
}
removeProjectLastScript keyboard_arrow_up
Modifiers help
onlyUnlocked checks for the following:
onlyArtistOrWhitelisted checks for the following:
Requirements help
Source Code
function removeProjectLastScript(uint256 _projectId)
public
onlyUnlocked(_projectId)
onlyArtistOrWhitelisted(_projectId)
{
require(
projects[_projectId].scriptCount > 0,
"there are no scripts to remove"
);
delete projects[_projectId].scripts[projects[_projectId].scriptCount - 1];
projects[_projectId].scriptCount = projects[_projectId].scriptCount.sub(1);
}
updateProjectScriptJSON keyboard_arrow_up
Modifiers help
onlyUnlocked checks for the following:
onlyArtistOrWhitelisted checks for the following:
Source Code
function updateProjectScriptJSON(
uint256 _projectId,
string memory _projectScriptJSON
) public onlyUnlocked(_projectId) onlyArtistOrWhitelisted(_projectId) {
projects[_projectId].scriptJSON = _projectScriptJSON;
}
updateProjectIpfsHash keyboard_arrow_up
Modifiers help
onlyUnlocked checks for the following:
onlyArtistOrWhitelisted checks for the following:
Source Code
function updateProjectIpfsHash(uint256 _projectId, string memory _ipfsHash)
public
onlyUnlocked(_projectId)
onlyArtistOrWhitelisted(_projectId)
{
projects[_projectId].ipfsHash = _ipfsHash;
}
updateProjectBaseURI keyboard_arrow_up
Modifiers help
onlyArtist checks for the following:
Source Code
function updateProjectBaseURI(uint256 _projectId, string memory _newBaseURI)
public
onlyArtist(_projectId)
{
projects[_projectId].projectBaseURI = _newBaseURI;
}
updateProjectBaseIpfsURI keyboard_arrow_up
Modifiers help
onlyArtist checks for the following:
Source Code
function updateProjectBaseIpfsURI(
uint256 _projectId,
string memory _projectBaseIpfsURI
) public onlyArtist(_projectId) {
projects[_projectId].projectBaseIpfsURI = _projectBaseIpfsURI;
}
toggleProjectUseIpfsForStatic keyboard_arrow_up
Modifiers help
onlyArtist checks for the following:
Requirements help
Source Code
function toggleProjectUseIpfsForStatic(uint256 _projectId)
public
onlyArtist(_projectId)
{
require(
!projects[_projectId].dynamic,
"can only set static IPFS hash for static projects"
);
projects[_projectId].useIpfs = !projects[_projectId].useIpfs;
}
toggleProjectIsDynamic keyboard_arrow_up
Modifiers help
onlyUnlocked checks for the following:
onlyArtistOrWhitelisted checks for the following:
Requirements help
Source Code
function toggleProjectIsDynamic(uint256 _projectId)
public
onlyUnlocked(_projectId)
onlyArtistOrWhitelisted(_projectId)
{
require(
projects[_projectId].invocations == 0,
"Can not switch after a token is minted."
);
if (projects[_projectId].dynamic) {
projects[_projectId].hashes = 0;
} else {
projects[_projectId].hashes = 1;
}
projects[_projectId].dynamic = !projects[_projectId].dynamic;
}
overrideTokenDynamicImageWithIpfsLink keyboard_arrow_up
Modifiers help
onlyArtist checks for the following:
Source Code
function overrideTokenDynamicImageWithIpfsLink(
uint256 _tokenId,
string memory _ipfsHash
) public onlyArtist(tokenIdToProjectId[_tokenId]) {
staticIpfsImageLink[_tokenId] = _ipfsHash;
}
clearTokenIpfsImageUri keyboard_arrow_up
Modifiers help
onlyArtist checks for the following:
Source Code
function clearTokenIpfsImageUri(uint256 _tokenId)
public
onlyArtist(tokenIdToProjectId[_tokenId])
{
delete staticIpfsImageLink[tokenIdToProjectId[_tokenId]];
}
projectDetails keyboard_arrow_up
Source Code
function projectDetails(uint256 _projectId)
public
view
returns (
string memory projectName,
string memory artist,
string memory description,
string memory website,
string memory license,
bool dynamic
)
{
projectName = projects[_projectId].name;
artist = projects[_projectId].artist;
description = projects[_projectId].description;
website = projects[_projectId].website;
license = projects[_projectId].license;
dynamic = projects[_projectId].dynamic;
}
projectTokenInfo keyboard_arrow_up
Source Code
function projectTokenInfo(uint256 _projectId)
public
view
returns (
address artistAddress,
uint256 pricePerTokenInWei,
uint256 invocations,
uint256 maxInvocations,
bool active,
address additionalPayee,
uint256 additionalPayeePercentage
)
{
artistAddress = projects[_projectId].artistAddress;
pricePerTokenInWei = projects[_projectId].pricePerTokenInWei;
invocations = projects[_projectId].invocations;
maxInvocations = projects[_projectId].maxInvocations;
active = projects[_projectId].active;
additionalPayee = projects[_projectId].additionalPayee;
additionalPayeePercentage = projects[_projectId].additionalPayeePercentage;
}
projectScriptInfo keyboard_arrow_up
Source Code
function projectScriptInfo(uint256 _projectId)
public
view
returns (
string memory scriptJSON,
uint256 scriptCount,
uint256 hashes,
string memory ipfsHash,
bool locked,
bool paused
)
{
scriptJSON = projects[_projectId].scriptJSON;
scriptCount = projects[_projectId].scriptCount;
hashes = projects[_projectId].hashes;
ipfsHash = projects[_projectId].ipfsHash;
locked = projects[_projectId].locked;
paused = projects[_projectId].paused;
}
projectScriptByIndex keyboard_arrow_up
projectURIInfo keyboard_arrow_up
Source Code
function projectURIInfo(uint256 _projectId)
public
view
returns (
string memory projectBaseURI,
string memory projectBaseIpfsURI,
bool useIpfs
)
{
projectBaseURI = projects[_projectId].projectBaseURI;
projectBaseIpfsURI = projects[_projectId].projectBaseIpfsURI;
useIpfs = projects[_projectId].useIpfs;
}
projectShowAllTokens keyboard_arrow_up
showTokenHashes keyboard_arrow_up
tokensOfOwner keyboard_arrow_up
getRoyaltyData keyboard_arrow_up
Source Code
function getRoyaltyData(uint256 _tokenId)
public
view
returns (
address artistAddress,
address additionalPayee,
uint256 additionalPayeePercentage,
uint256 royaltyFeeByID
)
{
artistAddress = projects[tokenIdToProjectId[_tokenId]].artistAddress;
additionalPayee = projects[tokenIdToProjectId[_tokenId]].additionalPayee;
additionalPayeePercentage = projects[tokenIdToProjectId[_tokenId]]
.additionalPayeePercentage;
royaltyFeeByID = projects[tokenIdToProjectId[_tokenId]].secondMarketRoyalty;
}
tokenURI keyboard_arrow_up
Modifiers help
onlyValidTokenId checks for the following:
null
Source Code
function tokenURI(uint256 _tokenId)
external
view
onlyValidTokenId(_tokenId)
returns (string memory)
{
if (bytes(staticIpfsImageLink[_tokenId]).length > 0) {
return
Strings.strConcat(
projects[tokenIdToProjectId[_tokenId]].projectBaseIpfsURI,
staticIpfsImageLink[_tokenId]
);
}
if (
!projects[tokenIdToProjectId[_tokenId]].dynamic &&
projects[tokenIdToProjectId[_tokenId]].useIpfs
) {
return
Strings.strConcat(
projects[tokenIdToProjectId[_tokenId]].projectBaseIpfsURI,
projects[tokenIdToProjectId[_tokenId]].ipfsHash
);
}
return
Strings.strConcat(
projects[tokenIdToProjectId[_tokenId]].projectBaseURI,
Strings.uint2str(_tokenId)
);
}
Internal Functions
Internal functions are parts of the contract that can't be used directly, but instead are used by the public functions listed above.
internal GenArt721._mintToken keyboard_arrow_up
Requirements help
Source Code
function _mintToken(address _to, uint256 _projectId)
internal
returns (uint256 _tokenId)
{
uint256 tokenIdToBe = (_projectId * ONE_MILLION) +
projects[_projectId].invocations;
projects[_projectId].invocations = projects[_projectId].invocations.add(1);
for (uint256 i = 0; i < projects[_projectId].hashes; i++) {
bytes32 hash = keccak256(
abi.encodePacked(
projects[_projectId].invocations,
block.number.add(i),
msg.sender
)
);
tokenIdToHashes[tokenIdToBe].push(hash);
hashToTokenId[hash] = tokenIdToBe;
}
_mint(_to, tokenIdToBe);
tokenIdToProjectId[tokenIdToBe] = _projectId;
projectIdToTokenIds[_projectId].push(tokenIdToBe);
emit Mint(
_to,
tokenIdToBe,
_projectId,
projects[_projectId].invocations,
projects[_projectId].pricePerTokenInWei
);
return tokenIdToBe;
}
internal GenArt721._splitFunds keyboard_arrow_up
Source Code
function _splitFunds(uint256 _projectId) internal {
if (msg.value > 0) {
uint256 pricePerTokenInWei = projects[_projectId].pricePerTokenInWei;
uint256 refund = msg.value.sub(projects[_projectId].pricePerTokenInWei);
if (refund > 0) {
msg.sender.transfer(refund);
}
uint256 foundationAmount = pricePerTokenInWei.div(100).mul(
artblocksPercentage
);
if (foundationAmount > 0) {
artblocksAddress.transfer(foundationAmount);
}
uint256 projectFunds = pricePerTokenInWei.sub(foundationAmount);
uint256 additionalPayeeAmount;
if (projects[_projectId].additionalPayeePercentage > 0) {
additionalPayeeAmount = projectFunds.div(100).mul(
projects[_projectId].additionalPayeePercentage
);
if (additionalPayeeAmount > 0) {
projects[_projectId].additionalPayee.transfer(additionalPayeeAmount);
}
}
uint256 creatorFunds = projectFunds.sub(additionalPayeeAmount);
if (creatorFunds > 0) {
projects[_projectId].artistAddress.transfer(creatorFunds);
}
}
}
internal ERC165.constructor keyboard_arrow_up
internal ERC165._registerInterface keyboard_arrow_up
Requirements help
Source Code
function _registerInterface(bytes4 interfaceId) internal {
require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
_supportedInterfaces[interfaceId] = true;
}
internal ERC721._exists keyboard_arrow_up
internal ERC721._isApprovedOrOwner keyboard_arrow_up
Requirements help
null
Source Code
function _isApprovedOrOwner(address spender, uint256 tokenId)
internal
view
returns (bool)
{
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ownerOf(tokenId);
return (spender == owner ||
getApproved(tokenId) == spender ||
isApprovedForAll(owner, spender));
}
internal ERC721._mint keyboard_arrow_up
Requirements help
Source Code
function _mint(address to, uint256 tokenId) internal {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_tokenOwner[tokenId] = to;
_ownedTokensCount[to].increment();
emit Transfer(address(0), to, tokenId);
}
internal ERC721._burn keyboard_arrow_up
Source Code
function _burn(address owner, uint256 tokenId) internal {
require(ownerOf(tokenId) == owner, "ERC721: burn of token that is not own");
_clearApproval(tokenId);
_ownedTokensCount[owner].decrement();
_tokenOwner[tokenId] = address(0);
emit Transfer(owner, address(0), tokenId);
}
internal ERC721._burn keyboard_arrow_up
Requirements help
Source Code
function _burn(uint256 tokenId) internal {
_burn(ownerOf(tokenId), tokenId);
}
internal ERC721._transferFrom keyboard_arrow_up
Requirements help
Source Code
function _transferFrom(
address from,
address to,
uint256 tokenId
) internal {
require(
ownerOf(tokenId) == from,
"ERC721: transfer of token that is not own"
);
require(to != address(0), "ERC721: transfer to the zero address");
_clearApproval(tokenId);
_ownedTokensCount[from].decrement();
_ownedTokensCount[to].increment();
_tokenOwner[tokenId] = to;
emit Transfer(from, to, tokenId);
}
internal ERC721._checkOnERC721Received keyboard_arrow_up
Source Code
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal returns (bool) {
if (!to.isContract()) {
return true;
}
bytes4 retval = IERC721Receiver(to).onERC721Received(
msg.sender,
from,
tokenId,
_data
);
return (retval == _ERC721_RECEIVED);
}
internal ERC721._clearApproval keyboard_arrow_up
internal ERC165.constructor keyboard_arrow_up
internal ERC165._registerInterface keyboard_arrow_up
Requirements help
Source Code
function _registerInterface(bytes4 interfaceId) internal {
require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
_supportedInterfaces[interfaceId] = true;
}
internal ERC721Enumerable._transferFrom keyboard_arrow_up
Requirements help
Source Code
function _transferFrom(
address from,
address to,
uint256 tokenId
) internal {
super._transferFrom(from, to, tokenId);
_removeTokenFromOwnerEnumeration(from, tokenId);
_addTokenToOwnerEnumeration(to, tokenId);
}
internal ERC721Enumerable._mint keyboard_arrow_up
Requirements help
Source Code
function _mint(address to, uint256 tokenId) internal {
super._mint(to, tokenId);
_addTokenToOwnerEnumeration(to, tokenId);
_addTokenToAllTokensEnumeration(tokenId);
}
internal ERC721Enumerable._burn keyboard_arrow_up
Requirements help
Source Code
function _burn(address owner, uint256 tokenId) internal {
super._burn(owner, tokenId);
_removeTokenFromOwnerEnumeration(owner, tokenId);
// Since tokenId will be deleted, we can clear its slot in _ownedTokensIndex to trigger a gas refund
_ownedTokensIndex[tokenId] = 0;
_removeTokenFromAllTokensEnumeration(tokenId);
}
internal ERC721Enumerable._tokensOfOwner keyboard_arrow_up
internal ERC721Enumerable._addTokenToOwnerEnumeration keyboard_arrow_up
Source Code
function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
_ownedTokensIndex[tokenId] = _ownedTokens[to].length;
_ownedTokens[to].push(tokenId);
}
internal ERC721Enumerable._addTokenToAllTokensEnumeration keyboard_arrow_up
internal ERC721Enumerable._removeTokenFromOwnerEnumeration keyboard_arrow_up
Source Code
function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId)
private
{
// To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = _ownedTokens[from].length.sub(1);
uint256 tokenIndex = _ownedTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary
if (tokenIndex != lastTokenIndex) {
uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];
_ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
}
// This also deletes the contents at the last position of the array
_ownedTokens[from].length--;
// Note that _ownedTokensIndex[tokenId] hasn't been cleared: it still points to the old slot (now occupied by
// lastTokenId, or just over the end of the array if the token was the last one).
}
internal ERC721Enumerable._removeTokenFromAllTokensEnumeration keyboard_arrow_up
Source Code
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
// To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = _allTokens.length.sub(1);
uint256 tokenIndex = _allTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
// rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
// an 'if' statement (like in _removeTokenFromOwnerEnumeration)
uint256 lastTokenId = _allTokens[lastTokenIndex];
_allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
// This also deletes the contents at the last position of the array
_allTokens.length--;
_allTokensIndex[tokenId] = 0;
}
internal ERC165.constructor keyboard_arrow_up
internal ERC165._registerInterface keyboard_arrow_up
Requirements help
Source Code
function _registerInterface(bytes4 interfaceId) internal {
require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
_supportedInterfaces[interfaceId] = true;
}
internal ERC721._exists keyboard_arrow_up
internal ERC721._isApprovedOrOwner keyboard_arrow_up
Requirements help
null
Source Code
function _isApprovedOrOwner(address spender, uint256 tokenId)
internal
view
returns (bool)
{
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ownerOf(tokenId);
return (spender == owner ||
getApproved(tokenId) == spender ||
isApprovedForAll(owner, spender));
}
internal ERC721._mint keyboard_arrow_up
Requirements help
Source Code
function _mint(address to, uint256 tokenId) internal {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_tokenOwner[tokenId] = to;
_ownedTokensCount[to].increment();
emit Transfer(address(0), to, tokenId);
}
internal ERC721._burn keyboard_arrow_up
Requirements help
Source Code
function _burn(address owner, uint256 tokenId) internal {
require(ownerOf(tokenId) == owner, "ERC721: burn of token that is not own");
_clearApproval(tokenId);
_ownedTokensCount[owner].decrement();
_tokenOwner[tokenId] = address(0);
emit Transfer(owner, address(0), tokenId);
}
internal ERC721._burn keyboard_arrow_up
Requirements help
Source Code
function _burn(uint256 tokenId) internal {
_burn(ownerOf(tokenId), tokenId);
}
internal ERC721._transferFrom keyboard_arrow_up
Requirements help
Source Code
function _transferFrom(
address from,
address to,
uint256 tokenId
) internal {
require(
ownerOf(tokenId) == from,
"ERC721: transfer of token that is not own"
);
require(to != address(0), "ERC721: transfer to the zero address");
_clearApproval(tokenId);
_ownedTokensCount[from].decrement();
_ownedTokensCount[to].increment();
_tokenOwner[tokenId] = to;
emit Transfer(from, to, tokenId);
}
internal ERC721._checkOnERC721Received keyboard_arrow_up
Source Code
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal returns (bool) {
if (!to.isContract()) {
return true;
}
bytes4 retval = IERC721Receiver(to).onERC721Received(
msg.sender,
from,
tokenId,
_data
);
return (retval == _ERC721_RECEIVED);
}
internal ERC721._clearApproval keyboard_arrow_up
internal ERC165.constructor keyboard_arrow_up
internal ERC165._registerInterface keyboard_arrow_up
Requirements help
Source Code
function _registerInterface(bytes4 interfaceId) internal {
require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
_supportedInterfaces[interfaceId] = true;
}