generator.sol

The Generator Contract

The purpose of the generator contract is to generate the dynamic NFT with all its attributes and SVG artwork. The data function in the generator contract is intended to be called by the factory contract's uri() function which is a feature of the ERC1155 standard.

Solidity API

IExtendedERC20

name

function name() external view returns (string)

symbol

function symbol() external view returns (string)

IFactory

vaults

function vaults(uint256 tokenId) external view returns (address)

Generator

factory

contract IFactory factory

_chainSymbol

string _chainSymbol

TokenUrlPrefixUpdated

event TokenUrlPrefixUpdated(string oldPrefix, string newPrefix)

constructor

constructor(string chainSymbol, string tokenUrlPrefix, address _factory) public

data

function data(uint256 tokenId) external view returns (string)

this returns the dynamic metadata for the erc1155 token

this should be called by the overriden erc1155 uri function in the factory contract

setTokenUrlPrefix

function setTokenUrlPrefix(string tokenUrlPrefix) external

this will display in NFT metadata

_generateAttributes

function _generateAttributes(struct IVault.Attr attributes, address receiveAddress, uint256 percent, uint256 balance) internal view returns (string)

_generateSVG

function _generateSVG(uint256 percent) internal pure returns (bytes)

_generatePaths

function _generatePaths(uint256 percentage) internal pure returns (string pathsString)

_getBalance

function _getBalance(contract IVault vault) internal view returns (uint256)

_getPercent

function _getPercent(contract IVault vault, uint256 balance) internal view returns (uint256 percentage)

calculates the percentage towards unlock based on time and target balance

_uint2str

function _uint2str(uint256 _i) internal pure returns (string _uintAsString)

_toAsciiString

function _toAsciiString(address x) internal pure returns (string)

_char

function _char(bytes1 b) internal pure returns (bytes1 c)

_convertWeiToEthString

function _convertWeiToEthString(uint256 weiValue) internal pure returns (string)

_insertCharAtIndex

function _insertCharAtIndex(string str, uint256 index, bytes1 newChar) internal pure returns (string)

IGenerator

data

function data(uint256 tokenId) external view returns (string)