Craftable Token
A general class of tokens that could be either Craftable Inputs or Outputs
How can a token become Craftable?
To make your ERC1155 become a craftable token, the contract for the token must:
Import the
craftable/CraftableIn.sol
and/orcraftable/CraftableOut.sol
Extend your token from either or both abstract classes. Depending on what you extend, your token can be used in different roles:
... is CraftableIn
This token can only be used as an input to future crafting rules others create.
... is CraftableOut
This token can only be used as an output from future crafting rules others create. This means that allowed crafting rules can mint from this token.
... is CraftableIn, CraftableOut
This token can be used as both inputs for some crafting rules and outputs for others. This represents a Fully Craftable Token.
Compose the Definition Metadata file and host it with a publicly accessible URI. The definition metadata will contain the necessary informations to other games and to the Craftware Crafting Web-app about the token attributes.
Implement the
virtual
functions from the inherited contracts you added. This is necessary to link the internal functionality of your tokens to the Crafting Protocol. Functions involve the defining how to read the attributes in order, generating the metadata URI for OpenSea, ...Updating the minting for your tokens to assign classes for them. (More on that here).
Deploy your token to the blockchain of choice.
What common functionality exist for a Craftable Token?
Both CraftableIn
and CraftableOut
inherit from a base contract CraftableBase
where functions necessary for both are defined.
Constructor
Any contract inheriting from one of the craftable must provide the URI for the Definition Metadata file they host. for example:
Classes
We propose a new dimension of ERC1155 tokens. We propose that each token minted in the ERC1155 contract should be assigned a class, so that tokens from the same class have the same attribute sets. This is important for crafting rules, because they need to know what is the set of attributes associated to a token.
For example, for an ERC1155 token contract clothes.sol
describing clothes in a game, it could mint hats and pants. But, hats have different attribute set (head_size, is_wool) than pants (length, material, size). As ERC1155 allows us perfectly to mint both in the same contract, we can assign all hats to class 1 and pants to class 2. If not, when a user inputs a token from clothes.sol
, we might not know whether it's a hat or pants and their attribute sets.
Classes are represented as lists
The class of the token is added automatically after minting it. for example:
Definition URIs
The definition URIs are essential to define the various classes and their required attributes. This allows other games, players, and the craftware web-app to understand the values for the attributes stored in lists.
Docs
Last updated