This module, stim_games::stim_games, establishes a decentralized game store, enabling publishers to sell game licenses and users to buy, store, and view their purchased licenses. Additional features like promo codes, fee management, and a licensing verification mechanism are built in, providing a comprehensive structure for managing a blockchain-based game store.
-
Platform: Represents the game platform, with attributes for owner, fee percentage, and accumulated revenue.
-
GameStore: A container for games and promotional codes, with features for owner management.
-
Game: Contains details of a game, including name, publisher, price, revenue, and a list of issued licenses.
-
UserAccount: Manages user-specific information such as balance and owned licenses.
-
License: Represents ownership of a purchased game, with details like purchase date and gifting information.
-
Discount: Details for promotional codes, including discount rate, expiry, and usage tracking.
- ENotOwner (0): Triggered when an action is attempted by a non-owner.
- EGameNotFound (1): Raised if a game is not found in the store.
- EUserNotFound (2): Raised when a user account is not found.
- EInsufficientFunds (3): Raised if the user lacks enough funds to purchase a license.
- EGameAlreadyExists (4): Raised when trying to add a game that already exists.
- EGameSoldOut (5): Raised when a game reaches its maximum licenses.
- EInvalidPromoCode (6): Raised if a promo code is invalid or expired.
-
initialize_platform: Initializes the platform with a set fee percentage for transactions. Only the platform owner can use this.
-
create_store: Creates a game store for managing games and promotional codes. The sender of the transaction becomes the store owner.
- create_user_account: Sets up a new user account for purchasing licenses.
-
add_game: Allows store owners to add new games, specifying name, price, description, and optional max licenses.
-
add_promo_code: Enables store owners to add promotional codes with defined discounts and usage restrictions.
- purchase_license: Manages the purchase of a game license, including promo code application, fund deduction, platform fees, and license issuance. Licenses are only issued if sufficient funds are available, and the game is not sold out.
-
view_user_licenses: Lists all licenses owned by the user.
-
view_license: Provides details of a specific license owned by the user.
- view_game_catalog: Displays all games available for purchase. Filters out sold-out games if
max_licensesis defined.
-
verify_license: Allows for the verification of a user’s license by the license holder.
-
withdraw_revenue: Enables the game publisher to withdraw accumulated revenue for a particular game.
-
Initialize Platform: Set up the platform with a fee percentage, enabling revenue collection for game sales.
-
Create Store: Owners create a store, which will manage the available games and promotional codes.
-
Add Games and Promo Codes: Owners add games with prices and descriptions. Promo codes may be added to incentivize purchases.
-
User Registration: Users create accounts to track their purchases and manage licenses.
-
Purchasing and Licensing: Users purchase licenses, with promo codes if available. Platform fees are automatically deducted and transferred to the platform’s revenue.
-
License Verification: Purchased licenses can be verified by the owner and store, ensuring authenticity and preventing unauthorized transfers.
- Decentralized Ownership: Owners have full control over store creation, game additions, and revenue withdrawal.
- Promotional Code System: Promo codes offer users discounts, which store owners can configure with usage limits and expiration.
- Revenue Collection and Fee Management: Platform fees are automatically collected on each purchase, providing a steady revenue stream for the platform.
- License Verification: Verifiable licenses increase transparency and trust, ensuring that only legitimate users access purchased content.
Dependencies:
- This module requires the
suiandcandidcrates for Sui blockchain interaction and data serialization.
get more info at dacade