Blockwell

Planet-1

About

Stats

Public Functions 31
Event Types 4
Code Size 105,540 bytes

Library Use

Uses SafeMath for uint256.
Uses SafeMath for uint32.
Uses SafeERC20 for IERC20.
Uses Counters for Counters.Counter.
Uses EnumerableSet for EnumerableSet.UintSet.
Uses EnumerableMap for EnumerableMap.UintToAddressMap.

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

OwnershipTransferred Event

Parameters help
previousOwner
address help
newOwner
address help

Transfer Event

Parameters help
from
address help
to
address help
tokenId
uint256 help

Functions Expand All Collapse All

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

renounceOwnership keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help transaction

Modifiers help

Source Code
    function renounceOwnership() public virtual 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

Requirements help

Source Code
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }

supportsInterface keyboard_arrow_up

Parameters help

Name Type
interfaceId
bytes4 help

Properties

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

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) public view override returns (uint256) {
        require(owner != address(0), "ERC721: balance query for the zero address");

        return _holderTokens[owner].length();
    }

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 override returns (address) {
        return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token");
    }

name keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
    function name() public view override 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() public view override returns (string memory) {
        return _symbol;
    }

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) public view override returns (string memory) {
        require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");

        string memory _tokenURI = _tokenURIs[tokenId];

        // If there is no base URI, return the token URI.
        if (bytes(_baseURI).length == 0) {
            return _tokenURI;
        }
        // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).
        if (bytes(_tokenURI).length > 0) {
            return string(abi.encodePacked(_baseURI, _tokenURI));
        }
        // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI.
        return string(abi.encodePacked(_baseURI, tokenId.toString()));
    }

baseURI keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
    function baseURI() public view returns (string memory) {
        return _baseURI;
    }

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 override returns (uint256) {
        return _holderTokens[owner].at(index);
    }

totalSupply keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
    function totalSupply() public view override returns (uint256) {
        // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds
        return _tokenOwners.length();
    }

tokenByIndex keyboard_arrow_up

Parameters help

Name Type
index
uint256 help

Properties

