Blockwell

Planet-1

About

Stats

Public Functions 31
Event Types 4
Code Size 105,540 bytes

Library Use

Uses SafeMath for uint256.
Uses SafeMath for uint32.
Uses SafeERC20 for IERC20.
Uses Counters for Counters.Counter.
Uses EnumerableSet for EnumerableSet.UintSet.
Uses EnumerableMap for EnumerableMap.UintToAddressMap.

Events (4) keyboard_arrow_up

Approval Event

Parameters help
owner
address help
approved
address help
tokenId
uint256 help

ApprovalForAll Event

Parameters help
owner
address help
operator
address help
approved
bool help

OwnershipTransferred Event

Parameters help
previousOwner
address help
newOwner
address help

Transfer Event

Parameters help
from
address help
to
address help
tokenId
uint256 help

_ERC721_RECEIVED Constant

bytes4 help
0x150b7a02

_INTERFACE_ID_ERC721 Constant

bytes4 help
0x80ac58cd

_INTERFACE_ID_ERC721_METADATA Constant

bytes4 help
0x5b5e139f

_INTERFACE_ID_ERC721_ENUMERABLE Constant

bytes4 help
0x780e9d63

_INTERFACE_ID_ERC165 Constant

bytes4 help
0x01ffc9a7

dnftTokenAddr Variable

address help

uniswapAddr Variable

address help

mainAddr Variable

address help

mintPerTimeValue Variable

uint256 help

pid Variable

uint16 help

maxMintTime Variable

uint256 help

maxTokenSize Variable

uint256 help

costTokenAddr Variable

address help

cost Variable

uint256 help

totalReturnRate Variable

uint32 help

mintTimeInterval Variable

uint256 help

costTokenDecimals Variable

uint8 help

_tokenDetails Variable

mapping(uint256 => Lib.ProductTokenDetail) help
Internal Variable

_tokenMintHistories Variable

mapping(uint256 => Lib.ProductMintItem[]) help
Internal Variable

_tokenMints Variable

mapping(address => EnumerableSet.UintSet) help
Internal Variable

_tokenIds Variable

Counters.Counter help
Internal Variable

_init Variable

bool help
Internal Variable

_holderTokens Variable

mapping(address => EnumerableSet.UintSet) help
Internal Variable

_tokenOwners Variable

EnumerableMap.UintToAddressMap help
Internal Variable

_tokenApprovals Variable

mapping(uint256 => address) help
Internal Variable

_operatorApprovals Variable

mapping(address => mapping(address => bool)) help
Internal Variable

_name Variable

string help
Internal Variable

_symbol Variable

string help
Internal Variable

_tokenURIs Variable

mapping(uint256 => string) help
Internal Variable

_baseURI Variable

string help
Internal Variable

_supportedInterfaces Variable

mapping(bytes4 => bool) help
Internal Variable

_owner Variable

address help
Internal Variable

Functions Expand All Collapse All

owner keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
function owner() public view returns (address) {
  return _owner;
}

renounceOwnership keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help transaction

Modifiers help

Source Code
function renounceOwnership() public virtual onlyOwner {
  emit OwnershipTransferred(_owner, address(0));
  _owner = address(0);
}

transferOwnership keyboard_arrow_up

Parameters help

Name Type
newOwner
address help

Properties

Visibility help public
Mutability help transaction

Modifiers help

Requirements help

Source Code
function transferOwnership(address newOwner) public virtual onlyOwner {
  require(newOwner != address(0), "Ownable: new owner is the zero address");
  emit OwnershipTransferred(_owner, newOwner);
  _owner = newOwner;
}

supportsInterface keyboard_arrow_up

Parameters help

Name Type
interfaceId
bytes4 help

Properties

Visibility help public
Mutability help view
Source Code
function supportsInterface(bytes4 interfaceId)
  public
  view
  override
  returns (bool)
{
  return _supportedInterfaces[interfaceId];
}

Parameters help

