Skip to main content

CrafterCore

CrafterCore​

Base contract that all Crafter contracts will inherit from

Create​

event Create(address creator, struct PluginsCore.Ingredient[] inputs, struct PluginsCore.Ingredient[] outputs)

Update​

event Update(uint256 craftableAmount)

Craft​

event Craft(uint256 craftedAmount, uint256 craftableAmount, address user)

burnAddress​

address burnAddress

craftableAmount​

uint96 craftableAmount

inputs​

struct PluginsCore.Ingredient[] inputs

outputs​

struct PluginsCore.Ingredient[] outputs

__CrafterCore_init​

function __CrafterCore_init(address _admin, address _burnAddress, struct PluginsCore.Ingredient[] _inputs, struct PluginsCore.Ingredient[] _outputs, address _forwarder) internal

performs validations that _inputs and _outputs are valid and creates the configuration

__CrafterCore_init_unchained​

function __CrafterCore_init_unchained(address _burnAddress, struct PluginsCore.Ingredient[] _inputs, struct PluginsCore.Ingredient[] _outputs) internal

performs validations that _inputs and _outputs are valid and creates the configuration

getInputs​

function getInputs() public view returns (struct PluginsCore.Ingredient[] _inputs)

Returns all inputs (without amounts or tokenIds)

getOutputs​

function getOutputs() public view returns (struct PluginsCore.Ingredient[] _outputs)

Returns all outputs (without amounts or tokenIds)

getInputIngredient​

function getInputIngredient(uint256 index) public view returns (enum PluginsCore.TokenType token, enum PluginsCore.ConsumableType consumableType, address contractAddr, uint256[] amounts, uint256[] tokenIds)

Returns all details for a specific ingredient (including amounts/tokenIds)

NameTypeDescription
indexuint256ingredient index to return details for
NameTypeDescription
tokenenum PluginsCore.TokenTypetoken type
consumableTypeenum PluginsCore.ConsumableTypeconsumable type
contractAddraddresstoken contract address
amountsuint256[]amount of each token
tokenIdsuint256[]token ids

getOutputIngredient​

function getOutputIngredient(uint256 index) public view returns (enum PluginsCore.TokenType token, enum PluginsCore.ConsumableType consumableType, address contractAddr, uint256[] amounts, uint256[] tokenIds)

Returns all details for a specific ingredient (including amounts/tokenIds)

NameTypeDescription
indexuint256ingredient index to return details for
NameTypeDescription
tokenenum PluginsCore.TokenTypetoken type
consumableTypeenum PluginsCore.ConsumableTypeconsumable type
contractAddraddresstoken contract address
amountsuint256[]amount of each token
tokenIdsuint256[]token ids

_validateInputs​

function _validateInputs(struct PluginsCore.Ingredient[] _inputs) internal

calls PluginsCore._validateInputs(_inputs, inputs)

_useInputs​

function _useInputs(uint256[][] _inputERC721Ids, uint256 amount) internal

call PluginsCore._useInputs(inputs, from, burnAddress, _inputERC721Ids, amount)

_validateOutputs​

function _validateOutputs(struct PluginsCore.Ingredient[] _outputs, uint256 _craftableAmount) internal returns (uint256)

validates outputs array of ingredients

NameTypeDescription
_outputsstruct PluginsCore.Ingredient[]the output array of the Crafter initializer
_craftableAmountuint256the amount of times the recipe may be crafted

_createOutputsArr​

function _createOutputsArr(struct PluginsCore.Ingredient[] _outputs, uint256 _craftableAmount, uint256 erc721Amount) internal pure returns (uint256[][])

Creating a static 2d array

NameTypeDescription
_outputsstruct PluginsCore.Ingredient[]the output array of the Crafter initializer
_craftableAmountuint256the amount of times the recipe may be crafted
erc721Amountuint256the number of erc721 tokens to be used as output

_addOutputs​

function _addOutputs(uint256 amount, uint256[][] _outputsERC721Ids, address from) internal virtual

function must be overriden by child contract. Adding process is too different between the contract for abstraction

NameTypeDescription
amountuint256sets of outputs to deposit
_outputsERC721Idsuint256[][]erc721 tokenIds to use as outputs
fromaddressif transferring, address to transfer outputs from

_removeOutputs​

function _removeOutputs(uint96 amount, address to) internal virtual

function must be overriden by child contract. Removal process is too different between the contracts for abstraction

NameTypeDescription
amountuint96sets of outputs to remove
toaddressaddress to send outputs to

__gap​

uint256[46] __gap