Blockwell

Ephimera

About

Stats

Public Functions 15
Event Types 3
Code Size 49,175 bytes

Library Use

Uses SafeMath for uint256.

Events (3) 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

Transfer Event

Parameters help
from
address help
to
address help
tokenId
uint256 help

_INTERFACE_ID_ERC721 Constant

bytes4 help
0x80ac58cd

_INTERFACE_ID_ERC721_METADATA Constant

bytes4 help
0x5b5e139f

ERC721_RECEIVED Constant

bytes4 help
UNKNOWN VALUE

_INTERFACE_ID_ERC165 Constant

bytes4 help
0x01ffc9a7

tokenPointer Variable

uint256 help

name Variable

string help

symbol Variable

string help

totalSupply Variable

uint256 help

accessControls Variable

address help

tokenTransferCount Variable

mapping(uint256 => uint256) help

owners Variable

mapping(uint256 => address) help
Internal Variable

approvals Variable

mapping(uint256 => address) help
Internal Variable

balances Variable

mapping(address => uint256) help
Internal Variable

operatorApprovals Variable

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

tokenURIs Variable

mapping(uint256 => string) help
Internal Variable

_supportedInterfaces Variable

mapping(bytes4 => bool) help
Internal Variable

Functions Expand All Collapse All

supportsInterface keyboard_arrow_up

Parameters help

Name Type
interfaceId
bytes4 help

Properties

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

setTokenURI keyboard_arrow_up

Parameters help

Name Type
_tokenId
uint256 help
_uri
string help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function setTokenURI(uint256 _tokenId, string calldata _uri) external {
  require(
    owners[_tokenId] != address(0),
    "EphimeraToken.setTokenURI: token does not exist."
  );
  require(
    accessControls.hasAdminRole(_msgSender()),
    "EphimeraToken.setTokenURI: caller is not a admin."
  );
  tokenURIs[_tokenId] = _uri;
}

mint keyboard_arrow_up

Parameters help

Name Type
_to
address help
_uri
string help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function mint(address _to, string calldata _uri) external returns (uint256) {
  require(_to != address(0), "ERC721: mint to the zero address");
  require(
    accessControls.hasContractWhitelistRole(_msgSender()),
    "EphimeraToken.mint: caller is not whitelisted."
  );

  tokenPointer = tokenPointer.add(1);
  uint256 tokenId = tokenPointer;

  // Mint
  owners[tokenId] = _to;
  balances[_to] = balances[_to].add(1);

  // MetaData
  tokenURIs[tokenId] = _uri;
  totalSupply = totalSupply.add(1);

  tokenTransferCount[tokenId] = 1;

  // Single Transfer event for a single token
  emit Transfer(address(0), _to, tokenId);

  return tokenId;
}

tokenURI keyboard_arrow_up

Parameters help

Name Type
_tokenId
uint256 help

Properties

Visibility help public
Mutability help view
Source Code
function tokenURI(uint256 _tokenId) external view returns (string memory) {
  return tokenURIs[_tokenId];
}

exists keyboard_arrow_up

Parameters help

Name Type
_tokenId
uint256 help

Properties

Visibility help public
Mutability help view
Source Code
function exists(uint256 _tokenId) external view returns (bool) {
  return owners[_tokenId] != address(0);
}

burn keyboard_arrow_up

Parameters help

