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
State Variables (15) keyboard_arrow_up
Functions
supportsInterface keyboard_arrow_up
unrestrictMinting keyboard_arrow_up
restrictMinting keyboard_arrow_up
name keyboard_arrow_up
symbol keyboard_arrow_up
totalSupply keyboard_arrow_up
balanceOf keyboard_arrow_up
Source Code
function balanceOf(address account) public view returns (uint256) {
require(account != address(0));
return tokenCount[account];
}
ownerOf keyboard_arrow_up
Source Code
function ownerOf(uint256 tokenId) public view returns (address) {
address owner = owners[tokenId];
require(owner != address(0));
return owner;
}
tokenOfOwnerByIndex keyboard_arrow_up
Source Code
function tokenOfOwnerByIndex(address owner, uint256 index)
public
view
returns (uint256)
{
require(index < balanceOf(owner));
return ownedTokens[owner][index];
}
tokenByIndex keyboard_arrow_up
Requirements help
Source Code
function tokenByIndex(uint256 index) public view returns (uint256) {
require(index < totalSupply());
return allTokens[index];
}
getApproved keyboard_arrow_up
isApprovedForAll keyboard_arrow_up
tokenURI keyboard_arrow_up
addAdmin keyboard_arrow_up
removeAdmin keyboard_arrow_up
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
approve keyboard_arrow_up
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
Requirements help
Source Code
function setApprovalForAll(address to, bool approved) public {
require(to != msg.sender);
operatorApproval[msg.sender][to] = approved;
emit ApprovalForAll(msg.sender, to, approved);
}
transferFrom keyboard_arrow_up
Requirements help
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
Requirements help
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
Requirements help
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
mintWithTokenURI keyboard_arrow_up
addQr keyboard_arrow_up
Requirements help
null
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
Requirements help
Source Code
function burn(uint256 tokenId) public {
require(msg.sender == ownerOf(tokenId));
_burn(msg.sender, 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 Qri._addAdmin keyboard_arrow_up
internal Qri._exists keyboard_arrow_up
internal Qri._isApprovedOrOwner keyboard_arrow_up
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
Requirements help
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
Requirements help
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
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
Requirements help
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
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
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
internal Qri.concat keyboard_arrow_up
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
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
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
internal ERC165Map._addInterface keyboard_arrow_up
Requirements help
Source Code
function _addInterface(bytes4 interfaceId) internal {
require(interfaceId != 0xffffffff);
supportedInterfaces[interfaceId] = true;
}