Skip to main content

Transformer

Transformer

Contract module that enables "transformation" of {ERC721OwlAttributes} tokens. The assumption with {ERC721OwlAttributes} is that the attributes of one individual token are encoded into a number, called "dna". This number is then mapped to the tokenId. Transforming configuration is set by one {Ingredient}[] (the inputs) and a {GeneMod}[] (the modifications). The inputs are the cost for the modifications to go through (as set by the contract deployer).

enum GeneTransformType {
none,
add,
sub,
mult,
set
}

struct GeneMod {
GeneTransformType geneTransformType;
uint256 value;
}

struct Ingredient {
TokenType token;
ConsumableType consumableType;
address contractAddr;
uint256[] amounts;
uint256[] tokenIds;
}

Once the {Ingredient}s in the inputs array have been used/consumed, the contract will update the "dna" associated with the tokenId submitted by the user. See {ERC721OwlAttributes} for an in-depth explanation of how "dna" encodes tokenId attributes.

version

string version

ERC165TAG

bytes4 ERC165TAG

Transform

event Transform(address nftAddr, uint256 tokenId, uint256 oldDna, uint256 newDna)

burnAddress

address burnAddress

inputs

struct PluginsCore.Ingredient[] inputs

nftAddr

address nftAddr

genes

uint8[] genes

modifications

struct TransformerCore.GeneMod[] modifications

initialize

function initialize(address _admin, address _burnAddress, struct PluginsCore.Ingredient[] _inputs, uint8[] _genes, struct TransformerCore.GeneMod[] _modifications, address _nftAddr, address _forwarder) external

Initializes contract (replaces constructor in proxy pattern)

NameTypeDescription
_adminaddressowner, no special permissions as of current release
_burnAddressaddressBurn address for burn inputs
_inputsstruct PluginsCore.Ingredient[]input ingredients for configuration
_genesuint8[]array denoting start location of genes within the 256 bit DNA
_modificationsstruct TransformerCore.GeneMod[]array denoting the modifications to be made upon each gene after transformation
_nftAddraddressthe address of the ERC721Owl contract
_forwarderaddresstrusted forwarder address for open GSN

proxyInitialize

function proxyInitialize(address _admin, address _burnAddress, struct PluginsCore.Ingredient[] _inputs, uint8[] _genes, struct TransformerCore.GeneMod[] _modifications, address _nftAddr, address _forwarder) external

Initializes contract through beacon proxy (replaces constructor in proxy pattern)

__Transformer_init

function __Transformer_init(address _admin, address _burnAddress, struct PluginsCore.Ingredient[] _inputs, uint8[] _genes, struct TransformerCore.GeneMod[] _modifications, address _nftAddr, address _forwarder) internal

performs validations that _inputs are valid and creates the configuration

__Transformer_init_unchained

function __Transformer_init_unchained(address _burnAddress, struct PluginsCore.Ingredient[] _inputs, uint8[] _genes, struct TransformerCore.GeneMod[] _modifications, address _nftAddr) internal

performs validations that _inputs and are valid and creates the configuration

transform

function transform(uint256 tokenId, uint256[][] _inputERC721Ids) external

the transformer instance from which this method is called from must have ERC721OwlAttributes DNA_ROLE

Used to transform. Consumes inputs and modifies DNA of inputted NFT token.

NameTypeDescription
tokenIduint256ID of NFT token to transform
_inputERC721Idsuint256[][]Array of pre-approved NFTs for crafting usage.

supportsInterface

function supportsInterface(bytes4 interfaceId) public view virtual returns (bool)

ERC165 Support

NameTypeDescription
interfaceIdbytes4hash of the interface testing for
NameTypeDescription
[0]boolbool whether interface is supported