Name Type
owner
address help

Properties

Visibility help public
Mutability help view

Requirements help

Source Code
function balanceOf(address owner) public view override returns (uint256) {
  require(owner != address(0), "ERC721: balance query for the zero address");

  return _holderTokens[owner].length();
}

ownerOf keyboard_arrow_up

Parameters help

Name Type
tokenId
uint256 help

Properties

Visibility help public
Mutability help view
Source Code
function ownerOf(uint256 tokenId) public view override returns (address) {
  return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token");
}

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
function name() public view override returns (string memory) {
  return _name;
}

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
function symbol() public view override returns (string memory) {
  return _symbol;
}

tokenURI keyboard_arrow_up

Parameters help

Name Type
tokenId
uint256 help

Properties

Visibility help public
Mutability help view

Requirements help

null
Source Code
function tokenURI(uint256 tokenId)
  public
  view
  override
  returns (string memory)
{
  require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");

  string memory _tokenURI = _tokenURIs[tokenId];

  // If there is no base URI, return the token URI.
  if (bytes(_baseURI).length == 0) {
    return _tokenURI;
  }
  // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).
  if (bytes(_tokenURI).length > 0) {
    return string(abi.encodePacked(_baseURI, _tokenURI));
  }
  // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI.
  return string(abi.encodePacked(_baseURI, tokenId.toString()));
}

baseURI keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
function baseURI() public view returns (string memory) {
  return _baseURI;
}

tokenOfOwnerByIndex keyboard_arrow_up

Parameters help

Name Type
owner
address help
index
uint256 help

Properties

Visibility help public
Mutability help view
Source Code
function tokenOfOwnerByIndex(address owner, uint256 index)
  public
  view
  override
  returns (uint256)
{
  return _holderTokens[owner].at(index);
}

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
function totalSupply() public view override returns (uint256) {
  // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds
  return _tokenOwners.length();
}

tokenByIndex keyboard_arrow_up

Parameters help

Name Type
index
uint256 help

Properties

Visibility help public
Mutability help view
Source Code
function tokenByIndex(uint256 index) public view override returns (uint256) {
  (uint256 tokenId, ) = _tokenOwners.at(index);
  return tokenId;
}

Parameters help

Name Type
to
address help
tokenId
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
function approve(address to, uint256 tokenId) public virtual override {
  address owner = 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);
}

getApproved keyboard_arrow_up

Parameters help

Name Type
tokenId
uint256 help

Properties

Visibility help public
Mutability help view

Requirements help

null
Source Code
function getApproved(uint256 tokenId) public view override returns (address) {
  require(_exists(tokenId), "ERC721: approved query for nonexistent token");

  return _tokenApprovals[tokenId];
}

setApprovalForAll keyboard_arrow_up

Parameters help

Name Type
operator
address help
approved
bool help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function setApprovalForAll(address operator, bool approved)
  public
  virtual
  override
{
  require(operator != _msgSender(), "ERC721: approve to caller");

  _operatorApprovals[_msgSender()][operator] = approved;
  emit ApprovalForAll(_msgSender(), operator, approved);
}

isApprovedForAll keyboard_arrow_up

Parameters help

Name Type
owner
address help
operator
address help

Properties

Visibility help public
Mutability help view
Source Code
function isApprovedForAll(address owner, address operator)
  public
  view
  override
  returns (bool)
{
  return _operatorApprovals[owner][operator];
}

Parameters help

Name Type
from
address help
to
address help
tokenId
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
function transferFrom(
  address from,
  address to,
  uint256 tokenId
) public virtual override {
  //solhint-disable-next-line max-line-length
  require(
    _isApprovedOrOwner(_msgSender(), tokenId),
    "ERC721: transfer caller is not owner nor approved"
  );

  _transfer(from, to, tokenId);
}

safeTransferFrom keyboard_arrow_up

Parameters help

