Blockwell

Sandbox's LANDs

About

Stats

Public Functions 35
Event Types 7
Code Size 41,415 bytes

AdminChanged Event

Parameters help
oldAdmin
address help
newAdmin
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

MetaTransactionProcessor Event

Parameters help
metaTransactionProcessor
address help
enabled
bool help

Minter Event

Parameters help
superOperator
address help
enabled
bool help

SuperOperator Event

Parameters help
superOperator
address help
enabled
bool help

Transfer Event

Parameters help
_from
address help
_to
address help
_tokenId
uint256 help

Functions Expand All Collapse All

getAdmin keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
    function getAdmin() external view returns (address) {
        return _admin;
    }

changeAdmin keyboard_arrow_up

Parameters help

Name Type
newAdmin
address help

Properties

Visibility help public
Mutability help transaction
Source Code
    function changeAdmin(address newAdmin) external {
        require(msg.sender == _admin, "only admin can change admin");
        emit AdminChanged(_admin, newAdmin);
        _admin = newAdmin;
    }

setMetaTransactionProcessor keyboard_arrow_up

Parameters help

Name Type
metaTransactionProcessor
address help
enabled
bool help

Properties

Visibility help public
Mutability help transaction
Source Code
    function setMetaTransactionProcessor(address metaTransactionProcessor, bool enabled) public {
        require(
            msg.sender == _admin,
            "only admin can setup metaTransactionProcessors"
        );
        _setMetaTransactionProcessor(metaTransactionProcessor, enabled);
    }

isMetaTransactionProcessor keyboard_arrow_up

Parameters help

Name Type
who
address help

Properties

Visibility help public
Mutability help view
Source Code
    function isMetaTransactionProcessor(address who) external view returns(bool) {
        return _metaTransactionContracts[who];
    }

setSuperOperator keyboard_arrow_up

Parameters help

Name Type
superOperator
address help
enabled
bool help

Properties

Visibility help public
Mutability help transaction
Source Code
    function setSuperOperator(address superOperator, bool enabled) external {
        require(
            msg.sender == _admin,
            "only admin is allowed to add super operators"
        );
        _superOperators[superOperator] = enabled;
        emit SuperOperator(superOperator, enabled);
    }

isSuperOperator keyboard_arrow_up

Parameters help

Name Type
who
address help

Properties

Visibility help public
Mutability help view
Source Code
    function isSuperOperator(address who) public view returns (bool) {
        return _superOperators[who];
    }

balanceOf keyboard_arrow_up

Parameters help

Name Type
owner
address help

Properties

Visibility help public
Mutability help view

Requirements help

Source Code
    function balanceOf(address owner) external view returns (uint256) {
        require(owner != address(0), "owner is zero address");
        return _numNFTPerAddress[owner];
    }

ownerOf keyboard_arrow_up

Parameters help

Name Type
id
uint256 help

Properties

Visibility help public
Mutability help view

Requirements help

Source Code
    function ownerOf(uint256 id) external view returns (address owner) {
        owner = _ownerOf(id);
        require(owner != address(0), "token does not exist");
    }

approveFor keyboard_arrow_up

Parameters help

Name Type
sender
address help
operator
address help
id
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
    function approveFor(
        address sender,
        address operator,
        uint256 id
    ) external {
        address owner = _ownerOf(id);
        require(sender != address(0), "sender is zero address");
        require(
            msg.sender == sender ||
            _metaTransactionContracts[msg.sender] ||
            _superOperators[msg.sender] ||
            _operatorsForAll[sender][msg.sender],
            "not authorized to approve"
        );
        require(owner == sender, "owner != sender");
        _approveFor(owner, operator, id);
    }

approve keyboard_arrow_up

Parameters help

Name Type
operator
address help
id
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
    function approve(address operator, uint256 id) external {
        address owner = _ownerOf(id);
        require(owner != address(0), "token does not exist");
        require(
            owner == msg.sender ||
            _superOperators[msg.sender] ||
            _operatorsForAll[owner][msg.sender],
            "not authorized to approve"
        );
        _approveFor(owner, operator, id);
    }

getApproved keyboard_arrow_up

Parameters help

Name Type
id
uint256 help

Properties

Visibility help public
Mutability help view

Requirements help

