Blockwell

Gods Unchained Cards

About

Stats

Public Functions 52
Event Types 10
Code Size 79,916 bytes

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

CardsMinted Event

Parameters help
start
uint256 help
to
address help
protos
uint16[] help
qualities
uint8[] help

ClassPropertySet Event

Parameters help
key
bytes32 help
value
bytes32 help

OwnershipTransferred Event

Parameters help
previousOwner
address help
newOwner
address help

ProtoUpdated Event

Parameters help
id
uint16 help

QualityChanged Event

Parameters help
tokenId
uint256 help
quality
uint8 help
factory
address help

SeasonStarted Event

Parameters help
id
uint16 help
name
string help
low
uint16 help
high
uint16 help

TokenPropertySet Event

Parameters help
id
uint help
key
bytes32 help
value
bytes32 help

Transfer Event

Parameters help
from
address help
to
address help
tokenId
uint256 help

Functions Expand All Collapse All

getProperty keyboard_arrow_up

Parameters help

Name Type
_id
uint help
_key
bytes32 help

Properties

Visibility help public
Mutability help view
Source Code
    function getProperty(
        uint _id,
        bytes32 _key
    )
        public
        view
        returns (bytes32 _value)
    {
        return properties[getTokenKey(_id, _key)];
    }

getTokenKey keyboard_arrow_up

Parameters help

Name Type
_tokenId
uint help
_key
bytes32 help

Properties

Visibility help public
Mutability help pure
Source Code
    function getTokenKey(
        uint _tokenId,
        bytes32 _key
    )
        public
        pure
        returns (bytes32)
    {
        // one prefix to prevent collisions
        return keccak256(abi.encodePacked(uint(1), _tokenId, _key));
    }

getClassKey keyboard_arrow_up

Parameters help

Name Type
_key
bytes32 help

Properties

Visibility help public
Mutability help pure
Source Code
    function getClassKey(bytes32 _key)
        public
        pure
        returns (bytes32)
    {
        // zero prefix to prevent collisions
        return keccak256(abi.encodePacked(uint(0), _key));
    }

getClassProperty keyboard_arrow_up

Parameters help

Name Type
_key
bytes32 help

Properties

Visibility help public
Mutability help view
Source Code
    function getClassProperty(bytes32 _key)
        public
        view
        returns (bytes32)
    {
        return properties[getClassKey(_key)];
    }

balanceOf keyboard_arrow_up

Parameters help

Name Type
_owner
address help

Properties

Visibility help public
Mutability help view
Source Code
    function balanceOf(address _owner)
        public
        view
        returns (uint256)
    {
        return _balances[_owner];
    }

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
        returns (address)
    {
        uint48 uID = ownerIDs[tokenId];
        if (uID == 0) {
            uint256 start = getBatchStart(tokenId);
            Batch memory b = batches[start];

            require(
                start + b.size > tokenId,
                "BT: token does not exist"
            );

            uID = b.userID;
            require(
                uID != 0,
                "BT: bad batch owner"
            );
        }
        return userIDToAddress[uID];
    }

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 {
        safeTransferFrom(from, to, tokenId, "");
    }

transferFrom 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 transferFrom(address from, address to, uint256 tokenId) public {
        //solhint-disable-next-line max-line-length
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");

        _transferFrom(from, to, tokenId);
    }