Name Type
from
address help
to
address help
tokenId
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
function safeTransferFrom(
  address from,
  address to,
  uint256 tokenId
) public virtual override {
  safeTransferFrom(from, to, tokenId, "");
}

safeTransferFrom keyboard_arrow_up

Parameters help

Name Type
from
address help
to
address help
tokenId
uint256 help
_data
bytes help

Properties

Visibility help public
Mutability help transaction
Source Code
function safeTransferFrom(
  address from,
  address to,
  uint256 tokenId,
  bytes memory _data
) public virtual override {
  require(
    _isApprovedOrOwner(_msgSender(), tokenId),
    "ERC721: transfer caller is not owner nor approved"
  );
  _safeTransfer(from, to, tokenId, _data);
}

initProduct keyboard_arrow_up

Parameters help

Name Type
_mainAddr
address help
_dnftTokenAddr
address help
_uniswapAddr
address help
_id
uint16 help
_costTokenAddr
address help
_cost
uint256 help
_totalReturnRate
uint32 help
_maxMintTime
uint256 help
_maxTokenSize
uint256 help

Properties

Visibility help public
Mutability help transaction

Modifiers help

Source Code
function initProduct(
  address _mainAddr,
  address _dnftTokenAddr,
  address _uniswapAddr,
  uint16 _id,
  address _costTokenAddr,
  uint256 _cost,
  uint32 _totalReturnRate,
  uint256 _maxMintTime,
  uint256 _maxTokenSize
) external onlyOwner {
  require(!_init, "repeat init");
  require(_maxTokenSize < 1E6, "product total supply must be < 1E6");
  mainAddr = _mainAddr;
  pid = _id;
  costTokenAddr = _costTokenAddr;
  cost = _cost;
  maxTokenSize = _maxTokenSize;
  maxMintTime = _maxMintTime;
  totalReturnRate = _totalReturnRate;
  dnftTokenAddr = _dnftTokenAddr;
  uniswapAddr = _uniswapAddr;
  if (_costTokenAddr != address(0)) {
    costTokenDecimals = IERC20Token(_costTokenAddr).decimals();
  } else {
    costTokenDecimals = 18;
  }
  mintTimeInterval = 1 minutes;
  mintPerTimeValue = totalReturnRate.mul(cost).div(100).div(
    maxMintTime.div(mintTimeInterval)
  );
}

getDNFTPrice keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
function getDNFTPrice() external view returns (uint256) {
  return _getDNFTPrice();
}

tokensOfOwner keyboard_arrow_up

Parameters help

Name Type
owner
address help

Properties

Visibility help public
Mutability help view
Source Code
function tokensOfOwner(address owner)
  external
  view
  returns (Lib.ProductTokenDetail[] memory)
{
  EnumerableSet.UintSet storage mintTokens = _tokenMints[owner];
  uint256 holdLength = balanceOf(owner);
  uint256 tokenLengthSize = mintTokens.length() + holdLength;
  if (tokenLengthSize == 0) {
    Lib.ProductTokenDetail[] memory zt = new Lib.ProductTokenDetail[](0);
    return zt;
  }
  Lib.ProductTokenDetail[] memory tokens = new Lib.ProductTokenDetail[](
    tokenLengthSize
  );
  uint256 i = 0;
  while (i < mintTokens.length()) {
    tokens[i] = _tokenDetails[mintTokens.at(i)];
    i++;
  }
  uint256 j = 0;
  while (j < holdLength) {
    tokens[i] = _tokenDetails[tokenOfOwnerByIndex(owner, j)];
    i++;
    j++;
  }
  return tokens;
}

tokenDetailOf keyboard_arrow_up

Parameters help

Name Type
tid
uint256 help

Properties

Visibility help public
Mutability help view
Source Code
function tokenDetailOf(uint256 tid)
  external
  view
  returns (Lib.ProductTokenDetail memory)
{
  return _tokenDetails[tid];
}

tokenMintHistoryOf keyboard_arrow_up

Parameters help