Source Code
    function getApproved(uint256 id) external view returns (address) {
        (address owner, bool operatorEnabled) = _ownerAndOperatorEnabledOf(id);
        require(owner != address(0), "token does not exist");
        if (operatorEnabled) {
            return _operators[id];
        } else {
            return address(0);
        }
    }

transferFrom keyboard_arrow_up

Parameters help

Name Type
from
address help
to
address help
id
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
    function transferFrom(address from, address to, uint256 id) external {
        bool metaTx = _checkTransfer(from, to, id);
        _transferFrom(from, to, id);
        if (to.isContract() && _checkInterfaceWith10000Gas(to, ERC721_MANDATORY_RECEIVER)) {
            require(
                _checkOnERC721Received(metaTx ? from : msg.sender, from, to, id, ""),
                "erc721 transfer rejected by to"
            );
        }
    }

safeTransferFrom keyboard_arrow_up

Parameters help

Name Type
from
address help
to
address help
id
uint256 help
data
bytes help

Properties

Visibility help public
Mutability help transaction
Source Code
    function safeTransferFrom(address from, address to, uint256 id, bytes memory data) public {
        bool metaTx = _checkTransfer(from, to, id);
        _transferFrom(from, to, id);
        if (to.isContract()) {
            require(
                _checkOnERC721Received(metaTx ? from : msg.sender, from, to, id, data),
                "ERC721: transfer rejected by to"
            );
        }
    }

safeTransferFrom keyboard_arrow_up

Parameters help

Name Type
from
address help
to
address help
id
uint256 help

Properties

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

batchTransferFrom keyboard_arrow_up

Parameters help

Name Type
from
address help
to
address help
ids
uint256[] help
data
bytes help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
    function batchTransferFrom(address from, address to, uint256[] calldata ids, bytes calldata data) external {
        _batchTransferFrom(from, to, ids, data, false);
    }

safeBatchTransferFrom keyboard_arrow_up

Parameters help

Name Type
from
address help
to
address help
ids
uint256[] help
data
bytes help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
    function safeBatchTransferFrom(address from, address to, uint256[] calldata ids, bytes calldata data) external {
        _batchTransferFrom(from, to, ids, data, true);
    }

supportsInterface keyboard_arrow_up

Parameters help

Name Type
id
bytes4 help

Properties

Visibility help public
Mutability help pure
Source Code
    function supportsInterface(bytes4 id) external pure returns (bool) {
        return id == 0x01ffc9a7 || id == 0x80ac58cd || id == 0x5b5e139f;
    }

setApprovalForAllFor keyboard_arrow_up

Parameters help

Name Type
sender
address help
operator
address help
approved
bool help

Properties

Visibility help public
Mutability help transaction
Source Code
    function setApprovalForAllFor(
        address sender,
        address operator,
        bool approved
    ) external {
        require(sender != address(0), "Invalid sender address");
        require(
            msg.sender == sender ||
            _metaTransactionContracts[msg.sender] ||
            _superOperators[msg.sender],
            "not authorized to approve for all"
        );

        _setApprovalForAll(sender, operator, approved);
    }

setApprovalForAll keyboard_arrow_up

Parameters help

Name Type
operator
address help
approved
bool help

Properties

