Crafting Protocol
Combining on-chain tokens from many games to create on-chain tokens for other games.
Last updated
Was this helpful?
Combining on-chain tokens from many games to create on-chain tokens for other games.
Last updated
Was this helpful?
Crafting is the missing piece of cross-game collaboration and utilizing game tokens. The Crafting Protocol is a set of specifications, Smart Contracts, and interfaces that allow web3 games to join hands and collaborate on complex token swap deals. With the Crafting protocol, we aim to create accessible and scalable agreements on exchanging a set of tokens from many games to other tokens from other games.
In this protocol, we are targeting three stakeholders:
Input Web3 Tokens: Web3 Games with tokens to offload (Ingredients)
Output Web3 Tokens: Web3 Games that want to craft their tokens from other games (Outputs)
Players who want to engage in the play-to-earn scheme hoping to find a value in the tokens of game 1 by crafting corresponding tokens in game 2.
The motivations for these 3 parties can vary widely based on the use case.
So, we aim to provide a service that allows games to collaborate on defining a new crafting rule with
Ingredients: a set of tokens with diverse balances, attributes, and origin contracts.
Outputs: another set of such tokens from other games and contracts.
Mapping Method: an immutable, generic, scalable, accessible, and efficient manner to define the output balances and attributes based on the ingredients the player provides. We the quantities of interest are:
Attributes: A set of unique values that associate with a token ID. ex: sword length
, material
, ...
Balances: The quantity of such tokens. ex: 3 swords with the same attributes.
So, the mapping rule
takes as input the balances and attributes of ingredients and mints tokens with corresponding balances and attributes. for ex:
In this system, all partner games - posing as both ingredients and outputs - need to approve said crafting rule to authorize it to:
transfer player ingredient tokens
mint output tokens based on the immutable rules
Finally, the system should adhere to the security requirements that prevent members in the system of abusing power, trust, and timing problems.
Our system is an end-to-end suite of abstract contracts and interfaces from which any ERC1155 can be inherited. During the development of these components, we aimed to allow the most flexibility to games to define how their own tokens operate, while asking for minimal functions to manipulate and represent some of the entry points.
At the heart of the Crafting Protocol is our Abstract Smart Contracts and Interfaces
One of the requirements of the protocol is to be accessible to users (players and game managers). This requires an easy way for all parties to lookup what tokens does this ERC1155 contract provide and what are their attributes. While this is a relevant question for business applications, it is not necessary to store the "meaning" of attributes[0]
as "length of the sword" on-chain for scalability, generalizability, and storage efficiency. Similarly to how OpenSea requires a metadata file to make sense of the attributes of a certain token, we require a definition metadata file to make sense of the Craftable tokens.
Using the Craftable
abstract contracts -as mentioned- all tokens attributes are defined in an ordered list. The meaning of each attribute of the list is stored in a metadata file hosted somewhere accessible to parties but not necessarily on-chain. We call these descriptive files as Definitions.
Definitions are small JSON files that encapsulate the what matters for Games and Players.
For illustration purposes, this is the definition of a falafel ERC1155 Craftable token.
This tool will help you:
search and display craftable input and output contracts others deployed.
select from many methods of generating the crafting rule and mapping the attribute combinations of input tokens to output tokens. For example, we provide a spreadsheet approach, filters approach, etc...
preview the Crafting smart contract and deploy it.
This is just a basic example. To find more details about the types in the parameters for the function, the representation of attributes, ... Check
which takes lists of tokens the user owns from the ingredient contracts, maps the balances and attributes, and mints the tokens to the user.
We designed crafting to be reversible. At any time that you want to redeem the ingredients back to your wallet, call redeem
.
The game developers need to worry about three functions before deploying a crafting rule to enforce a standard method to interact with the contract
: To make sure the user inputs the tokens in a specified and agreed order.
: To make sure the user inputs the tokens in a specified and agreed order.
: The central function of the contract. In this function you write the mapping code to compute output attributes and balances from input attributes and balances.
The Craftable Input is an abstract contract with a set of functions and logic units that augment existing tokens to be consumable by the.
which must return the attribute value at a specific index as ordered in the file hosted for the token. (More about that in ).
(optional) function tokenURI( ... )
: an optional function to generate a URI for the token in alignment with the
Before moving forwards, we need to introduce the concept of a template. Tokens having the same attribute values are said to have the same template. For each template is associated an ID. (ex: Token #1 (length=2, width=3) and Token #2 (length=2, width=3) have the same template). Templates are important to optimize the storage of attribute lists for similar tokens.
CraftableOut._templateURI( ... )
: Given a template ID, returns the URI pointing to the Formatted JSON file containing the attributes and values. It is flexible for designers to point to external URIs if attributes are handled off-chain or for on-chain attribute storage.
Because we aim to make crafting rules accessible to all games, we offer a.