Name Type
tid
uint256 help

Properties

Visibility help public
Mutability help view
Source Code
function tokenMintHistoryOf(uint256 tid)
  external
  view
  returns (Lib.ProductMintItem[] memory)
{
  return _tokenMintHistories[tid];
}

withdrawToken keyboard_arrow_up

Parameters help

Name Type
to
address help
token
address help
value
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
function withdrawToken(
  address payable to,
  address token,
  uint256 value
) external onlyMain {
  if (token == address(0)) to.transfer(value);
  else IERC20(token).safeTransfer(to, value);
}

buy keyboard_arrow_up

Parameters help

Name Type
to
address help

Properties

Visibility help public
Mutability help transaction
Source Code
function buy(address to) external onlyMain returns (uint256) {
  require(_tokenIds.current() < maxTokenSize, "product not enough");
  _tokenIds.increment();
  uint256 tid = pid * 1E6 + _tokenIds.current();
  Lib.ProductTokenDetail memory detail;
  detail.id = tid;
  detail.propA = Lib.random(0, 10000);
  detail.propB = Lib.random(0, 10000);
  detail.propC = Lib.random(0, 10000);
  _tokenDetails[tid] = detail;
  _safeMint(to, tid);
  _setTokenURI(tid, Strings.toString(tid));
  return tid;
}

mintBegin keyboard_arrow_up

Parameters help

Name Type
from
address help
tokenId
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
function mintBegin(address from, uint256 tokenId) external onlyMain {
  require(
    _isApprovedOrOwner(from, tokenId),
    "ERC721: transfer caller is not owner nor approved"
  );
  Lib.ProductTokenDetail storage detail = _tokenDetails[tokenId];
  require(detail.mining == false, "Token already mining.");
  require(detail.totalTime < maxMintTime, "Token already dead.");
  detail.mining = true;
  detail.currMining.minter = from;
  detail.currMining.beginTime = block.timestamp;
  detail.currMining.endTime = 0;
  detail.currMining.withdrawTime = detail.currMining.beginTime;
  _tokenMints[from].add(tokenId);
  _transfer(from, address(this), tokenId);
}

canWithdrawValue keyboard_arrow_up

Parameters help

Name Type
tokenId
uint256 help

Properties

Visibility help public
Mutability help view
Source Code
function canWithdrawValue(uint256 tokenId)
  external
  view
  returns (uint256 timeNum, uint256 dnftNum)
{
  return _canWithdrawValue(tokenId);
}

mintWithdraw keyboard_arrow_up

Parameters help

Name Type
from
address help
tokenId
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
function mintWithdraw(address from, uint256 tokenId)
  external
  onlyMain
  returns (uint256, uint256)
{
  _onlyMinter(from, tokenId);
  return _mintWithdraw(from, tokenId);
}

redeem keyboard_arrow_up

Parameters help

Name Type
from
address help
tokenId
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
function redeem(address from, uint256 tokenId)
  external
  onlyMain
  returns (uint256, uint256)
{
  _onlyMinter(from, tokenId);
  (uint256 withdrawNum, uint256 timeNum) = _mintWithdraw(from, tokenId);

  Lib.ProductTokenDetail storage detail = _tokenDetails[tokenId];
  detail.mining = false;
  detail.currMining.endTime = block.timestamp;
  _tokenMintHistories[tokenId].push(detail.currMining);

  _tokenMints[from].remove(tokenId);
  Lib.ProductMintItem memory currItem;
  detail.currMining = currItem;

  _safeTransfer(address(this), from, tokenId, "");
  return (withdrawNum, timeNum);
}

Internal Functions Expand All Collapse All

Internal functions are parts of the contract that can't be used directly, but instead are used by the public functions listed above.

internal DNFTProduct._onlyMinter keyboard_arrow_up

Parameters help

Name Type
from
address help
tokenId
uint256 help

Properties

