Blockwell

Blockwell-QR Index

About

Stats

Public Functions 25
Event Types 5
Code Size 24,115 bytes

Library Use

Uses Groups for Groups.GroupMap.
Uses SafeMath for uint256.

Events (5) keyboard_arrow_up

AddedToGroup Event

Parameters help
groupId
uint8 help
account
address help

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

RemovedFromGroup Event

Parameters help
groupId
uint8 help
account
address help

Transfer Event

Parameters help
_from
address help
_to
address help
_tokenId
uint256 help

ADMIN Constant

uint8 help
1

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

unrestrictedMinting Variable

bool help

tokenOwner Variable

address help

tokenName Variable

string help
Internal Variable

tokenSymbol Variable

string help
Internal Variable

groups Variable

Groups.GroupMap help
Internal Variable

allTokens Variable

uint256[] help
Internal Variable

tokenIndex Variable

mapping(uint256 => uint256) help
Internal Variable

owners Variable

mapping(uint256 => address) help
Internal Variable

ownedTokens Variable

mapping(address => uint256[]) help
Internal Variable

ownedTokensIndex Variable

mapping(uint256 => uint256) help
Internal Variable

approval Variable

mapping(uint256 => address) help
Internal Variable

tokenCount Variable

mapping(address => uint256) help
Internal Variable

operatorApproval Variable

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

uri 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 returns (bool) {
  return supportedInterfaces[interfaceId];
}

unrestrictMinting keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help transaction

Modifiers help

onlyAdmin checks for the following:
null
Source Code
function unrestrictMinting() public onlyAdmin {
  unrestrictedMinting = true;
}

restrictMinting keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help transaction

Modifiers help

onlyAdmin checks for the following:
null
Source Code
function restrictMinting() public onlyAdmin {
  unrestrictedMinting = false;
}

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
function name() external view returns (string) {
  return tokenName;
}

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
function symbol() external view returns (string) {
  return tokenSymbol;
}

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
function totalSupply() public view returns (uint256) {
  return allTokens.length;
}

Parameters help

Name Type
account
address help

Properties

Visibility help public
Mutability help view

Requirements help

Source Code
function balanceOf(address account) public view returns (uint256) {
  require(account != address(0));
  return tokenCount[account];
}

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 returns (address) {
  address owner = owners[tokenId];
  require(owner != address(0));
  return owner;
}

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
  returns (uint256)
{
  require(index < balanceOf(owner));
  return ownedTokens[owner][index];
}

tokenByIndex keyboard_arrow_up

Parameters help

Name Type
index
uint256 help

Properties

Visibility help public
Mutability help view

Requirements help

Source Code
function tokenByIndex(uint256 index) public view returns (uint256) {
  require(index < totalSupply());
  return allTokens[index];
}

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 returns (address) {
  require(_exists(tokenId));
  return approval[tokenId];
}

isApprovedForAll keyboard_arrow_up

Parameters help

Name Type
account
address help
operator
address help

Properties

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

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) external view returns (string) {
  require(_exists(tokenId));
  return uri[tokenId];
}

addAdmin keyboard_arrow_up

Parameters help

Name Type
account
address help

Properties

Visibility help public
Mutability help transaction

Modifiers help

onlyAdmin checks for the following:
null
Source Code
function addAdmin(address account) public onlyAdmin {
  _addAdmin(account);
}

removeAdmin keyboard_arrow_up

Parameters help

Name Type
account
address help

Properties

Visibility help public
Mutability help transaction

Modifiers help

onlyAdmin checks for the following:
null
Source Code
function removeAdmin(address account) public onlyAdmin {
  groups.remove(ADMIN, account);
  emit RemovedFromGroup(ADMIN, account);
}

isAdmin keyboard_arrow_up

Parameters help

Name Type
account
address help

Properties

Visibility help public
Mutability help view
Source Code
function isAdmin(address account) public view returns (bool) {
  return groups.contains(ADMIN, account);
}

Parameters help

Name Type
account
address help
tokenId
uint256 help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function approve(address account, uint256 tokenId) public {
  address owner = ownerOf(tokenId);

  require(msg.sender == owner || isApprovedForAll(owner, msg.sender));

  approval[tokenId] = account;
  emit Approval(owner, account, tokenId);
}

setApprovalForAll keyboard_arrow_up

Parameters help

Name Type
to
address help
approved
bool help

Properties

Visibility help public
Mutability help transaction
Source Code
function setApprovalForAll(address to, bool approved) public {
  require(to != msg.sender);
  operatorApproval[msg.sender][to] = approved;
  emit ApprovalForAll(msg.sender, to, approved);
}

Parameters help

Name Type
from
address help
to
address help
tokenId
uint256 help

