JOYWORLD JOYtoys
About
Stats
Public Functions
44
Event Types
12
Code Size
75,799 bytes
Library Use
Uses SafeMath for uint256.
Events (12) keyboard_arrow_up
Constants (5) keyboard_arrow_up
State Variables (42) keyboard_arrow_up
Functions
owner 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;
}
supportsInterface 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");
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);
}
createJOYtoy keyboard_arrow_up
Parameters help
Modifiers help
onlyOwner checks for the following:
Source Code
function createJOYtoy(
string memory artworkHash,
string memory artworkType,
string memory power,
string memory toyName,
string memory feature,
uint256 editionSize,
bool vendingMachine,
uint256 price,
uint256 royalty
) public onlyOwner {
toyMintingActive[JOYtoyIndex] = true;
JOYtoyArtwork[JOYtoyIndex][1] = artworkHash;
artworkTypeMemory[JOYtoyIndex][1] = artworkType;
powerMemory[JOYtoyIndex] = power;
toyNameMemory[JOYtoyIndex] = toyName;
featuresMemory[JOYtoyIndex] = feature;
editionSizeMemory[JOYtoyIndex] = editionSize;
totalCreated[JOYtoyIndex] = 0;
totalMinted[JOYtoyIndex] = 0;
artworkSlotFilled[JOYtoyIndex][1] = true;
vendingMachineMode[JOYtoyIndex] = vendingMachine;
priceMemory[JOYtoyIndex] = price;
royaltyMemory[JOYtoyIndex] = royalty;
emit NewJOYtoyCreated(
artworkHash,
artworkType,
power,
toyName,
feature,
editionSize,
vendingMachine,
price,
royalty,
JOYtoyIndex
);
JOYtoyIndex = JOYtoyIndex + 1;
}
addJOYtoyRoyalties keyboard_arrow_up
Parameters help
Modifiers help
onlyOwner checks for the following:
Requirements help
Source Code
function addJOYtoyRoyalties(
uint256 JOYtoyId,
address[] memory royaltyAddresses,
uint256[] memory royaltyPercentage,
string memory collaboratorNames
) public onlyOwner {
require(royaltyAddresses.length == royaltyPercentage.length);
require(royaltyAddresses.length <= 5);
uint256 totalCollaboratorRoyalties;
collaboratorNamesMemory[JOYtoyId] = collaboratorNames;
for (uint256 i = 0; i < royaltyAddresses.length; i++) {
royaltyAddressMemory[JOYtoyId][i] = royaltyAddresses[i];
royaltyPercentageMemory[JOYtoyId][i] = royaltyPercentage[i];
totalCollaboratorRoyalties =
totalCollaboratorRoyalties +
royaltyPercentage[i];
}
royaltyLengthMemory[JOYtoyId] = royaltyAddresses.length;
emit AddJOYtoyRoyalties(JOYtoyId, royaltyAddresses.length);
}
getRoyalties keyboard_arrow_up
Source Code
function getRoyalties(uint256 JOYtoyId)
public
view
returns (address[5] memory addresses, uint256[5] memory percentages)
{
for (uint256 i = 0; i < royaltyLengthMemory[JOYtoyId]; i++) {
addresses[i] = royaltyAddressMemory[JOYtoyId][i];
percentages[i] = royaltyPercentageMemory[JOYtoyId][i];
}
}
addJOYCollector keyboard_arrow_up
Parameters help
Modifiers help
onlyOwner checks for the following:
Source Code
function addJOYCollector(
uint256 JOYtoyId,
uint256 joyTokenId,
uint256 joyCollectorPercent,
bool collectorActive
) public onlyOwner {
joyCollabTokenId[JOYtoyId] = joyTokenId;
joyHolderCollaborator[JOYtoyId] = originalJOYOwner(joyTokenId);
joyHolderCollabPercent[JOYtoyId] = joyCollectorPercent;
joyHolderCollabActive[JOYtoyId] = collectorActive;
emit AddJOYCollector(
JOYtoyId,
joyTokenId,
joyCollectorPercent,
collectorActive
);
}
getJoyCollaborator keyboard_arrow_up
Source Code
function getJoyCollaborator(uint256 JOYtoyId)
public
view
returns (
uint256 joyTokenId,
address joyTokenHolder,
uint256 joyCollectorPercent,
bool collectorActive
)
{
joyTokenId = joyCollabTokenId[JOYtoyId];
joyTokenHolder = joyHolderCollaborator[JOYtoyId];
joyCollectorPercent = joyHolderCollabPercent[JOYtoyId];
collectorActive = joyHolderCollabActive[JOYtoyId];
}
clearRoyalties keyboard_arrow_up
Modifiers help
onlyOwner checks for the following:
Source Code
function clearRoyalties(uint256 JOYtoyId) public onlyOwner {
for (uint256 i = 0; i < royaltyLengthMemory[JOYtoyId]; i++) {
royaltyAddressMemory[JOYtoyId][
i
] = 0x0000000000000000000000000000000000000000;
royaltyPercentageMemory[JOYtoyId][i] = 0;
}
collaboratorNamesMemory[JOYtoyId] = "";
royaltyLengthMemory[JOYtoyId] = 0;
emit ClearRoyalties(JOYtoyId);
}
addJOYtoyArtwork keyboard_arrow_up
Parameters help
Modifiers help
onlyOwner checks for the following:
Requirements help
Source Code
function addJOYtoyArtwork(
uint256 JOYtoyToUpdate,
string memory artworkHash,
string memory artworkType,
uint256 artworkIndex
) public onlyOwner {
require(artworkSlotFilled[JOYtoyToUpdate][artworkIndex] == false);
JOYtoyArtwork[JOYtoyToUpdate][artworkIndex] = artworkHash;
artworkTypeMemory[JOYtoyToUpdate][artworkIndex] = artworkType;
artworkSlotFilled[JOYtoyToUpdate][artworkIndex] = true;
emit NewArtworkAdded(JOYtoyToUpdate, artworkHash, artworkType, artworkIndex);
}
updateFeature keyboard_arrow_up
Modifiers help
onlyOwner checks for the following:
Source Code
function updateFeature(uint256 JOYtoyToUpdate, string memory newFeatures)
public
onlyOwner
{
featuresMemory[JOYtoyToUpdate] = newFeatures;
emit UpdateFeature(JOYtoyToUpdate, newFeatures);
}
updatePrice keyboard_arrow_up
Modifiers help
onlyOwner checks for the following:
Source Code
function updatePrice(uint256 JOYtoyToUpdate, uint256 price) public onlyOwner {
priceMemory[JOYtoyToUpdate] = price;
emit UpdatePrice(JOYtoyToUpdate, price / 10**18);
}
mintJOYtoy keyboard_arrow_up
Modifiers help
onlyOwner checks for the following:
Requirements help
totalMinted for JOYtoyId + amountToMint
must be less than or equal to
editionSizeMemory for JOYtoyId
Source Code
function mintJOYtoy(uint256 JOYtoyId, uint256 amountToMint) public onlyOwner {
require(toyMintingActive[JOYtoyId] == true);
require(totalMinted[JOYtoyId] + amountToMint <= editionSizeMemory[JOYtoyId]);
for (
uint256 i = totalMinted[JOYtoyId];
i < amountToMint + totalMinted[JOYtoyId];
i++
) {
uint256 tokenId = totalSupply() + 1;
artworkJOYtoyReference[tokenId] = JOYtoyId;
editionNumberMemory[tokenId] = i + 1;
_safeMint(msg.sender, tokenId);
}
totalMinted[JOYtoyId] = totalMinted[JOYtoyId] + amountToMint;
if (totalMinted[JOYtoyId] == editionSizeMemory[JOYtoyId]) {
closeJOYtoyWindow(JOYtoyId);
}
}
JOYtoyMachine keyboard_arrow_up
Requirements help
null
Source Code
function JOYtoyMachine(uint256 JOYtoyId) public payable {
require(toyMintingActive[JOYtoyId] == true);
require(totalMinted[JOYtoyId] + 1 <= editionSizeMemory[JOYtoyId]);
require(vendingMachineMode[JOYtoyId] == true);
require(msg.value == priceMemory[JOYtoyId]);
uint256 tokenId = totalSupply() + 1;
artworkJOYtoyReference[tokenId] = JOYtoyId;
editionNumberMemory[tokenId] = totalMinted[JOYtoyId] + 1;
(
address[5] memory royaltyAddress,
uint256[5] memory percentage
) = getRoyalties(JOYtoyId);
for (uint256 i = 0; i < royaltyLengthMemory[JOYtoyId]; i++) {
address payable artistWallet = address(uint160(royaltyAddress[i]));
artistWallet.transfer((msg.value / 100) * percentage[i]);
}
if (joyHolderCollabActive[JOYtoyId] == true) {
address payable joyHolder = address(
uint160(joyHolderCollaborator[JOYtoyId])
);
uint256 joyHolderPercentage = joyHolderCollabPercent[JOYtoyId];
joyHolder.transfer((msg.value / 100) * joyHolderPercentage);
}
joyWallet.transfer(address(this).balance);
_safeMint(msg.sender, tokenId);
totalMinted[JOYtoyId] = totalMinted[JOYtoyId] + 1;
if (totalMinted[JOYtoyId] == editionSizeMemory[JOYtoyId]) {
closeJOYtoyWindow(JOYtoyId);
}
}
closeJOYtoyWindow keyboard_arrow_up
Modifiers help
onlyOwner checks for the following:
Source Code
function closeJOYtoyWindow(uint256 JOYtoyId) public onlyOwner {
toyMintingActive[JOYtoyId] = false;
editionSizeMemory[JOYtoyId] = totalMinted[JOYtoyId];
emit CloseJOYtoyWindow(JOYtoyId);
}
withdrawFunds keyboard_arrow_up
getJOYtoyArtworkData keyboard_arrow_up
Source Code
function getJOYtoyArtworkData(uint256 JOYtoyId, uint256 index)
public
view
returns (
string memory artworkHash,
string memory artworkType,
uint256 unmintedEditions
)
{
artworkHash = JOYtoyArtwork[JOYtoyId][index];
artworkType = artworkTypeMemory[JOYtoyId][index];
unmintedEditions = editionSizeMemory[JOYtoyId] - totalMinted[JOYtoyId];
}
getMetadata keyboard_arrow_up
Requirements help
null
Source Code
function getMetadata(uint256 tokenId)
public
view
returns (
string memory toyName,
string memory power,
uint256 editionSize,
uint256 editionNumber,
bool vendingMachine,
string memory feature,
uint256 price,
string memory collaborators,
bool toyActive
)
{
require(_exists(tokenId), "Token does not exist.");
uint256 JOYtoyRef = artworkJOYtoyReference[tokenId];
toyName = toyNameMemory[JOYtoyRef];
power = powerMemory[JOYtoyRef];
editionSize = editionSizeMemory[JOYtoyRef];
editionNumber = editionNumberMemory[tokenId];
vendingMachine = vendingMachineMode[JOYtoyRef];
feature = featuresMemory[JOYtoyRef];
price = priceMemory[JOYtoyRef];
collaborators = collaboratorNamesMemory[JOYtoyRef];
toyActive = toyMintingActive[JOYtoyRef];
}
getRoyaltyData keyboard_arrow_up
Requirements help
null
Source Code
function getRoyaltyData(uint256 tokenId)
public
view
returns (address artistAddress, uint256 royaltyFeeById)
{
require(_exists(tokenId), "Token does not exist.");
uint256 JOYtoyRef = artworkJOYtoyReference[tokenId];
artistAddress = joyWallet;
royaltyFeeById = royaltyMemory[JOYtoyRef];
}
getArtworkData keyboard_arrow_up
Requirements help
null
Source Code
function getArtworkData(uint256 tokenId, uint256 index)
public
view
returns (string memory artworkHash, string memory artworkType)
{
require(_exists(tokenId), "Token does not exist.");
uint256 JOYtoyRef = artworkJOYtoyReference[tokenId];
artworkHash = JOYtoyArtwork[JOYtoyRef][index];
artworkType = artworkTypeMemory[JOYtoyRef][index];
}
updateGalleryLink keyboard_arrow_up
Modifiers help
onlyOwner checks for the following:
Source Code
function updateGalleryLink(string memory newURL) public onlyOwner {
joyGalleryLink = newURL;
}
updatePaymentWallet keyboard_arrow_up
Modifiers help
onlyOwner checks for the following:
Source Code
function updatePaymentWallet(address payable newWallet) public onlyOwner {
joyWallet = newWallet;
}
updateURI keyboard_arrow_up
Modifiers help
onlyOwner checks for the following:
Source Code
function updateURI(string memory newURI) public onlyOwner {
_setBaseURI(newURI);
}
updateJOYtoyURI keyboard_arrow_up
Modifiers help
onlyOwner checks for the following:
Source Code
function updateJOYtoyURI(string memory newURI1, string memory newURI2)
public
onlyOwner
{
JOYtoyURI1 = newURI1;
JOYtoyURI2 = newURI2;
}
JOYtoyURI keyboard_arrow_up
Requirements help
null
Source Code
function JOYtoyURI(uint256 tokenId, uint256 artworkIndex)
external
view
returns (string memory)
{
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
return
string(
abi.encodePacked(
JOYtoyURI1,
integerToString(tokenId),
JOYtoyURI2,
integerToString(artworkIndex)
)
);
}
originalJOYOwner keyboard_arrow_up
updateArtworkTypeList keyboard_arrow_up
Modifiers help
onlyOwner checks for the following:
Source Code
function updateArtworkTypeList(string memory newArtworkTypeList)
public
onlyOwner
{
artworkTypeList = newArtworkTypeList;
}
updateJOYContractAddress keyboard_arrow_up
Modifiers help
onlyOwner checks for the following:
Source Code
function updateJOYContractAddress(address newJOYaddress) public onlyOwner {
joyContractAddress = newJOYaddress;
joyWorld = JOYContract(joyContractAddress);
}
Internal Functions
Internal functions are parts of the contract that can't be used directly, but instead are used by the public functions listed above.
internal JOYtoys.integerToString keyboard_arrow_up
Source Code
function integerToString(uint256 _i) internal pure returns (string memory) {
if (_i == 0) {
return "0";
}
uint256 j = _i;
uint256 len;
while (j != 0) {
len++;
j /= 10;
}
bytes memory bstr = new bytes(len);
uint256 k = len - 1;
while (_i != 0) {
bstr[k--] = byte(uint8(48 + (_i % 10)));
_i /= 10;
}
return string(bstr);
}
internal ERC721._safeTransfer keyboard_arrow_up
Requirements help
Source Code
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(
_checkOnERC721Received(from, to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
internal ERC721._exists keyboard_arrow_up
internal ERC721._isApprovedOrOwner keyboard_arrow_up
Requirements help
null
Source Code
function _isApprovedOrOwner(address spender, uint256 tokenId)
internal
view
returns (bool)
{
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ownerOf(tokenId);
return (spender == owner ||
getApproved(tokenId) == spender ||
isApprovedForAll(owner, spender));
}
internal ERC721._safeMint keyboard_arrow_up
Requirements help
null
Source Code
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
internal ERC721._safeMint keyboard_arrow_up
Requirements help
null
Source Code
function _safeMint(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
internal ERC721._mint keyboard_arrow_up
Requirements help
Source Code
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_holderTokens[to].add(tokenId);
_tokenOwners.set(tokenId, to);
emit Transfer(address(0), to, tokenId);
}
internal ERC721._burn keyboard_arrow_up
Source Code
function _burn(uint256 tokenId) internal virtual {
address owner = ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
// Clear metadata (if any)
if (bytes(_tokenURIs[tokenId]).length != 0) {
delete _tokenURIs[tokenId];
}
_holderTokens[owner].remove(tokenId);
_tokenOwners.remove(tokenId);
emit Transfer(owner, address(0), tokenId);
}
internal ERC721._transfer keyboard_arrow_up
Requirements help
Source Code
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(
ownerOf(tokenId) == from,
"ERC721: transfer of token that is not own"
);
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_holderTokens[from].remove(tokenId);
_holderTokens[to].add(tokenId);
_tokenOwners.set(tokenId, to);
emit Transfer(from, to, tokenId);
}
internal ERC721._setTokenURI keyboard_arrow_up
Requirements help
null
Source Code
function _setTokenURI(uint256 tokenId, string memory _tokenURI)
internal
virtual
{
require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token");
_tokenURIs[tokenId] = _tokenURI;
}
internal ERC721._setBaseURI keyboard_arrow_up
internal ERC721._checkOnERC721Received keyboard_arrow_up
Source Code
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (!to.isContract()) {
return true;
}
bytes memory returndata = to.functionCall(
abi.encodeWithSelector(
IERC721Receiver(to).onERC721Received.selector,
_msgSender(),
from,
tokenId,
_data
),
"ERC721: transfer to non ERC721Receiver implementer"
);
bytes4 retval = abi.decode(returndata, (bytes4));
return (retval == _ERC721_RECEIVED);
}
internal ERC721._approve keyboard_arrow_up
internal ERC721._beforeTokenTransfer keyboard_arrow_up
internal Context._msgSender keyboard_arrow_up
internal Context._msgData keyboard_arrow_up
Parameters help
This function has no parameters.
Source Code
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
internal ERC165.constructor keyboard_arrow_up
internal ERC165._registerInterface keyboard_arrow_up
Requirements help
Source Code
function _registerInterface(bytes4 interfaceId) internal virtual {
require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
_supportedInterfaces[interfaceId] = true;
}
internal Ownable.constructor keyboard_arrow_up
internal Context._msgSender keyboard_arrow_up
internal Context._msgData keyboard_arrow_up
Parameters help
This function has no parameters.
Source Code
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}