Visibility help private
Mutability help view
Source Code
function _onlyMinter(address from, uint256 tokenId) private view {
  require(
    _isApprovedOrOwner(address(this), tokenId),
    "ERC721: transfer caller is not owner nor approved"
  );
  require(_tokenDetails[tokenId].mining == true, "Token no mining.");
  require(
    _tokenDetails[tokenId].currMining.minter == from,
    "Token mine is not owner."
  );
}

internal DNFTProduct._getUniswapPrice keyboard_arrow_up

Parameters help

Name Type
r02
IUniswapV2Router02 help
_tv1
uint256 help
token1
address help
token2
address help

Properties

Visibility help private
Mutability help view
Source Code
function _getUniswapPrice(
  IUniswapV2Router02 r02,
  uint256 _tv1,
  address token1,
  address token2
) private view returns (uint256) {
  uint256 tv1 = _tv1;
  IUniswapV2Factory f = IUniswapV2Factory(r02.factory());
  address pairAddr = f.getPair(token1, token2);
  require(pairAddr != address(0), "DNFT uniswap pair not exists.");
  IERC20Token t1 = IERC20Token(token1);
  IERC20Token t2 = IERC20Token(token2);
  uint256 tb1 = t1.balanceOf(pairAddr);
  uint256 tb2 = t2.balanceOf(pairAddr);
  require(tb1 > 0 && tb2 > 0, "Pair token balance < 0");
  uint256 td1 = 10**t1.decimals();
  return td1.mul(tv1).div(tb1).mul(tb2).div(td1);
}

internal DNFTProduct._getDNFTPrice keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help private
Mutability help view
Source Code
function _getDNFTPrice() private view returns (uint256) {
  if (costTokenAddr == address(dnftTokenAddr)) return 1E8;
  if (uniswapAddr == address(0)) {
    return 1000 * 1E8;
  }
  IUniswapV2Router02 r02 = IUniswapV2Router02(uniswapAddr);
  address wethAddr = r02.WETH();
  uint256 oneEthDnftPrice = _getUniswapPrice(
    r02,
    1E18,
    wethAddr,
    address(dnftTokenAddr)
  );
  if (costTokenAddr == address(0)) {
    return oneEthDnftPrice;
  } else {
    uint256 oneEthTokenPrice = _getUniswapPrice(
      r02,
      1E18,
      wethAddr,
      costTokenAddr
    );
    if (costTokenDecimals == 8)
      return ((oneEthDnftPrice * 1E8) / oneEthTokenPrice);
    if (costTokenDecimals < 8)
      return ((oneEthDnftPrice * 1E8) /
        oneEthTokenPrice /
        (10**(8 - uint256(costTokenDecimals))));
    return
      ((oneEthDnftPrice * 1E8) / oneEthTokenPrice) *
      (10**(uint256(costTokenDecimals) - 8));
  }
}

internal DNFTProduct._canWithdrawValue keyboard_arrow_up

Parameters help

Name Type
tokenId
uint256 help

Properties

Visibility help private
Mutability help view
Source Code
function _canWithdrawValue(uint256 tokenId)
  private
  view
  returns (uint256 timeNum, uint256 dnftNum)
{
  uint256 price = _getDNFTPrice();
  Lib.ProductTokenDetail storage detail = _tokenDetails[tokenId];
  uint256 freeTimeNum = (maxMintTime.sub(detail.totalTime)).div(
    mintTimeInterval
  );
  if (freeTimeNum <= 0) {
    return (0, 0);
  }
  timeNum = block.timestamp.sub(detail.currMining.withdrawTime).div(
    mintTimeInterval
  );
  if (timeNum > freeTimeNum) {
    timeNum = freeTimeNum;
  }
  if (timeNum <= 0) {
    return (0, 0);
  }
  uint256 decimal = 18;
  if (costTokenAddr != address(0)) decimal = uint256(costTokenDecimals);
  dnftNum = mintPerTimeValue.mul(price).mul(timeNum).div(10**decimal);
  if (dnftNum <= 0) {
    return (0, 0);
  }
}

