About
Stats
Public Functions
63
Event Types
18
Code Size
169,167 bytes
Library Use
Uses Counters for Counters.Counter.
Events (18) keyboard_arrow_up
Structs (2) keyboard_arrow_up
Functions
supportsInterface keyboard_arrow_up
onERC1155Received keyboard_arrow_up
Source Code
function onERC1155Received(address, address, uint256, uint256, bytes memory) public virtual override returns (bytes4) {
return this.onERC1155Received.selector;
}
onERC1155BatchReceived keyboard_arrow_up
Source Code
function onERC1155BatchReceived(address, address, uint256[] memory, uint256[] memory, bytes memory) public virtual override returns (bytes4) {
return this.onERC1155BatchReceived.selector;
}
owner keyboard_arrow_up
renounceOwnership keyboard_arrow_up
transferOwnership keyboard_arrow_up
Modifiers help
onlyOwner checks for the following:
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;
}
recoverERC20 keyboard_arrow_up
Modifiers help
onlyOwner checks for the following:
Source Code
function recoverERC20(address tokenAddress, uint256 tokenAmount)
public
onlyOwner
{
IERC20(tokenAddress).transfer(owner(), tokenAmount);
}
paused keyboard_arrow_up
balanceOf keyboard_arrow_up
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
name keyboard_arrow_up
symbol keyboard_arrow_up
tokenURI keyboard_arrow_up
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
tokenOfOwnerByIndex keyboard_arrow_up
totalSupply keyboard_arrow_up
tokenByIndex keyboard_arrow_up
approve keyboard_arrow_up
Requirements help
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
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
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
transferFrom keyboard_arrow_up
Requirements help
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
Requirements help
Source Code
function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
safeTransferFrom keyboard_arrow_up
Requirements help
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);
}
burn keyboard_arrow_up
Requirements help
null
Source Code
function burn(uint256 tokenId) public virtual {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721Burnable: caller is not owner nor approved");
_burn(tokenId);
}
hasRole keyboard_arrow_up
getRoleMemberCount keyboard_arrow_up
getRoleMember keyboard_arrow_up
getRoleAdmin keyboard_arrow_up
grantRole keyboard_arrow_up
Requirements help
null
Source Code
function grantRole(bytes32 role, address account) public virtual {
require(
hasRole(_roles[role].adminRole, _msgSender()),
"AccessControl: sender must be an admin to grant"
);
_grantRole(role, account);
}
revokeRole keyboard_arrow_up
Requirements help
null
Source Code
function revokeRole(bytes32 role, address account) public virtual {
require(
hasRole(_roles[role].adminRole, _msgSender()),
"AccessControl: sender must be an admin to revoke"
);
_revokeRole(role, account);
}
renounceRole keyboard_arrow_up
Requirements help
Source Code
function renounceRole(bytes32 role, address account) public virtual {
require(
account == _msgSender(),
"AccessControl: can only renounce roles for self"
);
_revokeRole(role, account);
}
mint keyboard_arrow_up
Modifiers help
onlyMinter checks for the following:
null
Requirements help
Source Code
function mint(address player) public override onlyMinter {
//pet minted has 3 days until it starves at first
timeUntilStarving[_tokenIds.current()] = block.timestamp.add(3 days);
timeVnftBorn[_tokenIds.current()] = block.timestamp;
vnftDetails[_tokenIds.current()] = VNFTObj(
address(this),
_tokenIds.current(),
721
);
super._mint(player, _tokenIds.current());
_tokenIds.increment();
emit VnftMinted(msg.sender);
}
pause keyboard_arrow_up
unpause keyboard_arrow_up
contractURI keyboard_arrow_up
pauseGame keyboard_arrow_up
changeBurnPercentage keyboard_arrow_up
changeGiveLifePrice keyboard_arrow_up
changeMaxDevAllocation keyboard_arrow_up
itemExists keyboard_arrow_up
isVnftAlive keyboard_arrow_up
Source Code
function isVnftAlive(uint256 _nftId) public view returns (bool) {
uint256 _timeUntilStarving = timeUntilStarving[_nftId];
if (_timeUntilStarving != 0 && _timeUntilStarving >= block.timestamp) {
return true;
}
}
getVnftScore keyboard_arrow_up
getItemInfo keyboard_arrow_up
Source Code
function getItemInfo(uint256 _itemId)
public
view
returns (
string memory _name,
uint256 _price,
uint256 _points,
uint256 _timeExtension
)
{
_name = itemName[_itemId];
_price = itemPrice[_itemId];
_timeExtension = itemTimeExtension[_itemId];
_points = itemPoints[_itemId];
}
getVnftInfo keyboard_arrow_up
Source Code
function getVnftInfo(uint256 _nftId)
public
view
returns (
uint256 _vNFT,
bool _isAlive,
uint256 _score,
uint256 _level,
uint256 _expectedReward,
uint256 _timeUntilStarving,
uint256 _lastTimeMined,
uint256 _timeVnftBorn,
address _owner,
address _token,
uint256 _tokenId,
uint256 _fatalityReward
)
{
_vNFT = _nftId;
_isAlive = this.isVnftAlive(_nftId);
_score = this.getVnftScore(_nftId);
_level = this.level(_nftId);
_expectedReward = this.getRewards(_nftId);
_timeUntilStarving = timeUntilStarving[_nftId];
_lastTimeMined = lastTimeMined[_nftId];
_timeVnftBorn = timeVnftBorn[_nftId];
_owner = this.ownerOf(_nftId);
_token = vnftDetails[_nftId].token;
_tokenId = vnftDetails[_nftId].id;
_fatalityReward = getFatalityReward(_nftId);
}
editCurves keyboard_arrow_up
Modifiers help
onlyOperator checks for the following:
null
Source Code
function editCurves(
uint256 _la,
uint256 _lb,
uint256 _ra,
uint256 _rb
) external onlyOperator {
la = _la;
lb = _lb;
ra = _ra;
lb = _rb;
}
level keyboard_arrow_up
Source Code
function level(uint256 tokenId) external view returns (uint256) {
// This is the formula L(x) = 2 * sqrt(x * 2)
uint256 _score = vnftScore[tokenId].div(100);
if (_score == 0) {
return 1;
}
uint256 _level = sqrtu(_score.mul(la));
return (_level.mul(lb));
}
getRewards keyboard_arrow_up
Source Code
function getRewards(uint256 tokenId) external view returns (uint256) {
// This is the formula to get token rewards R(level)=(level)*6/7+6
uint256 _level = this.level(tokenId);
if (_level == 1) {
return 6 ether;
}
_level = _level.mul(1 ether).mul(ra).div(rb);
return (_level.add(5 ether));
}
editItem keyboard_arrow_up
Parameters help
Modifiers help
onlyOperator checks for the following:
null
Source Code
function editItem(
uint256 _id,
uint256 _price,
uint256 _points,
string calldata _name,
uint256 _timeExtension
) external onlyOperator {
itemPrice[_id] = _price;
itemPoints[_id] = _points;
itemName[_id] = _name;
itemTimeExtension[_id] = _timeExtension;
}
claimMiningRewards keyboard_arrow_up
Modifiers help
notPaused checks for the following:
Requirements help
null
One or more of the following:
-
lastTimeMined for nftId
must be equal to
0
- OR
block.timestamp
must be greater than or equal to
UNKNOWN VALUE
One or more of the following:
-
careTaker for nftId for the result of calling ownerOf with nftId
must be equal to
the sender's address
- OR
the result of calling ownerOf with nftId
must be equal to
the sender's address
Source Code
function claimMiningRewards(uint256 nftId) external notPaused {
require(isVnftAlive(nftId), "Your vNFT is dead, you can't mine");
require(
block.timestamp >= lastTimeMined[nftId].add(1 days) ||
lastTimeMined[nftId] == 0,
"Current timestamp is over the limit to claim the tokens"
);
require(
ownerOf(nftId) == msg.sender ||
careTaker[nftId][ownerOf(nftId)] == msg.sender,
"You must own the vNFT to claim rewards"
);
//reset last start mined so can't remine and cheat
lastTimeMined[nftId] = block.timestamp;
uint256 _reward = this.getRewards(nftId);
muse.mint(msg.sender, _reward);
emit ClaimedMiningRewards(nftId, msg.sender, _reward);
}
buyAccesory keyboard_arrow_up
Modifiers help
notPaused checks for the following:
Requirements help
null
One or more of the following:
-
careTaker for nftId for the result of calling ownerOf with nftId
must be equal to
the sender's address
- OR
the result of calling ownerOf with nftId
must be equal to
the sender's address
Source Code
function buyAccesory(uint256 nftId, uint256 itemId) external notPaused {
require(itemExists(itemId), "This item doesn't exist");
uint256 amount = itemPrice[itemId];
require(
ownerOf(nftId) == msg.sender ||
careTaker[nftId][ownerOf(nftId)] == msg.sender,
"You must own the vNFT or be a care taker to buy items"
);
// require(isVnftAlive(nftId), "Your vNFT is dead");
uint256 amountToBurn = amount.mul(burnPercentage).div(100);
if (!isVnftAlive(nftId)) {
vnftScore[nftId] = itemPoints[itemId];
timeUntilStarving[nftId] = block.timestamp.add(
itemTimeExtension[itemId]
);
} else {
//recalculate timeUntilStarving.
timeUntilStarving[nftId] = block.timestamp.add(
itemTimeExtension[itemId]
);
vnftScore[nftId] = vnftScore[nftId].add(itemPoints[itemId]);
}
// burn 90% so they go back to community mining and staking, and send 10% to devs
if (devAllocation <= maxDevAllocation) {
devAllocation = devAllocation.add(amount.sub(amountToBurn));
muse.transferFrom(msg.sender, address(this), amount);
// burn 90% of token, 10% stay for dev and community fund
muse.burn(amountToBurn);
} else {
muse.burnFrom(msg.sender, amount);
}
emit VnftConsumed(nftId, msg.sender, itemId);
}
setBaseURI keyboard_arrow_up
fatality keyboard_arrow_up
Modifiers help
notPaused checks for the following:
Requirements help
Source Code
function fatality(uint256 _deadId, uint256 _tokenId) external notPaused {
require(
!isVnftAlive(_deadId),
"The vNFT has to be starved to claim his points"
);
vnftScore[_tokenId] = vnftScore[_tokenId].add(
(vnftScore[_deadId].mul(60).div(100))
);
// delete vnftDetails[_deadId];
_burn(_deadId);
emit VnftFatalized(_deadId, msg.sender);
}
getFatalityReward keyboard_arrow_up
createItem keyboard_arrow_up
Parameters help
Modifiers help
onlyOperator checks for the following:
null
Source Code
function createItem(
string calldata name,
uint256 price,
uint256 points,
uint256 timeExtension
) external onlyOperator returns (bool) {
_itemIds.increment();
uint256 newItemId = _itemIds.current();
itemName[newItemId] = name;
itemPrice[newItemId] = price * 10**18;
itemPoints[newItemId] = points;
itemTimeExtension[newItemId] = timeExtension;
emit ItemCreated(newItemId, name, price, points);
}
addNft keyboard_arrow_up
Modifiers help
onlyOperator checks for the following:
null
Source Code
function addNft(address _nftToken, uint256 _type) public onlyOperator {
supportedNfts.push(
NFTInfo({token: _nftToken, active: true, standard: _type})
);
}
supportedNftLength keyboard_arrow_up
updateSupportedNFT keyboard_arrow_up
Modifiers help
onlyOperator checks for the following:
null
Source Code
function updateSupportedNFT(
uint256 index,
bool _active,
address _address
) public onlyOperator {
supportedNfts[index].active = _active;
supportedNfts[index].token = _address;
}
giveLife keyboard_arrow_up
Modifiers help
notPaused checks for the following:
Requirements help
Source Code
function giveLife(
uint256 index,
uint256 _id,
uint256 nftType
) external notPaused {
uint256 amountToBurn = giveLifePrice.mul(burnPercentage).div(100);
if (devAllocation <= maxDevAllocation) {
devAllocation = devAllocation.add(giveLifePrice.sub(amountToBurn));
muse.transferFrom(msg.sender, address(this), giveLifePrice);
// burn 90% of token, 10% stay for dev and community fund
muse.burn(amountToBurn);
} else {
muse.burnFrom(msg.sender, giveLifePrice);
}
if (nftType == 721) {
IERC721(supportedNfts[index].token).transferFrom(
msg.sender,
address(this),
_id
);
} else if (nftType == 1155) {
IERC1155(supportedNfts[index].token).safeTransferFrom(
msg.sender,
address(this),
_id,
1, //the amount of tokens to transfer which always be 1
"0x0"
);
}
// mint a vNFT
vnftDetails[_tokenIds.current()] = VNFTObj(
supportedNfts[index].token,
_id,
nftType
);
timeUntilStarving[_tokenIds.current()] = block.timestamp.add(3 days);
timeVnftBorn[_tokenIds.current()] = block.timestamp;
super._mint(msg.sender, _tokenIds.current());
_tokenIds.increment();
emit LifeGiven(supportedNfts[index].token, _id);
}
unwrap keyboard_arrow_up
Requirements help
null
null
UNKNOWN VALUE
must not be equal to
UNKNOWN VALUE
Source Code
function unwrap(uint256 _vnftId) external {
require(isVnftAlive(_vnftId), "Your vNFT is dead, you can't unwrap it");
transferFrom(msg.sender, address(this), _vnftId);
VNFTObj memory details = vnftDetails[_vnftId];
timeUntilStarving[_vnftId] = 1;
vnftScore[_vnftId] = 0;
emit Unwrapped(_vnftId);
_withdraw(details.id, details.token, msg.sender, details.standard);
}
withdraw keyboard_arrow_up
addCareTaker keyboard_arrow_up
Requirements help
One or more of the following:
-
the result of calling ownerOf with _tokenId
must be equal to
the sender's address
- ORnull
Source Code
function addCareTaker(uint256 _tokenId, address _careTaker) external {
require(
hasRole(OPERATOR_ROLE, _msgSender()) ||
ownerOf(_tokenId) == msg.sender,
"Roles: caller does not have the OPERATOR role"
);
careTaker[_tokenId][msg.sender] = _careTaker;
emit CareTakerAdded(_tokenId, _careTaker);
}
clearCareTaker keyboard_arrow_up
Requirements help
One or more of the following:
-
the result of calling ownerOf with _tokenId
must be equal to
the sender's address
- ORnull
Source Code
function clearCareTaker(uint256 _tokenId) external {
require(
hasRole(OPERATOR_ROLE, _msgSender()) ||
ownerOf(_tokenId) == msg.sender,
"Roles: caller does not have the OPERATOR role"
);
delete careTaker[_tokenId][msg.sender];
emit CareTakerRemoved(_tokenId);
}