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:
- What does a player own? β
MonsutaNFT.soldefines the NFT standard: upgradeable, batch-mintable, lockable, and royalty-aware. - How do new items come into existence? β
CraftingRecipes.soldefines the rules: players can forge new NFTs by combining existing ones, either entirely on-chain (trustless) or with server authorization (server-gated). - What has a player accomplished? β
AchievementsRegistry.solrecords 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β
| Component | Description | Doc |
|---|---|---|
| Crafting | Recipe-driven item creation from NFT materials | Crafting β |
| Achievements | On-chain achievement attestations with direct, batch, and server-gated issuance | Achievements β |
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β
| Property | Detail |
|---|---|
| Non-custodial | NFTs stay in player wallets β never locked in the crafting contract |
| Batch minting | mintBatch(address, uint256[]) β gas-optimized for bridging 100s of NFTs at once |
| Lockable | LOCK_MANAGER_ROLE allows staking and tournament contracts to lock tokens |
| Upgradeable | UUPS proxy on all contracts β owners can upgrade without redeploying |
| Multi-minter | MINTER_ROLE on MonsutaNFT supports bridge + crafting + future systems |
| EIP-712 replay protection | Each server signature has a nonce and deadline β cannot be reused |
| Royalties | ERC-2981 royalty support built into MonsutaNFT |
| Achievement attestations | Permanent on-chain records with revocable/non-revocable modes |
When to Use This Moduleβ
| Your Situation | What You Need |
|---|---|
| Game has a crafting or item-forging mechanic | Crafting |
| Game wants to reward milestones with on-chain proof | Achievements |
| Game has tradeable items that players own permanently | Both |
| Game only has gameplay with no items or progression | β Not needed |