internal DNFTProduct._mintWithdraw keyboard_arrow_up

Parameters help

Name Type
player
address help
tokenId
uint256 help

Properties

Visibility help private
Mutability help transaction
Source Code
function _mintWithdraw(address player, uint256 tokenId)
  private
  returns (uint256, uint256)
{
  (uint256 timeNum, uint256 dnftNum) = _canWithdrawValue(tokenId);
  if (dnftNum <= 0) return (dnftNum, timeNum);
  Lib.ProductTokenDetail storage detail = _tokenDetails[tokenId];
  detail.totalValue = detail.totalValue.add(dnftNum);
  detail.currMining.totalValue = detail.currMining.totalValue.add(dnftNum);
  uint256 useTime = timeNum.mul(mintTimeInterval);
  detail.currMining.withdrawTime = detail.currMining.withdrawTime.add(useTime);
  detail.totalTime = detail.totalTime.add(useTime);
  IERC20Token(dnftTokenAddr).transfer(player, dnftNum);
  return (dnftNum, timeNum);
}

internal ERC721._safeTransfer keyboard_arrow_up

Parameters help

Name Type
from
address help
to
address help
tokenId
uint256 help
_data
bytes help

Properties

Visibility help internal
Mutability help transaction

Requirements help

Source Code
function _safeTransfer(
  address from,
  address to,
  uint256 tokenId,
  bytes memory _data
) internal virtual {
  _transfer(from, to, tokenId);
  require(
    _checkOnERC721Received(from, to, tokenId, _data),
    "ERC721: transfer to non ERC721Receiver implementer"
  );
}

internal ERC721._exists keyboard_arrow_up

Parameters help

Name Type
tokenId
uint256 help

Properties

Visibility help internal
Mutability help view
Source Code
function _exists(uint256 tokenId) internal view returns (bool) {
  return _tokenOwners.contains(tokenId);
}

internal ERC721._isApprovedOrOwner keyboard_arrow_up

Parameters help

Name Type
spender
address help
tokenId
uint256 help

Properties

Visibility help internal
Mutability help view

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._safeMint keyboard_arrow_up

Parameters help

Name Type
to
address help
tokenId
uint256 help

Properties

Visibility help internal
Mutability help transaction
Source Code
function _safeMint(address to, uint256 tokenId) internal virtual {
  _safeMint(to, tokenId, "");
}

internal ERC721._safeMint keyboard_arrow_up

Parameters help

Name Type
to
address help
tokenId
uint256 help
_data
bytes help

Properties

Visibility help internal
Mutability help transaction
Source Code
function _safeMint(
  address to,
  uint256 tokenId,
  bytes memory _data
) internal virtual {
  _mint(to, tokenId);
  require(
    _checkOnERC721Received(address(0), to, tokenId, _data),
    "ERC721: transfer to non ERC721Receiver implementer"
  );
}

internal ERC721._mint keyboard_arrow_up

Parameters help

Name Type
to
address help
tokenId
uint256 help

Properties

Visibility help internal
Mutability help transaction
Source Code
function _mint(address to, uint256 tokenId) internal virtual {
  require(to != address(0), "ERC721: mint to the zero address");
  require(!_exists(tokenId), "ERC721: token already minted");

  _beforeTokenTransfer(address(0), to, tokenId);

  _holderTokens[to].add(tokenId);

  _tokenOwners.set(tokenId, to);

  emit Transfer(address(0), to, tokenId);
}

internal ERC721._burn keyboard_arrow_up

Parameters help

Name Type
tokenId
uint256 help

Properties

Visibility help internal
Mutability help transaction
Source Code
function _burn(uint256 tokenId) internal virtual {
  address owner = ownerOf(tokenId);

  _beforeTokenTransfer(owner, address(0), tokenId);

  // Clear approvals
  _approve(address(0), tokenId);

  // Clear metadata (if any)
  if (bytes(_tokenURIs[tokenId]).length != 0) {
    delete _tokenURIs[tokenId];
  }

  _holderTokens[owner].remove(tokenId);

  _tokenOwners.remove(tokenId);

  emit Transfer(owner, address(0), tokenId);
}

