On-chain Inventory
Last updated
Last updated
The On-chain Inventory is a smart contract that enables players of web3 games to equip items onto their character NFTs.
As the name suggests, the On-chain Inventory exclusively tracks equipment on the blockchain, eliminating the need for off-chain metadata. This enhances the composability of game NFTs, allowing their state to be utilized not only by off-chain programs but also by smart contracts.
The Inventory has two user categories: administrators and players.
Administrators have the following abilities:
Defining inventory slots for an ERC721 contract (NFT collection).
Specifying the persistence of each slot, determining whether items can be unequipped from them.
Establishing the tokens that can be equipped in each slot.
Players can perform the following actions:
Equipping items into the inventory slots of the NFTs they own.
Unequipping items from their owned NFTs' inventory slots (with the exception of persistent slots).
When an item is equipped onto an NFT, ownership of the item is transferred to the inventory contract. This prevents the simultaneous use of item tokens by multiple entities. Additionally, if a player transfers an NFT to another player, the equipped items on that NFT are implicitly transferred to the new owner.
The Inventory contract is specifically designed for utilization in web3 games. If a game interprets inventory slots as holding character attributes in general, the Inventory can also be utilized to track aspects such as hit points, experience points, reputation, abilities, and skills, in addition to items and equipment.