approve keyboard_arrow_up

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 {
        address owner = ownerOf(tokenId);

        require(
            to != owner,
            "BT: approval to current owner"
        );

        require(
            msg.sender == owner || isApprovedForAll(owner, msg.sender),
            "BT: approve caller is not owner nor approved for all"
        );

        approvedIDs[tokenId] = _getUserID(to);
        emit Approval(owner, 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
        returns (address)
    {
        require(
            _exists(tokenId),
            "BT: approved query for nonexistent token"
        );

        return userIDToAddress[approvedIDs[tokenId]];
    }

setApprovalForAll keyboard_arrow_up

Parameters help

Name Type
to
address help
approved
bool help

Properties

Visibility help public
Mutability help transaction

Requirements help

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

        _operatorApprovals[_msgSender()][to] = approved;
        emit ApprovalForAll(_msgSender(), to, 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 returns (bool) {
        return _operatorApprovals[owner][operator];
    }

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 {
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
        _safeTransferFrom(from, to, tokenId, _data);
    }

name keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

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

symbol keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

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

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 string(abi.encodePacked(
            baseURI,
            String.fromAddress(address(this)),
            "/",
            String.fromUint(tokenId)
        ));
    }

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

getBatchStart keyboard_arrow_up

Parameters help

Name Type
tokenId
uint256 help

Properties

Visibility help public
Mutability help view
Source Code
    function getBatchStart(uint256 tokenId) public view returns (uint) {
        return tokenId.div(batchSize).mul(batchSize);
    }

getBatch keyboard_arrow_up

Parameters help

Name Type
index
uint256 help

Properties

Visibility help public
Mutability help view
Source Code
    function getBatch(uint256 index) public view returns (uint48 userID, uint16 size) {
        return (batches[index].userID, batches[index].size);
    }

totalSupply keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
    function totalSupply()
        public
        view
        returns (uint)
    {
        return tokenCount;
    }

transferBatch keyboard_arrow_up

Parameters help

Name Type
from
address help
to
address help
start
uint256 help
end
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
    function transferBatch(
        address from,
        address to,
        uint256 start,
        uint256 end
    )
        public
    {
        for (uint i = start; i < end; i++) {
            transferFrom(from, to, i);
        }
    }

transferAllFrom keyboard_arrow_up

Parameters help

Name Type
from
address help
to
address help
tokenIDs
uint256[] help

Properties

Visibility help public
Mutability help transaction
Source Code
    function transferAllFrom(
        address from,
        address to,
        uint256[] memory tokenIDs
    )
        public
    {
        for (uint i = 0; i < tokenIDs.length; i++) {
            transferFrom(from, to, tokenIDs[i]);
        }
    }

safeTransferBatch keyboard_arrow_up

Parameters help

Name Type
from
address help
to
address help
start
uint256 help
end
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
    function safeTransferBatch(
        address from,
        address to,
        uint256 start,
        uint256 end
    )
        public
    {
        for (uint i = start; i < end; i++) {
            safeTransferFrom(from, to, i);
        }
    }

safeTransferAllFrom keyboard_arrow_up

Parameters help

Name Type
from
address help
to
address help
tokenIDs
uint256[] help

Properties

Visibility help public
Mutability help transaction
Source Code
    function safeTransferAllFrom(
        address from,
        address to,
        uint256[] memory tokenIDs
    )
        public
    {
        for (uint i = 0; i < tokenIDs.length; i++) {
            safeTransferFrom(from, to, tokenIDs[i]);
        }
    }

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

isOwner keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
    function isOwner() public view returns (bool) {
        return _msgSender() == _owner;
    }

renounceOwnership keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help transaction

Modifiers help

onlyOwner checks for the following:
null
Source Code
    function renounceOwnership() public 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

onlyOwner checks for the following:
null

Requirements help

Source Code
    function transferOwnership(address newOwner) public onlyOwner {
        _transferOwnership(newOwner);
    }

getDetails keyboard_arrow_up

Parameters help

Name Type
tokenId
uint256 help

Properties

Visibility help public
Mutability help view
Source Code
    function getDetails(uint256 tokenId) public view returns (uint16 proto, uint8 quality) {
        return isOld(tokenId) ? old.getDetails(tokenId) : (cardProtos[tokenId], cardQualities[tokenId]);
    }

mintCard keyboard_arrow_up

Parameters help

Name Type
_to
address help
_proto
uint16 help
_quality
uint8 help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
    function mintCard(address _to, uint16 _proto, uint8 _quality) public returns (uint id) {
        require(!migrating, "must not be migrating");
        super.mintCard(_to, _proto, _quality);
    }

mintCards keyboard_arrow_up

Parameters help

Name Type
_to
address help
_protos
uint16[] help
_qualities
uint8[] help

Properties

Visibility help public
Mutability help transaction
Source Code
    function mintCards(address _to, uint16[] memory _protos, uint8[] memory _qualities) public returns (uint id) {
        require(!migrating, "must not be migrating");
        super.mintCards(_to, _protos, _qualities);
    }

addFactory keyboard_arrow_up

Parameters help

Name Type
_factory
address help
_season
uint256 help

Properties

Visibility help public
Mutability help transaction

Modifiers help

onlyOwner checks for the following:
null
Source Code
    function addFactory(
        address _factory,
        uint256 _season
    )
        public
        onlyOwner
    {
        require(
            seasons.length >= _season,
            "Core: season must exist"
        );

        require(
            _season > 0,
            "Core: season must not be 0"
        );

        require(
            !factoryApproved[_factory][_season],
            "Core: this factory is already approved"
        );

        require(
            !seasonTradable[_season],
            "Core: season must not be tradable"
        );

        factoryApproved[_factory][_season] = true;
    }

approveForMythic keyboard_arrow_up

Parameters help

Name Type
_factory
address help
_mythic
uint16 help

Properties

Visibility help public
Mutability help transaction

Modifiers help

onlyOwner checks for the following:
null
Source Code
    function approveForMythic(
        address _factory,
        uint16 _mythic
    )
        public
        onlyOwner
    {
        require(
            _mythic >= MYTHIC_THRESHOLD,
            "not a mythic"
        );

        require(
            !mythicApproved[_mythic][_factory],
            "Core: this factory is already approved for this mythic"
        );

        mythicApproved[_mythic][_factory] = true;
    }

makeMythicTradable keyboard_arrow_up

Parameters help

Name Type
_mythic
uint16 help

Properties

Visibility help public
Mutability help transaction

Modifiers help

onlyOwner checks for the following:
null
Source Code
    function makeMythicTradable(
        uint16 _mythic
    )
        public
        onlyOwner
    {
        require(
            _mythic >= MYTHIC_THRESHOLD,
            "Core: not a mythic"
        );

        require(
            !mythicTradable[_mythic],
            "Core: must not be tradable already"
        );

        mythicTradable[_mythic] = true;
    }

unlockTrading keyboard_arrow_up

Parameters help

Name Type
_season
uint256 help

Properties

Visibility help public
Mutability help transaction

Modifiers help

onlyOwner checks for the following:
null
Source Code
    function unlockTrading(
        uint256 _season
    )
        public
        onlyOwner
    {
        require(
            _season > 0 && _season <= seasons.length,
            "Core: must be a current season"
        );

        require(
            !seasonTradable[_season],
            "Core: season must not be tradable"
        );

        seasonTradable[_season] = true;
    }

burn keyboard_arrow_up

Parameters help

Name Type
_tokenId
uint256 help

Properties

Visibility help public
Mutability help transaction

Requirements help

null
null
Source Code
    function burn(uint256 _tokenId) public {
        require(
            isTradable(_tokenId),
            "Core: not yet tradable"
        );

        super._burn(_tokenId);
    }

burnAll keyboard_arrow_up

Parameters help

Name Type
tokenIDs
uint256[] help

Properties

Visibility help public
Mutability help transaction
Source Code
    function burnAll(uint256[] memory tokenIDs) public {
        for (uint256 i = 0; i < tokenIDs.length; i++) {
            burn(tokenIDs[i]);
        }
    }

isTradable keyboard_arrow_up

Parameters help

Name Type
_tokenId
uint256 help

Properties

Visibility help public
Mutability help view
Source Code
    function isTradable(uint256 _tokenId) public view returns (bool) {
        uint16 proto = getProto(_tokenId);
        if (proto >= MYTHIC_THRESHOLD) {
            return mythicTradable[proto];
        }
        return seasonTradable[protoToSeason[proto]];
    }

startSeason keyboard_arrow_up

Parameters help

Name Type
name
string help
low
uint16 help
high
uint16 help

Properties

Visibility help public
Mutability help transaction

Modifiers help

onlyOwner checks for the following:
null
Source Code
    function startSeason(
        string memory name,
        uint16 low,
        uint16 high
    )
        public
        onlyOwner
        returns (uint)
    {
        require(
            low > 0,
            "Core: must not be zero proto"
        );

        require(
            high > low,
            "Core: must be a valid range"
        );

        require(
            seasons.length == 0 || low > seasons[seasons.length - 1].high,
            "Core: seasons cannot overlap"
        );

        require(
            MYTHIC_THRESHOLD > high,
            "Core: cannot go into mythic territory"
        );

        // seasons start at 1
        uint16 id = uint16(seasons.push(Season({ high: high, low: low })));

        uint256 cp;
        assembly { cp := protoToSeason_slot }
        StorageWrite.repeatUint16(cp, low, (high - low) + 1, id);

        emit SeasonStarted(id, name, low, high);

        return id;
    }

updateProtos keyboard_arrow_up

Parameters help

Name Type
_ids
uint16[] help
_gods
uint8[] help
_cardTypes
uint8[] help
_rarities
uint8[] help
_manas
uint8[] help
_attacks
uint8[] help
_healths
uint8[] help
_tribes
uint8[] help

Properties

Visibility help public
Mutability help transaction

Modifiers help

onlyOwner checks for the following:
null
Source Code
    function updateProtos(
        uint16[] memory _ids,
        uint8[] memory _gods,
        uint8[] memory _cardTypes,
        uint8[] memory _rarities,
        uint8[] memory _manas,
        uint8[] memory _attacks,
        uint8[] memory _healths,
        uint8[] memory _tribes
    ) public onlyOwner {
        for (uint256 i = 0; i < _ids.length; i++) {
            uint16 id = _ids[i];

            require(
                id > 0,
                "Core: proto must not be zero"
            );

            Proto memory proto = protos[id];
            require(
                !proto.locked,
                "Core: proto is locked"
            );

            protos[id] = Proto({
                locked: false,
                exists: true,
                god: _gods[i],
                cardType: _cardTypes[i],
                rarity: _rarities[i],
                mana: _manas[i],
                attack: _attacks[i],
                health: _healths[i],
                tribe: _tribes[i]
            });
            emit ProtoUpdated(id);
        }
    }

lockProtos keyboard_arrow_up

Parameters help

Name Type
_ids
uint16[] help

Properties

Visibility help public
Mutability help transaction

Modifiers help

onlyOwner checks for the following:
null

Requirements help

Source Code
    function lockProtos(uint16[] memory _ids) public onlyOwner {
        require(
            _ids.length > 0,
            "must lock some"
        );

        for (uint256 i = 0; i < _ids.length; i++) {
            uint16 id = _ids[i];
            require(
                id > 0,
                "proto must not be zero"
            );

            Proto storage proto = protos[id];

            require(
                !proto.locked,
                "proto is locked"
            );

            require(
                proto.exists,
                "proto must exist"
            );

            proto.locked = true;
            emit ProtoUpdated(id);
        }
    }

setQuality keyboard_arrow_up

Parameters help

Name Type
_tokenId
uint256 help
_quality
uint8 help

Properties

Visibility help public
Mutability help transaction
Source Code
    function setQuality(
        uint256 _tokenId,
        uint8 _quality
    )
        public
    {
        uint16 proto = cardProtos[_tokenId];
        // wont' be able to change mythic season
        uint256 season = protoToSeason[proto];

        require(
            factoryApproved[msg.sender][season],
            "Core: factory can't change quality of this season"
        );

        cardQualities[_tokenId] = _quality;
        emit QualityChanged(_tokenId, _quality, msg.sender);
    }

setPropertyManager keyboard_arrow_up

Parameters help

Name Type
_manager
address help

Properties

Visibility help public
Mutability help transaction

Modifiers help

onlyOwner checks for the following:
null
Source Code
    function setPropertyManager(address _manager) public onlyOwner {
        propertyManager = _manager;
    }

setProperty keyboard_arrow_up

Parameters help

Name Type
_id
uint256 help
_key
bytes32 help
_value
bytes32 help

Properties

Visibility help public
Mutability help transaction
Source Code
    function setProperty(uint256 _id, bytes32 _key, bytes32 _value) public {
        require(
            msg.sender == propertyManager,
            "Core: must be property manager"
        );

        _setProperty(_id, _key, _value);
    }

setClassProperty keyboard_arrow_up

Parameters help

Name Type
_key
bytes32 help
_value
bytes32 help

Properties

Visibility help public
Mutability help transaction
Source Code
    function setClassProperty(bytes32 _key, bytes32 _value) public {
        require(
            msg.sender == propertyManager,
            "Core: must be property manager"
        );

        _setClassProperty(_key, _value);
    }

setBaseURI keyboard_arrow_up

Parameters help

Name Type
uri
string help

Properties

Visibility help public
Mutability help transaction

Modifiers help

onlyOwner checks for the following:
null
Source Code
    function setBaseURI(string memory uri) public onlyOwner {
        baseURI = uri;
    }

setMigrating keyboard_arrow_up

Parameters help

Name Type
_migrating
bool help

Properties

Visibility help public
Mutability help transaction

Modifiers help

onlyOwner checks for the following:
null
Source Code
    function setMigrating(bool _migrating) public onlyOwner {
        migrating = _migrating;
    }

copyUntil keyboard_arrow_up

Parameters help

Name Type
gasThreshold
uint help

Properties

Visibility help public
Mutability help transaction
Source Code
    function copyUntil(uint gasThreshold) public {
        while (gasleft() > gasThreshold) {
            copyNextBatch();
        }
    }

copyNextBatch keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help transaction
Source Code
    function copyNextBatch() public {
        require(migrating, "must be migrating");
        uint256 start = nextBatch;
        (uint48 userID, uint16 size) = old.batches(start);
        require(size > 0 && userID > 0, "incorrect batch or limit reached");
        if (old.cardProtos(start) != 0) {
            address to = old.userIDToAddress(userID);
            uint48 uID = _getUserID(to);
            batches[start] = Batch({
                userID: uID,
                size: size
            });
            uint256 end = start.add(size);
            for (uint256 i = start; i < end; i++) {
                emit Transfer(address(0), to, i);
            }
            _balances[to] = _balances[to].add(size);
            tokenCount = tokenCount.add(size);
        }
        nextBatch = nextBatch.add(batchSize);
    }

isOld keyboard_arrow_up

Parameters help

Name Type
_tokenId
uint help

Properties

Visibility help public
Mutability help view

Requirements help

null
Source Code
    function isOld(uint _tokenId) public view returns (bool) {
        require(_exists(_tokenId), "card does not exist");
        return cardProtos[_tokenId] == 0;
    }

getProto keyboard_arrow_up

Parameters help

Name Type
_tokenId
uint help

Properties

Visibility help public
Mutability help view
Source Code
    function getProto(uint _tokenId) public view returns (uint16) {
        return isOld(_tokenId) ? old.cardProtos(_tokenId) : cardProtos[_tokenId];
    }

getQuality keyboard_arrow_up

Parameters help

Name Type
_tokenId
uint help

Properties

Visibility help public
Mutability help view
Source Code
    function getQuality(uint _tokenId) public view returns (uint8) {
        return isOld(_tokenId) ? old.cardQualities(_tokenId) : cardQualities[_tokenId];
    }