How Smart Contracts Work

Smart contracts are the "rules" of Citizen of Arcanis that run automatically on the blockchain. Think of them as a digital judge that never lies and never changes the rules.

What Are Smart Contracts?

Simple Explanation

Imagine a vending machine:

  1. You put money in

  2. You select a product

  3. The machine automatically gives you the product

  4. No human needed to operate it

Smart contracts work the same way:

  1. You perform an action in the game

  2. The smart contract checks if it's valid

  3. The contract automatically updates the game state

  4. No game company needed to approve it

In Citizen of Arcanis

Every action you take goes through smart contracts:

  • Creating your character

  • Fighting enemies

  • Trading items

  • Joining factions

Why Use Smart Contracts?

Trust and Transparency

  • No cheating: Rules can't be changed secretly

  • Always fair: Same rules apply to everyone

  • Transparent: Anyone can verify what happened

  • Permanent: Your achievements can't be deleted

True Ownership

  • Your items are really yours: Stored on blockchain, not company servers

  • Can't be taken away: No one can confiscate your items

  • Trade freely: Sell to anyone, anywhere

  • Keep forever: Items exist even if game company disappears

The Technology Stack

Starknet Blockchain

  • Fast: Quick transaction processing

  • Cheap: Low fees for game actions

  • Secure: Protected by advanced cryptography

  • Scalable: Can handle many players

Cairo Programming Language

  • Efficient: Uses less computational resources

  • Secure: Built-in safety features

  • Provable: Mathematical verification of correctness

Dojo Framework

  • Game-focused: Built specifically for blockchain games

  • Easy development: Simplifies smart contract creation

  • Optimized: Efficient for game mechanics

How Actions Work

Example: Attacking an Enemy

  1. You click "Attack" in the game interface

  2. Transaction sent to Starknet blockchain

  3. Smart contract receives your attack command

  4. Contract checks:

    • Do you have enough energy?

    • Are you in combat range?

    • What weapon are you using?

  5. Contract calculates damage based on your stats

  6. Contract updates:

    • Enemy's health

    • Your experience points

    • Any item drops

  7. Result displayed in the game interface

Example: Trading an Item

  1. You list item for sale on marketplace

  2. Smart contract creates a trade offer

  3. Another player accepts the trade

  4. Contract automatically:

    • Transfers item to buyer

    • Transfers payment to seller

    • Updates ownership records

  5. Trade completed without any middleman

Game State on Blockchain

What's Stored

Every important piece of game data lives on the blockchain:

Character Data

  • Health, attack, defense stats

  • Experience points and level

  • Faction membership

  • Location in game world

Item Data

  • What items you own

  • Item stats and rarity

  • Item history and previous owners

Game Events

  • Combat results

  • Trading history

  • Quest completions

  • Faction activities

Data Structure

Player {
  id: unique_identifier
  health: current_health_points
  attack: attack_power
  defense: defense_rating
  experience: total_experience
  faction: chosen_faction
}

Item {
  id: unique_item_identifier
  owner: player_who_owns_it
  item_type: weapon/armor/vehicle/pet
  rarity: common/rare/epic/legendary
  stats: specific_item_bonuses
}

Benefits for Players

Permanent Ownership

  • Items stored on blockchain forever

  • Can't be accidentally deleted

  • Survive game updates and changes

Transparent Economy

  • See all market transactions

  • Verify item authenticity

  • Track market trends and prices

Cross-Game Potential

  • Items could work in other games

  • Build reputation across platforms

  • Investments have lasting value

Community Control

  • Players can verify game fairness

  • Community can propose changes

  • Democratic governance possible

For Non-Technical Players

You don't need to understand the technical details to play! The game interface handles all the complex blockchain interactions. You just:

  1. Connect your wallet (like logging in)

  2. Play the game normally

  3. Your actions automatically use smart contracts

  4. Enjoy true ownership of your achievements

Think of it like using email - you don't need to understand internet protocols to send messages, but the technology makes it possible for your emails to reach anyone in the world securely.

Last updated