Visibility help public
Mutability help transaction
Source Code
    function setApprovalForAll(address operator, bool approved) external {
        _setApprovalForAll(msg.sender, 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)
        external
        view
        returns (bool isOperator)
    {
        return _operatorsForAll[owner][operator] || _superOperators[operator];
    }

_burn keyboard_arrow_up

Parameters help

Name Type
from
address help
owner
address help
id
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
    function _burn(address from, address owner, uint256 id) public {
        require(from == owner, "not owner");
        _owners[id] = 2**160; // cannot mint it again
        _numNFTPerAddress[from]--;
        emit Transfer(from, address(0), id);
    }

burn keyboard_arrow_up

Parameters help

Name Type
id
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
    function burn(uint256 id) external {
        _burn(msg.sender, _ownerOf(id), id);
    }

burnFrom keyboard_arrow_up

Parameters help

Name Type
from
address help
id
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
    function burnFrom(address from, uint256 id) external {
        require(from != address(0), "Invalid sender address");
        (address owner, bool operatorEnabled) = _ownerAndOperatorEnabledOf(id);
        require(
            msg.sender == from ||
            _metaTransactionContracts[msg.sender] ||
            (operatorEnabled && _operators[id] == msg.sender) ||
            _superOperators[msg.sender] ||
            _operatorsForAll[from][msg.sender],
            "not authorized to burn"
        );
        _burn(from, owner, id);
    }

setMinter keyboard_arrow_up

Parameters help

Name Type
minter
address help
enabled
bool help

Properties

Visibility help public
Mutability help transaction
Source Code
    function setMinter(address minter, bool enabled) external {
        require(
            msg.sender == _admin,
            "only admin is allowed to add minters"
        );
        _minters[minter] = enabled;
        emit Minter(minter, enabled);
    }

isMinter keyboard_arrow_up

Parameters help

Name Type
who
address help

Properties

Visibility help public
Mutability help view
Source Code
    function isMinter(address who) public view returns (bool) {
        return _minters[who];
    }

width keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help transaction
Source Code
    function width() external returns(uint256) {
        return GRID_SIZE;
    }

height keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help transaction
Source Code
    function height() external returns(uint256) {
        return GRID_SIZE;
    }

x keyboard_arrow_up

Parameters help

Name Type
id
uint256 help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
    function x(uint256 id) external returns(uint256) {
        require(_ownerOf(id) != address(0), "token does not exist");
        return id % GRID_SIZE;
    }

y keyboard_arrow_up

Parameters help

Name Type
id
uint256 help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
    function y(uint256 id) external returns(uint256) {
        require(_ownerOf(id) != address(0), "token does not exist");
        return id / GRID_SIZE;
    }

mintQuad keyboard_arrow_up

Parameters help

Name Type
to
address help
size
uint256 help
x
uint256 help
y
uint256 help
data
bytes help

Properties

Visibility help public
Mutability help transaction

Requirements help

null
UNKNOWN VALUE must be equal to 0
UNKNOWN VALUE must be equal to 0
Source Code
    function mintQuad(address to, uint256 size, uint256 x, uint256 y, bytes calldata data) external {
        require(to != address(0), "to is zero address");
        require(
            isMinter(msg.sender),
            "Only a minter can mint"
        );
        require(x % size == 0 && y % size == 0, "Invalid coordinates");
        require(x <= GRID_SIZE - size && y <= GRID_SIZE - size, "Out of bounds");

        uint256 quadId;
        uint256 id = x + y * GRID_SIZE;

        if (size == 1) {
            quadId = id;
        } else if (size == 3) {
            quadId = LAYER_3x3 + id;
        } else if (size == 6) {
            quadId = LAYER_6x6 + id;
        } else if (size == 12) {
            quadId = LAYER_12x12 + id;
        } else if (size == 24) {
            quadId = LAYER_24x24 + id;
        } else {
            require(false, "Invalid size");
        }

        require(_owners[LAYER_24x24 + (x/24) * 24 + ((y/24) * 24) * GRID_SIZE] == 0, "Already minted as 24x24");

        uint256 toX = x+size;
        uint256 toY = y+size;
        if (size <= 12) {
            require(
                _owners[LAYER_12x12 + (x/12) * 12 + ((y/12) * 12) * GRID_SIZE] == 0,
                "Already minted as 12x12"
            );
        } else {
            for (uint256 x12i = x; x12i < toX; x12i += 12) {
                for (uint256 y12i = y; y12i < toY; y12i += 12) {
                    uint256 id12x12 = LAYER_12x12 + x12i + y12i * GRID_SIZE;
                    require(_owners[id12x12] == 0, "Already minted as 12x12");
                }
            }
        }

        if (size <= 6) {
            require(_owners[LAYER_6x6 + (x/6) * 6 + ((y/6) * 6) * GRID_SIZE] == 0, "Already minted as 6x6");
        } else {
            for (uint256 x6i = x; x6i < toX; x6i += 6) {
                for (uint256 y6i = y; y6i < toY; y6i += 6) {
                    uint256 id6x6 = LAYER_6x6 + x6i + y6i * GRID_SIZE;
                    require(_owners[id6x6] == 0, "Already minted as 6x6");
                }
            }
        }

        if (size <= 3) {
            require(_owners[LAYER_3x3 + (x/3) * 3 + ((y/3) * 3) * GRID_SIZE] == 0, "Already minted as 3x3");
        } else {
            for (uint256 x3i = x; x3i < toX; x3i += 3) {
                for (uint256 y3i = y; y3i < toY; y3i += 3) {
                    uint256 id3x3 = LAYER_3x3 + x3i + y3i * GRID_SIZE;
                    require(_owners[id3x3] == 0, "Already minted as 3x3");
                }
            }
        }

        for (uint256 i = 0; i < size*size; i++) {
            uint256 id = _idInPath(i, size, x, y);
            require(_owners[id] == 0, "Already minted");
            emit Transfer(address(0), to, id);
        }

        _owners[quadId] = uint256(to);
        _numNFTPerAddress[to] += size * size;

        _checkBatchReceiverAcceptQuad(msg.sender, address(0), to, size, x, y, data);
    }

transferQuad keyboard_arrow_up

Parameters help

Name Type
from
address help
to
address help
size
uint256 help
x
uint256 help
y
uint256 help
data
bytes help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
    function transferQuad(address from, address to, uint256 size, uint256 x, uint256 y, bytes calldata data) external {
        require(from != address(0), "from is zero address");
        require(to != address(0), "can't send to zero address");
        bool metaTx = msg.sender != from && _metaTransactionContracts[msg.sender];
        if (msg.sender != from && !metaTx) {
            require(
                _superOperators[msg.sender] ||
                _operatorsForAll[from][msg.sender],
                "not authorized to transferQuad"
            );
        }
        _transferQuad(from, to, size, x, y);
        _numNFTPerAddress[from] -= size * size;
        _numNFTPerAddress[to] += size * size;

        _checkBatchReceiverAcceptQuad(metaTx ? from : msg.sender, from, to, size, x, y, data);
    }

batchTransferQuad keyboard_arrow_up

Parameters help

Name Type
from
address help
to
address help
sizes
uint256[] help
xs
uint256[] help
ys
uint256[] help
data
bytes help

Properties

Visibility help public
Mutability help transaction
Source Code
    function batchTransferQuad(
        address from,
        address to,
        uint256[] calldata sizes,
        uint256[] calldata xs,
        uint256[] calldata ys,
        bytes calldata data
    ) external {
        require(from != address(0), "from is zero address");
        require(to != address(0), "can't send to zero address");
        require(sizes.length == xs.length && xs.length == ys.length, "invalid data");
        bool metaTx = msg.sender != from && _metaTransactionContracts[msg.sender];
        if (msg.sender != from && !metaTx) {
            require(
                _superOperators[msg.sender] ||
                _operatorsForAll[from][msg.sender],
                "not authorized to transferMultiQuads"
            );
        }
        uint256 numTokensTransfered = 0;
        for (uint256 i = 0; i < sizes.length; i++) {
            uint256 size = sizes[i];
            _transferQuad(from, to, size, xs[i], ys[i]);
            numTokensTransfered += size * size;
        }
        _numNFTPerAddress[from] -= numTokensTransfered;
        _numNFTPerAddress[to] += numTokensTransfered;

        if (to.isContract() && _checkInterfaceWith10000Gas(to, ERC721_MANDATORY_RECEIVER)) {
            uint256[] memory ids = new uint256[](numTokensTransfered);
            uint256 counter = 0;
            for (uint256 j = 0; j < sizes.length; j++) {
                uint256 size = sizes[j];
                for (uint256 i = 0; i < size*size; i++) {
                    ids[counter] = _idInPath(i, size, xs[j], ys[j]);
                    counter++;
                }
            }
            require(
                _checkOnERC721BatchReceived(metaTx ? from : msg.sender, from, to, ids, data),
                "erc721 batch transfer rejected by to"
            );
        }
    }

name keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help pure
Source Code
    function name() external pure returns (string memory) {
        return "Sandbox's LANDs";
    }

symbol keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help pure
Source Code
    function symbol() external pure returns (string memory) {
        return "LAND";
    }

tokenURI keyboard_arrow_up

Parameters help

Name Type
id
uint256 help

Properties

Visibility help public
Mutability help view

Requirements help

Source Code
    function tokenURI(uint256 id) public view returns (string memory) {
        require(_ownerOf(id) != address(0), "Id does not exist");
        return
            string(
                abi.encodePacked(
                    "https://api.sandbox.game/lands/",
                    uint2str(id),
                    "/metadata.json"
                )
            );
    }