Properties

Visibility help public
Mutability help transaction

Requirements help

null
Source Code
function transferFrom(
  address from,
  address to,
  uint256 tokenId
) public {
  require(_isApprovedOrOwner(msg.sender, tokenId));
  require(to != address(0));

  _clearApproval(from, tokenId);
  _removeTokenFrom(from, tokenId);
  _addTokenTo(to, tokenId);

  emit 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 payable

Requirements help

null
null
Source Code
function safeTransferFrom(
  address from,
  address to,
  uint256 tokenId
) external payable {
  transferFrom(from, to, tokenId);
  require(_checkOnERC721Received(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 payable

Requirements help

null
null
Source Code
function safeTransferFrom(
  address from,
  address to,
  uint256 tokenId,
  bytes data
) external payable {
  transferFrom(from, to, tokenId);
  require(_checkOnERC721Received(from, to, tokenId, data));
}

mint keyboard_arrow_up

Parameters help

Name Type
to
address help
tokenId
uint256 help

Properties

Visibility help public
Mutability help transaction

Modifiers help

onlyAdmin checks for the following:
null
Source Code
function mint(address to, uint256 tokenId) public onlyAdmin returns (bool) {
  _mint(to, tokenId);
  return true;
}

mintWithTokenURI keyboard_arrow_up

Parameters help

Name Type
to
address help
tokenId
uint256 help
URIForToken
string help

Properties

Visibility help public
Mutability help transaction

Modifiers help

onlyAdmin checks for the following:
null
Source Code
function mintWithTokenURI(
  address to,
  uint256 tokenId,
  string URIForToken
) public onlyAdmin returns (bool) {
  _mint(to, tokenId);
  _setTokenURI(tokenId, URIForToken);
  return true;
}

addQr keyboard_arrow_up

Parameters help

Name Type
tokenId
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
function addQr(uint256 tokenId) public returns (bool) {
  if (!unrestrictedMinting) {
    require(isAdmin(msg.sender), "Must be an admin");
  }
  _mint(tokenOwner, tokenId);
  _setTokenURI(
    tokenId,
    concat("https://qr.blockwell.ai/qri/", uint2str(tokenId))
  );
  return true;
}

burn keyboard_arrow_up

Parameters help

Name Type
tokenId
uint256 help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function burn(uint256 tokenId) public {
  require(msg.sender == ownerOf(tokenId));
  _burn(msg.sender, tokenId);
}

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 Qri._addAdmin keyboard_arrow_up

Parameters help

Name Type
account
address help

Properties

Visibility help internal
Mutability help transaction
Source Code
function _addAdmin(address account) internal {
  groups.add(ADMIN, account);
  emit AddedToGroup(ADMIN, account);
}

internal Qri._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 owners[tokenId] != address(0);
}

internal Qri._isApprovedOrOwner keyboard_arrow_up

Parameters help

Name Type
spender
address help
tokenId
uint256 help

Properties

Visibility help internal
Mutability help view
Source Code
function _isApprovedOrOwner(address spender, uint256 tokenId)
  internal
  view
  returns (bool)
{
  address owner = ownerOf(tokenId);
  return (spender == owner ||
    getApproved(tokenId) == spender ||
    isApprovedForAll(owner, spender));
}

internal Qri._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 {
  require(to != address(0));
  _addTokenTo(to, tokenId);

  tokenIndex[tokenId] = allTokens.length;
  allTokens.push(tokenId);

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

internal Qri._burn keyboard_arrow_up

Parameters help

Name Type
account
address help
tokenId
uint256 help

Properties

Visibility help internal
Mutability help transaction
Source Code
function _burn(address account, uint256 tokenId) internal {
  _clearApproval(account, tokenId);
  _removeTokenFrom(account, tokenId);

  if (bytes(uri[tokenId]).length != 0) {
    delete uri[tokenId];
  }

  // Delete from array by moving the last element to the deleted position
  uint256 index = tokenIndex[tokenId];
  uint256 lastTokenIndex = allTokens.length.sub(1);
  uint256 lastToken = allTokens[lastTokenIndex];

  allTokens[index] = lastToken;
  allTokens[lastTokenIndex] = 0;

  allTokens.length--;
  tokenIndex[tokenId] = 0;
  tokenIndex[lastToken] = index;

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

internal Qri._addTokenTo keyboard_arrow_up

Parameters help

Name Type
to
address help
tokenId
uint256 help

Properties

Visibility help internal
Mutability help transaction
Source Code
function _addTokenTo(address to, uint256 tokenId) internal {
  require(owners[tokenId] == address(0));
  owners[tokenId] = to;
  tokenCount[to] = tokenCount[to].add(1);

  ownedTokens[to].push(tokenId);
  ownedTokensIndex[tokenId] = ownedTokens[to].length - 1;
}

internal Qri._removeTokenFrom keyboard_arrow_up

Parameters help

Name Type
from
address help
tokenId
uint256 help

Properties

Visibility help internal
Mutability help transaction
Source Code
function _removeTokenFrom(address from, uint256 tokenId) internal {
  require(ownerOf(tokenId) == from);
  tokenCount[from] = tokenCount[from].sub(1);
  owners[tokenId] = address(0);

  // Delete from array by moving the last element to the deleted position
  uint256 index = ownedTokensIndex[tokenId];
  uint256 lastTokenIndex = ownedTokens[from].length.sub(1);
  uint256 lastToken = ownedTokens[from][lastTokenIndex];

  ownedTokens[from][index] = lastToken;
  ownedTokens[from].length--;

  ownedTokensIndex[tokenId] = 0;
  ownedTokensIndex[lastToken] = index;
}

internal Qri._checkOnERC721Received 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
Source Code
function _checkOnERC721Received(
  address from,
  address to,
  uint256 tokenId,
  bytes data
) internal returns (bool) {
  if (!isContract(to)) {
    return true;
  }
  ERC721TokenReceiver receiver = ERC721TokenReceiver(to);
  bytes4 retval = receiver.onERC721Received(msg.sender, from, tokenId, data);
  return (retval == receiver.onERC721Received.selector);
}

internal Qri._clearApproval keyboard_arrow_up

Parameters help

Name Type
account
address help
tokenId
uint256 help

Properties

Visibility help private
Mutability help transaction
Source Code
function _clearApproval(address account, uint256 tokenId) private {
  require(ownerOf(tokenId) == account);
  if (approval[tokenId] != address(0)) {
    approval[tokenId] = address(0);
  }
}

internal Qri._setTokenURI keyboard_arrow_up

Parameters help

Name Type
tokenId
uint256 help
newURI
string help

Properties

Visibility help internal
Mutability help transaction

Requirements help

null
Source Code
function _setTokenURI(uint256 tokenId, string newURI) internal {
  require(_exists(tokenId));
  uri[tokenId] = newURI;
}

internal Qri.concat keyboard_arrow_up

Parameters help

Name Type
a
string help
b
string help

Properties

Visibility help internal
Mutability help pure
Source Code
function concat(string memory a, string memory b)
  internal
  pure
  returns (string memory)
{
  uint256 aLength = bytes(a).length;
  uint256 bLength = bytes(b).length;
  string memory value = new string(aLength + bLength);
  uint256 valuePointer;
  uint256 aPointer;
  uint256 bPointer;
  assembly {
    valuePointer := add(value, 32)
    aPointer := add(a, 32)
    bPointer := add(b, 32)
  }
  copy(aPointer, valuePointer, aLength);
  copy(bPointer, valuePointer + aLength, bLength);
  return value;
}

internal Qri.uint2str keyboard_arrow_up

Parameters help

Name Type
i
uint help

Properties

Visibility help internal
Mutability help pure
Source Code
function uint2str(uint256 i) internal pure returns (string) {
  if (i == 0) return "0";
  uint256 j = i;
  uint256 length;
  while (j != 0) {
    length++;
    j /= 10;
  }
  bytes memory bstr = new bytes(length);
  uint256 k = length - 1;
  while (i != 0) {
    bstr[k--] = byte(48 + (i % 10));
    i /= 10;
  }
  return string(bstr);
}

internal Qri.copy keyboard_arrow_up

Parameters help

Name Type
src
uint help
dest
uint help
len
uint help

Properties

Visibility help internal
Mutability help pure
Source Code
function copy(
  uint256 src,
  uint256 dest,
  uint256 len
) internal pure {
  // Copy word-length chunks while possible
  for (; len >= 32; len -= 32) {
    assembly {
      mstore(dest, mload(src))
    }
    dest += 32;
    src += 32;
  }

  // Copy remaining bytes
  uint256 mask = 256**(32 - len) - 1;
  assembly {
    let srcpart := and(mload(src), not(mask))
    let destpart := and(mload(dest), mask)
    mstore(dest, or(destpart, srcpart))
  }
}

internal Qri.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) {
  uint256 size;
  assembly {
    size := extcodesize(account)
  }
  return size > 0;
}

internal ERC165Map._addInterface keyboard_arrow_up

Parameters help

Name Type
interfaceId
bytes4 help

Properties

Visibility help internal
Mutability help transaction

Requirements help

Source Code
function _addInterface(bytes4 interfaceId) internal {
  require(interfaceId != 0xffffffff);
  supportedInterfaces[interfaceId] = true;
}