Skip to main content

Crafting Guide

This guide explains what crafting is within Web3 gaming and the different ways it can be achieved.


What is crafting?

Crafting in gaming refers to a game mechanic where players can combine or manipulate in-game assets, items, or resources to create new, more valuable, or unique items. It involves the process of taking various components or materials and using them to "craft" something else within the game world.

Here's how crafting works in Web3 gaming:

  1. Collecting Resources: Players typically start by gathering or acquiring various in-game resources, such as materials, ingredients, or items. These assets may exist as NFTs, ERC20 or off-chain local game assets (e.g. gold collected by playing the game).

  2. Crafting Recipes: Games often provide crafting recipes or blueprints that specify which combinations of resources are required to create a new item or upgrade an existing one. These recipes act as guidelines for players.

  3. Combining and Crafting: Players use their collected resources and follow the crafting recipe's instructions to create the desired item.

  4. Outcome: After successfully crafting, players receive the newly created item, which could be a weapon, armor, potion, accessory, or any other in-game asset. Crafting can also result in an existing item being upgraded to have more desirable qualities (i.e. Power Up). The outcome may also depend on chance, skill, or the quality of the resources used.

Crafting adds depth and complexity to Web3 games by allowing players to customize their gaming experience, experiment with item creation, and engage in resource management. It often encourages exploration, trading, and collaboration within the game's ecosystem, as players seek rare or valuable crafting materials and trade crafted items with other players.

How to craft

Crafting can occur in 2 ways:

  • Mint and Burn: This method involves creating a new asset with desirable metadata by collecting and burning other assets involved in the crafting operation. This method is recommended if the crafting process creates new assets that are significantly different from the ingredients required by the recipe (see tip below regarding tracking asset history). This method consumes more gas than the method below as it requires additional on-chain minting activity.

    In the below diagram the player is burning wood and nails to craft a new house asset.

Burn & Mint
  • Metadata Updates: This method entails upgrading an existing asset’s metadata by collecting additional assets. This process may or may not involve burning on-chain assets depending on the resources needed to upgrade the asset. This method is recommended if the crafting process upgrades an asset, or if a game’s economy is very sensitive to gas fees. In the below diagram the player has a regular sword and is burning fire. Their regular sword is upgraded to a fire sword due to having its metadata updated as part of the crafting process.Burn & Refresh
tip

Metadata updates evolves an asset allowing its historical activity to be tracked easily, as it retains the same token_id. This is particularly significant for games or players interested in tracing the history and upgrade lineage of an asset, ensuring a continuous and linked record.

Conversely, the mint and burn approach involves replacing an asset with a new token_id. This method complicates the process of tracking the asset's history, as each new iteration of the asset is assigned a different token_id, disrupting the continuity of its historical record.

-Mint and BurnMetadata Updates
Gas UsageMore than Metadata UpdatesLess than Mint and Burn
Crafting OutputGood for new items that are inherently different from original crafting ingredientsGood for transforming or evolving an item
Item HistoryLost due to items being burnt during the crafting processMaintained due to item being upgraded

Atomic transactions

tip

"Atomic" refers to a characteristic of transactions where all actions within a single transaction are executed entirely or not at all. This concept is crucial in blockchain and decentralized technologies to ensure the consistency and reliability of transactions.

A transaction is atomic when it executes in an all-or-nothing capacity. If a transaction contains multiple operations (like transferring tokens, executing smart contract functions, etc.), all these operations must succeed for the transaction to be considered valid. If any single operation fails, the entire transaction is reverted, and none of the operations take effect.

As crafting can consist of burning assets to create new (or upgrade existing) assets, it is important that the transactions required in the crafting process occur in an atomic manner, otherwise a player may not complete the process and lose assets.

If your crafting activity meets all of the following criteria crafting can be achieved via a contract function.

  • All crafting ingredients belong to the same collection
  • If minting is required, the newly minted asset from the crafting exercise belongs to the same collection as the crafting ingredients.
  • All crafting ingredients are owned by the same wallet

If your crafting activity meets any of the following criteria you will require the use of a multi-caller contract to achieve atomicity.

  • Any crafting ingredient belonging to a different collection than the others
  • If minting is required, the newly minted asset from the crafting exercise belongs to a different collection as the crafting ingredients.
  • Crafting ingredients are owned by different wallet
tip

An example of a crafting recipe utilizing a multi-caller contract for atomicity is as follows: e.g.

  • Burn water from Collection A
  • Burn fish from Collection A
  • Burn firewood from Collection B
  • Mint fish soup from Collection C

The multi-caller contract guarantees that all components are burnt and the new asset is minted within a single transaction. For instance, if firewood can't be burnt for any reason, the player won't lose their other assets in a failed crafting attempt. In contrast, without the multi-caller, there's a risk that water and fish could be burnt without successfully crafting fish soup.

For implementation of a multi-caller contract on the mainnet, it is mandatory to have the contract registered with Immutable's Operator Allowlist.

Should your project require a multi-caller contract for crafting purposes, please contact your Immutable account representative for assistance.

note

Immutable is currently developing an innovative crafting solution that eliminates the need for each game studio to implement their own multi-caller contract. This streamlined approach is designed to enhance efficiency and ease the integration process for our partners.

For detailed information about this upcoming solution and how it can benefit your operations, we encourage you to reach out to your Immutable account representative. Additionally, we invite you to revisit this page soon for further updates on this initiative.

Crafting and random asset generation

Crafting in blockchain transactions benefits from atomicity for optimal user experience and to minimize support issues. However, when randomness is involved in the asset creation process, directly linking asset sacrifice actions (like burns or transfers) to the asset creation response can present challenges.

Players must approve crafting transactions from their wallet. If the transaction reveals any details of the expected new asset resulting from the craft, players have the option to accept or reject it. Should the transaction details indicate an undesirable outcome, players may reject the transaction and attempt again, aiming for a more favorable result.

To prevent potential abuse by sophisticated players, it is advisable to separate the minting process from other crafting actions in these scenarios:

  • The quantity of assets to be minted is random.
  • The minted asset may originate from two or more collections.
  • Token IDs are sequential, enabling players to infer the desirability of an asset based on its ID.

For games with crafting mechanics that include these elements, it is recommended to continue fulfilling crafting recipes atomically as outlined in this guide. However, the minting activity should be conducted in a separate transaction to safeguard against exploitation of the crafting feature.