NFT Contract

Verified Contract:
  • 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)
)
)
);
}
}
​