petsy is a Sui Move smart contract module implementing a Tamagotchi-style on-chain pet system. Users can adopt, care for, train, and trade virtual pets using SUI coins and in-game currency. The module supports pet evolution, accessories, and a full marketplace for pets and items.
-
Pet Lifecycle
- Adopt up to 3 pets per user
- Feed, play with, exercise, rest, and work for coins
- Let pets sleep and wake them up
- Track stats: health, hunger, cleanliness, coins, experience, and maturity
- Evolve pets based on maturity and experience
-
Accessories
- Mint and equip accessories (glasses, hats, toys)
- Accessory effects are reflected visually on the pet
- Equip/unequip functionality
-
Marketplace
- List and buy pets and accessories
- Payments handled via SUI coins
- Event emission for listings and sales
-
Game Economy
- Coins can be purchased with SUI
- Experience points (XP) for pet actions
- Game balance constants define costs, gains, and stat changes
-
Events
PetAdopted,PetAction,PetEvolved,PetBredPetListed,PetSold,AccessoryListed,AccessorySoldCoinsPurchased
- ContractOwner – Tracks the module owner
- PetRegistry – Maps users to the number of pets they own
- Pet – Main pet object storing stats, game data, and personality
- PetAccessory – Accessories for pets
- PetStats & PetGameData – Stores pet health, hunger, cleanliness, coins, XP, and maturity
- PetListing & AccessoryListing – Objects for marketplace listings
adopt_pet– Adopt a new petfeed_pet– Feed a pet to restore hungerplay_with_pet– Play with a pet to increase XPexercise– Exercise a petrest– Rest to recover healthwork_for_coins– Earn coins via pet worklet_pet_sleep&wake_up_pet– Manage pet sleep and recoverytry_evolve– Evolve pets based on maturitymint_hat,mint_toy– Create accessorieslist_pet,buy_listed_pet,cancel_pet_listing– Marketplace operationslist_accessory,buy_listed_accessory,cancel_accessory_listingequip_accessory,unequip_accessory– Equip or unequip accessoriesbuy_coins_with_sui– Exchange SUI for in-game coins
get_pet_name,get_pet_health,get_pet_hunger,get_pet_maturityget_pet_coins,get_pet_xp,get_pet_personalityget_pet_stats,get_pet_game_datais_sleeping– Checks if a pet is currently sleeping
- Error codes for common validation failures (e.g., max pets reached, pet too tired)
- URLs for pet images at different stages of evolution and accessories
- Keys for dynamic fields (e.g., equipped item, evolution stage, sleep timestamp)
- Default game balance parameters for feeding, playing, working, resting, etc.
The module provides a test-only initializer:
#[test_only]
public fun init_for_testing(ctx: &mut TxContext) {
init(PETSY {}, ctx);
}