internal ERC721._transfer keyboard_arrow_up

Parameters help

Name Type
from
address help
to
address help
tokenId
uint256 help

Properties

Visibility help internal
Mutability help transaction

Requirements help

Source Code
function _transfer(
  address from,
  address to,
  uint256 tokenId
) internal virtual {
  require(
    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);

  _holderTokens[from].remove(tokenId);
  _holderTokens[to].add(tokenId);

  _tokenOwners.set(tokenId, to);

  emit Transfer(from, to, tokenId);
}

internal ERC721._setTokenURI keyboard_arrow_up

Parameters help

Name Type
tokenId
uint256 help
_tokenURI
string help

Properties

Visibility help internal
Mutability help transaction

Requirements help

null
Source Code
function _setTokenURI(uint256 tokenId, string memory _tokenURI)
  internal
  virtual
{
  require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token");
  _tokenURIs[tokenId] = _tokenURI;
}

internal ERC721._setBaseURI keyboard_arrow_up

Parameters help

Name Type
baseURI_
string help

Properties

Visibility help internal
Mutability help transaction
Source Code
function _setBaseURI(string memory baseURI_) internal virtual {
  _baseURI = baseURI_;
}

internal ERC721._checkOnERC721Received keyboard_arrow_up

Parameters help

Name Type
from
address help
to
address help
tokenId
uint256 help
_data
bytes help

Properties

Visibility help private
Mutability help transaction
Source Code
function _checkOnERC721Received(
  address from,
  address to,
  uint256 tokenId,
  bytes memory _data
) private returns (bool) {
  if (!to.isContract()) {
    return true;
  }
  bytes memory returndata = to.functionCall(
    abi.encodeWithSelector(
      IERC721Receiver(to).onERC721Received.selector,
      _msgSender(),
      from,
      tokenId,
      _data
    ),
    "ERC721: transfer to non ERC721Receiver implementer"
  );
  bytes4 retval = abi.decode(returndata, (bytes4));
  return (retval == _ERC721_RECEIVED);
}

internal ERC721._approve keyboard_arrow_up

Parameters help

Name Type
to
address help
tokenId
uint256 help

Properties

Visibility help private
Mutability help transaction
Source Code
function _approve(address to, uint256 tokenId) private {
  _tokenApprovals[tokenId] = to;
  emit Approval(ownerOf(tokenId), to, tokenId);
}

internal ERC721._beforeTokenTransfer keyboard_arrow_up

Parameters help

Name Type
from
address help
to
address help
tokenId
uint256 help

Properties

Visibility help internal
Mutability help transaction
Source Code
function _beforeTokenTransfer(
  address from,
  address to,
  uint256 tokenId
) internal virtual {}

internal Context._msgSender keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help internal
Mutability help view
Source Code
function _msgSender() internal view virtual returns (address payable) {
  return msg.sender;
}

internal Context._msgData keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help internal
Mutability help view
Source Code
function _msgData() internal view virtual returns (bytes memory) {
  this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
  return msg.data;
}

internal ERC165._registerInterface keyboard_arrow_up

Parameters help

Name Type
interfaceId
bytes4 help

Properties

Visibility help internal
Mutability help transaction

Requirements help

Source Code
function _registerInterface(bytes4 interfaceId) internal virtual {
  require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
  _supportedInterfaces[interfaceId] = true;
}

internal Context._msgSender keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help internal
Mutability help view
Source Code
function _msgSender() internal view virtual returns (address payable) {
  return msg.sender;
}

internal Context._msgData keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help internal
Mutability help view
Source Code
function _msgData() internal view virtual returns (bytes memory) {
  this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
  return msg.data;
}