numericTraitsabout the Aavegotchi, and other details. But unlike many NFT games, we actually store all of the SVG files themselves onchain.
_svgargument holds one or more SVG images as strings. It is more gas-efficient for
_svgto contain multiple SVG images because
_svgis stored as the entire contents of a contract. Creating a new contract has an up-front fixed gas cost of 32,000.
_typesAndSizesis used to say what category the SVG images are and contains size information so the
_svgdata can be broken into multiple SVG images.
svgTypespecifies the category of SVG images in
_svg. Each SVG category has SVG images with unique incrementing identifiers that start at 0. SVG categories are used to distinguish different groups of SVG images. Here are SVG categories:
storeSvgfunction above calls the following function to actually store the
_svgargument as contract data:
storeSvgInContractcontains the bytecode of a contract constructor function that returns data as a contract.
storeSvgInContractuses the constructor function to create a contract consisting of
_svgand returns the Ethereum address.
getSvg(bytes32 _svgType, uint256 _id)internal function from
LibSvg.solto get SVG data.
_svgTypeis the SVG category.
_idis the unique id of an SVG image.
function previewAavegotchi(hauntId, collateralAddress, numericTraits, equippedWearables)
hauntIdrefers to the minting events of new Aavegotchi's, which increments from zero, so Haunt 1 is
hauntId = 0. Different "haunts" have different varieties to their designs such as the collateral type and eye shape. The expected argument is a whole integer, for example supplying
0is used to produce Aavegotchi's with Haunt 1 collateral / eye shapes available.
collateralAddressis equal to the token collateral's address that would be used to stake the Aavegotchi which further determines the color and style of its features. The expected argument is a string, such as
0x9719d867a500ef117cc201206b8ab51e794d3f82which is the maUSDC address Polygon.
numericTraits: int16is an array of 6 traits from 0-100 for newly-summoned Aavegotchis, the last two values in the array determine some visual features like eye shape and color. The expected format is an array of whole integers such as
[ 1, 10, 50, 99, 0, 1]
equippedWearables: int16indicated equipped items on the Aavegotchi by matching the svgId to the index of the array, if the svgId is zero then the slot has nothing equipped. The index of the item in the array determines what slot is matches, for example
[ 0, 0, 0, 43, 0, 0, 0, 0, 0, 0, 0, 0, 0]produces a character with only a santa hat because the svgId of Santa Hat is 43, and the HEAD slot corresponds to the third index of the equippedWearables array.
<img>element so it can be viewed in a browser.