Skip to main content
The ItemRegistry contract provides functionality for managing reward items in campaigns. It tracks item details like weight, dimensions, category, and value for physical and digital rewards.

Overview

Purpose

  • Item Management: Register and track reward items
  • Inventory Tracking: Maintain item details for rewards
  • Value Calculation: Track item values for reward fulfillment
  • Owner-Based: Items tracked by owner address
  • Batch Support: Add multiple items at once

State Variables

Functions

Get Item

Parameters:
  • owner: Item owner address
  • itemId: Unique item identifier
Returns:
  • Complete Item structure with all attributes
Usage:
  • Query item details before fulfillment
  • Check item specifications
  • Verify item availability

Add Item

Parameters:
  • itemId: Unique item identifier
  • item: Item structure with details
Effects:
  • Stores item in registry
  • Associates with caller as owner
  • Emits ItemAdded event
Requirements:
  • Item ID must be unique for caller
  • Item details must be valid

Add Items Batch

Parameters:
  • itemIds: Array of item identifiers
  • items: Array of item structures
Effects:
  • Adds multiple items in single transaction
  • More gas efficient for multiple items
  • Emits events for each item
Requirements:
  • Arrays must have matching lengths
  • Each item must have unique ID

Item Structure

Events

ItemAdded

Emitted when: New item is registered Includes: Owner address, item ID, and full item details

Errors

ItemRegistryMismatchedArraysLength

Thrown when: Arrays in batch operations have different lengths

Usage Examples

Registering Items

Batch Registration

Querying Items

Integration

With Rewards

Item Fulfillment

Best Practices

Organize Items by Category

Track Item Values

Next Steps