NFT Contract
Verified Contract:
https://etherscan.io/address/0x51369E8C482763089b0b90009C2A79C98244168E#code
Unifriends.sol
ERC721Enumerable w/ optimization tweaks
On-chain metadata for properties and stats
Off-chain image asset stored in IPFS
UnifriendsRenderer.sol
Logic for deriving properties from a seed
On-chain metadata
function tokenURI(uint256 tokenId)
public
view
override
returns (string memory)
{
require(_exists(tokenId), "Token does not exist.");
if (!isRevealed) {
return preRevealMetadata();
}
return
UnifriendsRenderer.base64TokenURI(
tokenId,
baseURI,
animationURI,
tokenIdToRandomNumber[tokenId]
);
}
Pseudo-randomness for properties for gas cost savings. Chainlink VRF was about 3x gas to run
function pseudorandom(address to, uint256 tokenId)
private
view
returns (uint256)
{
return
uint256(
keccak256(
abi.encodePacked(
block.difficulty,
block.timestamp,
to,
Strings.toString(mintNonce),
Strings.toString(tokenId)
)
)
);
}
}
Last updated