Visibility help public
Mutability help view
Source Code
    function tokenByIndex(uint256 index) public view override returns (uint256) {
        (uint256 tokenId, ) = _tokenOwners.at(index);
        return 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 virtual override {
        address owner = ownerOf(tokenId);
        require(to != owner, "ERC721: approval to current owner");

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

        _approve(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 override returns (address) {
        require(_exists(tokenId), "ERC721: approved query for nonexistent token");

        return _tokenApprovals[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) public virtual override {
        require(operator != _msgSender(), "ERC721: approve to caller");

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

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

        _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 transaction
Source Code
    function safeTransferFrom(address from, address to, uint256 tokenId) public virtual 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 virtual override {
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
        _safeTransfer(from, to, tokenId, _data);
    }

initProduct keyboard_arrow_up

Parameters help

Name Type
_mainAddr
address help
_dnftTokenAddr
address help
_uniswapAddr
address help
_id
uint16 help
_costTokenAddr
address help
_cost
uint256 help
_totalReturnRate
uint32 help
_maxMintTime
uint256 help
_maxTokenSize
uint256 help

Properties

Visibility help public
Mutability help transaction

Modifiers help

Source Code
    function initProduct(
        address _mainAddr,
        address _dnftTokenAddr,
        address _uniswapAddr,
        uint16 _id,
        address _costTokenAddr,
        uint256 _cost,
        uint32 _totalReturnRate,
        uint256 _maxMintTime,
        uint256 _maxTokenSize
    ) external onlyOwner {
        require(!_init, "repeat init");
        require(_maxTokenSize < 1E6, "product total supply must be < 1E6");
        mainAddr = _mainAddr;
        pid = _id;
        costTokenAddr = _costTokenAddr;
        cost = _cost;
        maxTokenSize = _maxTokenSize;
        maxMintTime = _maxMintTime;
        totalReturnRate = _totalReturnRate;
        dnftTokenAddr = _dnftTokenAddr;
        uniswapAddr = _uniswapAddr;
        if (_costTokenAddr != address(0)) {
            costTokenDecimals = IERC20Token(_costTokenAddr).decimals();
        } else {
            costTokenDecimals = 18;
        }
        mintTimeInterval = 1 minutes;
        mintPerTimeValue = totalReturnRate.mul(cost).div(100).div(maxMintTime.div(mintTimeInterval));
    }

getDNFTPrice keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
    function getDNFTPrice() external view returns (uint256){
        return _getDNFTPrice();
    }

tokensOfOwner keyboard_arrow_up

Parameters help

Name Type
owner
address help

Properties

Visibility help public
Mutability help view
Source Code
    function tokensOfOwner(address owner) external view returns (Lib.ProductTokenDetail[] memory){
        EnumerableSet.UintSet storage mintTokens = _tokenMints[owner];
        uint holdLength = balanceOf(owner);
        uint tokenLengthSize = mintTokens.length() + holdLength;
        if (tokenLengthSize == 0) {
            Lib.ProductTokenDetail[] memory zt = new Lib.ProductTokenDetail[](0);
            return zt;
        }
        Lib.ProductTokenDetail[] memory tokens = new Lib.ProductTokenDetail[](tokenLengthSize);
        uint i = 0;
        while (i < mintTokens.length()) {
            tokens[i] = _tokenDetails[mintTokens.at(i)];
            i++;
        }
        uint j = 0;
        while (j < holdLength) {
            tokens[i] = _tokenDetails[tokenOfOwnerByIndex(owner, j)];
            i++;
            j++;
        }
        return tokens;
    }

tokenDetailOf keyboard_arrow_up

Parameters help

Name Type
tid
uint256 help

Properties

Visibility help public
Mutability help view
Source Code
    function tokenDetailOf(uint256 tid) external view returns (Lib.ProductTokenDetail memory){
        return _tokenDetails[tid];
    }

tokenMintHistoryOf keyboard_arrow_up

Parameters help

Name Type
tid
uint256 help

Properties

Visibility help public
Mutability help view
Source Code
    function tokenMintHistoryOf(uint256 tid) external view returns (Lib.ProductMintItem[] memory){
        return _tokenMintHistories[tid];
    }

withdrawToken keyboard_arrow_up

Parameters help

Name Type
to
address help
token
address help
value
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
    function withdrawToken(address payable to, address token, uint256 value) onlyMain external {
        if (token == address(0))
            to.transfer(value);
        else
            IERC20(token).safeTransfer(to, value);
    }

buy keyboard_arrow_up

Parameters help

Name Type
to
address help

Properties

Visibility help public
Mutability help transaction
Source Code
    function buy(address to) external onlyMain returns (uint256) {
        require(_tokenIds.current() < maxTokenSize, "product not enough");
        _tokenIds.increment();
        uint256 tid = pid * 1E6 + _tokenIds.current();
        Lib.ProductTokenDetail memory detail;
        detail.id = tid;
        detail.propA = Lib.random(0, 10000);
        detail.propB = Lib.random(0, 10000);
        detail.propC = Lib.random(0, 10000);
        _tokenDetails[tid] = detail;
        _safeMint(to, tid);
        _setTokenURI(tid, Strings.toString(tid));
        return tid;
    }

mintBegin keyboard_arrow_up

Parameters help

Name Type
from
address help
tokenId
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
    function mintBegin(address from, uint256 tokenId) external onlyMain {
        require(_isApprovedOrOwner(from, tokenId), "ERC721: transfer caller is not owner nor approved");
        Lib.ProductTokenDetail storage detail = _tokenDetails[tokenId];
        require(detail.mining == false, "Token already mining.");
        require(detail.totalTime < maxMintTime, "Token already dead.");
        detail.mining = true;
        detail.currMining.minter = from;
        detail.currMining.beginTime = block.timestamp;
        detail.currMining.endTime = 0;
        detail.currMining.withdrawTime = detail.currMining.beginTime;
        _tokenMints[from].add(tokenId);
        _transfer(from, address(this), tokenId);
    }

canWithdrawValue keyboard_arrow_up

Parameters help

Name Type
tokenId
uint256 help

Properties

Visibility help public
Mutability help view
Source Code
    function canWithdrawValue(uint256 tokenId) external view returns (uint256 timeNum, uint256 dnftNum){
        return _canWithdrawValue(tokenId);
    }

mintWithdraw keyboard_arrow_up

Parameters help

Name Type
from
address help
tokenId
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
    function mintWithdraw(address from, uint256 tokenId) external onlyMain returns (uint256, uint256) {
        _onlyMinter(from, tokenId);
        return _mintWithdraw(from, tokenId);
    }

redeem keyboard_arrow_up

Parameters help

Name Type
from
address help
tokenId
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
    function redeem(address from, uint256 tokenId) external onlyMain returns (uint256, uint256){
        _onlyMinter(from, tokenId);
        (uint256 withdrawNum,uint256 timeNum) = _mintWithdraw(from, tokenId);

        Lib.ProductTokenDetail storage detail = _tokenDetails[tokenId];
        detail.mining = false;
        detail.currMining.endTime = block.timestamp;
        _tokenMintHistories[tokenId].push(detail.currMining);

        _tokenMints[from].remove(tokenId);
        Lib.ProductMintItem memory currItem;
        detail.currMining = currItem;

        _safeTransfer(address(this), from, tokenId, "");
        return (withdrawNum, timeNum);
    }