UnstBONE

Link to UnstBONE source code on Ethereum

UnstBONE contract is an ERC721 contract used by the KnBONE contract to manage withdrawal requests.

Variables

address public knBONE; - knBONE contract address. uint256 public tokenIdIndex; - totalSupply value of the contract. Burned NFTs are not taken into account, so it shows how many tokens were minted. mapping(address => uint256[]) public owner2Tokens; - for each address returns an array of tokens that this address owns. mapping(uint256 => uint256) public token2Index; - for each token returns the index in the owner2Tokens array. mapping(address => uint256[]) public address2Approved; - for each address returns an array of tokens that have been approved for this address. Does not take into account approvals via approvalForAll. mapping(uint256 => uint256) public tokenId2ApprovedIndex; - for each approved token returns the index in the returned array address2Approved.

Modifiers

isKnBONE() - requires the function caller to be knBONE.

Methods

initialize

function initialize(
        address _knBONE,
        address _dao
    ) external initializer

- initializer function, not called after initialization.

mint

function mint(address _to) external isKnBONE returns (uint256)

Mint new token.

tokenID starts from 1, not from 0

burn

function burn(uint256 _tokenId) external isKnBONE

Burns the token.

approve

function approve(address _to, uint256 _tokenId)
        public
        override(ERC721Upgradeable, IERC721Upgradeable)

Rewritten 'approval' from ERC721, in addition to what it usually does, it also interacts with address2Approved and tokenId2ApprovedIndex.

isApprovedOrOwner

function isApprovedOrOwner(address _spender, uint256 _tokenId)
        external
        view
        returns (bool)

Shows whether the spender is authorized to use the token (approved or owned). An approve that was made via approvalForAll is taken into account.

setKnBONE

function setKnBONE(address _knBONE) external onlyOwner

Sets knBONE contract address.

getOwnedTokens

function getOwnedTokens(address _address)
        external
        view
        returns (uint256[] memory)

Duplicates owner2Tokens - for each address returns an array of tokens that this address owns.

getApprovedTokens

function getApprovedTokens(address _address)
        external
        view
        returns (uint256[] memory)

Duplicates address2Approved - for each address returns an array of tokens that have been approved for this address. Does not take into account approvals via approvalForAll.

togglePause

function togglePause() external onlyOwner

Switches pause on/off.

Last updated