Name Type
_tokenId
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
function burn(uint256 _tokenId) external {
  require(
    _msgSender() == ownerOf(_tokenId),
    "EphimeraToken.burn: Caller must be owner."
  );
  _burn(_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 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 override {
  transferFrom(_from, _to, _tokenId);
  require(
    _checkOnERC721Received(_from, _to, _tokenId, _data),
    "ERC721: transfer to non ERC721Receiver implementer"
  );
}

Parameters help

Name Type
_approved
address help
_tokenId
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
function approve(address _approved, uint256 _tokenId) external override {
  address owner = ownerOf(_tokenId);
  require(_approved != owner, "ERC721: approval to current owner");

  require(
    _msgSender() == owner || isApprovedForAll(owner, _msgSender()),
    "ERC721: approve caller is not owner nor approved for all"
  );

  approvals[_tokenId] = _approved;
  emit Approval(owner, _approved, _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)
  external
  override
{
  require(_operator != _msgSender(), "ERC721: approve to caller");

  operatorApprovals[_msgSender()][_operator] = _approved;
  emit ApprovalForAll(_msgSender(), _operator, _approved);
}

Parameters help

Name Type
_owner
address help

Properties

Visibility help public
Mutability help view

Requirements help

Source Code
function balanceOf(address _owner) external view override returns (uint256) {
  require(_owner != address(0), "ERC721: owner query for nonexistent token");
  return balances[_owner];
}

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 override {
  require(_to != address(0), "ERC721_ZERO_TO_ADDRESS");

  address owner = ownerOf(_tokenId);
  require(_from == owner, "ERC721_OWNER_MISMATCH");

  address spender = _msgSender();
  address approvedAddress = getApproved(_tokenId);
  require(
    spender == owner ||
      isApprovedForAll(owner, spender) ||
      approvedAddress == spender,
    "ERC721_INVALID_SPENDER"
  );

  if (approvedAddress != address(0)) {
    approvals[_tokenId] = address(0);
  }

  owners[_tokenId] = _to;
  balances[_from] = balances[_from].sub(1);
  balances[_to] = balances[_to].add(1);

  tokenTransferCount[_tokenId] = tokenTransferCount[_tokenId].add(1);

  emit Transfer(_from, _to, _tokenId);
}

ownerOf keyboard_arrow_up

Parameters help

Name Type
_tokenId
uint256 help

Properties

Visibility help public
Mutability help view

Requirements help

Source Code
function ownerOf(uint256 _tokenId) public view override returns (address) {
  address owner = owners[_tokenId];
  require(owner != address(0), "ERC721: owner query for nonexistent token");
  return owner;
}

getApproved keyboard_arrow_up

Parameters help

Name Type
_tokenId
uint256 help

Properties

Visibility help public
Mutability help view

Requirements help

Source Code
function getApproved(uint256 _tokenId) public view override returns (address) {
  require(
    owners[_tokenId] != address(0),
    "ERC721: approved query for nonexistent token"
  );
  return approvals[_tokenId];
}

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];
}

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 EphimeraToken.isContract keyboard_arrow_up

Parameters help

Name Type
account
address help

Properties

Visibility help internal
Mutability help view
Source Code
function isContract(address account) internal view returns (bool) {
  // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
  // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
  // for accounts without code, i.e. `keccak256('')`
  bytes32 codehash;

    bytes32 accountHash
   = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
  // solhint-disable-next-line no-inline-assembly
  assembly {
    codehash := extcodehash(account)
  }
  return (codehash != accountHash && codehash != 0x0);
}

internal EphimeraToken._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 (!isContract(to)) {
    return true;
  }
  // solhint-disable-next-line avoid-low-level-calls
  (bool success, bytes memory returndata) = to.call(
    abi.encodeWithSelector(
      IERC721Receiver(to).onERC721Received.selector,
      _msgSender(),
      from,
      tokenId,
      _data
    )
  );
  if (!success) {
    if (returndata.length > 0) {
      // solhint-disable-next-line no-inline-assembly
      assembly {
        let returndata_size := mload(returndata)
        revert(add(32, returndata), returndata_size)
      }
    } else {
      revert("ERC721: transfer to non ERC721Receiver implementer");
    }
  } else {
    bytes4 retval = abi.decode(returndata, (bytes4));
    return (retval == ERC721_RECEIVED);
  }
}

internal EphimeraToken._burn keyboard_arrow_up

Parameters help

Name Type
_tokenId
uint256 help

Properties

Visibility help internal
Mutability help transaction

Requirements help

Source Code
function _burn(uint256 _tokenId) internal {
  address owner = owners[_tokenId];
  require(owner != address(0), "ERC721_ZERO_OWNER_ADDRESS");

  owners[_tokenId] = address(0);
  balances[owner] = balances[owner].sub(1);
  totalSupply = totalSupply.sub(1);

  // clear metadata
  if (bytes(tokenURIs[_tokenId]).length != 0) {
    delete tokenURIs[_tokenId];
  }

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

internal ERC165.constructor keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help internal
Mutability help transaction

Requirements help

Source Code
constructor() internal {
  // Derived contracts need only register support for their own interfaces,
  // we register support for ERC165 itself here
  _registerInterface(_INTERFACE_ID_ERC165);
}

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

Parameters help

This function has no parameters.

Properties

Visibility help internal
Mutability help transaction
Source Code
constructor() internal {}

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;
}