Skip to main content

Identity & Crafting Module

On-chain NFT identity, item crafting, achievement attestations, and dynamic metadata.


What This Module Does​

The Identity module is the bridge between off-chain gameplay and permanent on-chain ownership. It answers three questions that every blockchain game needs to answer:

  1. What does a player own? β€” MonsutaNFT.sol defines the NFT standard: upgradeable, batch-mintable, lockable, and royalty-aware.
  2. How do new items come into existence? β€” CraftingRecipes.sol defines the rules: players can forge new NFTs by combining existing ones, either entirely on-chain (trustless) or with server authorization (server-gated).
  3. What has a player accomplished? β€” AchievementsRegistry.sol records on-chain attestations that prove a player reached a milestone, completed a quest, or won a tournament.

The metadata router ties it together: token IDs encode their type mathematically, so traits are generated dynamically without a database lookup for every request.


Components​

ComponentDescriptionDoc
CraftingRecipe-driven item creation from NFT materialsCrafting β†’
AchievementsOn-chain achievement attestations with direct, batch, and server-gated issuanceAchievements β†’

Architecture​

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ GAME SERVER β”‚
β”‚ β”‚
β”‚ Player earns materials ────────── Player crafts item β”‚
β”‚ through gameplay (selects recipe) β”‚
β”‚ β”‚ β”‚ β”‚
β”‚ β”‚ (tracked off-chain) β”‚ β”‚
β”‚ β”‚ β–Ό β”‚
β”‚ β”‚ Server checks conditions β”‚
β”‚ β”‚ (XP, quest complete, etc.) β”‚
β”‚ β”‚ β”‚ β”‚
β”‚ β”‚ β–Ό β”‚
β”‚ Player reaches Server signs EIP-712 attestation β”‚
β”‚ achievement milestone β”‚ β”‚
β”‚ β”‚ β”‚ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚ β”‚
β”‚ (NFTs held in wallet) β–Ό
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ β”‚ CraftingRecipes.sol β”‚
β”‚ β”‚ β”‚
β”‚ β”‚ 1. Verify sig / recipeβ”‚
β”‚ β”‚ 2. Check NFT ownershipβ”‚
β–Ό β”‚ 3. Burn input NFTs β”‚
MonsutaNFT.sol ◄────────────│ 4. Mint output NFT β”‚
(owns the token IDs) β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ β”‚ AchievementsRegistry.sol β”‚
β”‚ β”‚ β”‚
β”‚ β”‚ 1. Verify issuer or signature β”‚
β”‚ β”‚ 2. Record achievement on-chainβ”‚
β”‚ β”‚ 3. Emit AchievementIssued β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β–Ό
Metadata Router (Railway)
GET /meta/{tokenId}.json
β†’ Dynamic traits via tokenId math

Token ID Design​

Token IDs carry their type identity mathematically:

tokenId = typeId Γ— 1,000,000 + serial

This means:

  • tokenId = 5 β†’ Base token, serial 5 (a Rock)
  • tokenId = 1_000_001 β†’ TypeId 1, serial 1 (first Marble Slab ever crafted)
  • tokenId = 2_000_047 β†’ TypeId 2, serial 47 (47th Tetra Goldium crafted)

The metadata router decodes this on every request β€” no database, no registry, no state to keep in sync. A new crafted type just needs a new typeId added to the config.


Crafting Modes​

CraftingRecipes.sol supports two modes that can be mixed across different recipes:

Trustless Crafting​

No server involvement. The recipe lives entirely on-chain.

  • Example: Burn 4 Rocks β†’ Receive 1 Marble Slab
  • Player approves the contract, calls craft(), done
  • No signature required, no server round-trip
  • Gas cost: ~220k (~0.002 AVAX at 10 gwei)

Server-Gated Crafting​

The game server authorizes the craft with an EIP-712 signature.

  • Example: Reach Level 20 + hold 3 Rare cards β†’ Receive 1 Legendary
  • Server checks off-chain conditions (XP, rank, quest state)
  • Server signs a Craft(player, recipeId, nonce, deadline) payload
  • Player submits the signature on-chain β€” contract verifies and executes
  • Conditions are defined and enforced by the game, not the contract

Both modes support two output types: MINT_ON_DEMAND (contract mints fresh) and PRE_MINTED (tokens queued and transferred FIFO).


Key Properties​

PropertyDetail
Non-custodialNFTs stay in player wallets β€” never locked in the crafting contract
Batch mintingmintBatch(address, uint256[]) β€” gas-optimized for bridging 100s of NFTs at once
LockableLOCK_MANAGER_ROLE allows staking and tournament contracts to lock tokens
UpgradeableUUPS proxy on all contracts β€” owners can upgrade without redeploying
Multi-minterMINTER_ROLE on MonsutaNFT supports bridge + crafting + future systems
EIP-712 replay protectionEach server signature has a nonce and deadline β€” cannot be reused
RoyaltiesERC-2981 royalty support built into MonsutaNFT
Achievement attestationsPermanent on-chain records with revocable/non-revocable modes

When to Use This Module​

Your SituationWhat You Need
Game has a crafting or item-forging mechanicCrafting
Game wants to reward milestones with on-chain proofAchievements
Game has tradeable items that players own permanentlyBoth
Game only has gameplay with no items or progression❌ Not needed