v-starship: The Actor Model Goes to War

How Gear’s Sails framework turns the blockchain into a high-speed backend for real-time arcade dogfights.

• View on GitHub • More from gear-foundation

A detailed illustration of a starship mid-warp, its exhaust transforming into cascading lines of code and hexagonal blockchain cells.
v-starship treats a Rust smart contract like a high-speed microservice.

Key Takeaways

The "Game Feel" Paradox

The holy grail of blockchain gaming has always been real-time, high-fidelity action that doesn't sacrifice decentralization. Most "Web3 games" are glorified spreadsheets or turn-based card games because block latency kills the "game feel." It is difficult to dodge a laser beam when every movement requires a sequential state transition on a distributed ledger.

v-starship is the counter-argument. Built by the Gear Foundation, it leverages the Gear Protocol’s Actor Model and the Sails framework to treat a smart contract like a high-speed microservice. The result is a space shooter that runs at 60 frames per second in the browser while securely committing state and economic data to the chain.

Breaking the Latency Barrier

To achieve arcade-style immediacy, v-starship employs a "Play-then-Sync" model. The heavy lifting of the 60fps action happens entirely client-side. The game engine, built in React, uses custom hooks like use-fps.ts and use-keyboard-controls.ts to maintain a local simulation.

Instead of triggering actions on keypress, the input handler updates a reference representing X and Y intensity. This allows for smooth, diagonal movement and prevents the stutter associated with OS-level repeat delays. The local simulation only "reports" to the blockchain at critical state transitions—like a game over or a level completion.

The Play-then-Sync model decouples the real-time game loop from the blockchain state transition.

Sails: Smart Contracts as Services

The secret sauce connecting the high-speed frontend to the blockchain backend is the Sails framework. Sails abstracts the low-level Gear Protocol actor model into a more familiar service-oriented architecture.

Inside the contract/ directory, Rust code defines the game's rules. Sails then generates a TypeScript SDK (api/sails/programs/starship.ts) that acts as a client-side mirror. This allows frontend developers to call methods like add_points or usePlayer as if they were standard REST or GraphQL endpoints.

An illustration of a ship's mast where the rigging ropes are Ethernet cables connecting a glowing anchor to a floating hologram.
The Sails framework bridges the Rust backend and the TypeScript frontend with generated SDKs.

The Physics of the Actor Model

Unlike the Ethereum Virtual Machine (EVM), which executes transactions sequentially in a global state, the Gear Protocol uses the Actor Model. This allows for parallel, asynchronous messaging.

When a player finishes a run, the Starship program can send messages to an NFT contract (representing the ship) and a VFT contract (representing fungible tokens or points) simultaneously. This asynchronous nature prevents "Daily Resets" and "Token Exchanges" from blocking the main game logic.

From Sprites to Assets

The ship in v-starship isn't just a sprite; it’s an on-chain identity. The game integrates NFTs directly into the progression system. A "Showroom" component provides a direct link to an external address, bridging the gameplay experience with the broader Vara network ecosystem.

To manage this economy safely, the Rust contract relies heavily on "Saturating Math" (e.g., saturating_sub). This prevents integer underflow panics—a critical safety pattern when boosters and points are being spent rapidly.

A close-up of a mechanical counter hitting zero and physically locking with an iron bar to prevent rolling back.
Saturating math prevents integer underflows, protecting the on-chain economy.
Featurev-starship (Actor Model)Standard EVM Games
ExecutionAsynchronous / ParallelSequential / Blocking
State SyncEvent-driven (Play-then-Sync)Polling / Indexing
Developer ExperienceAuto-generated SDKs (Sails)Manual ABI management

v-starship proves that blockchain games don't have to feel like interacting with a database. By delegating the demanding loop to the client and utilizing an asynchronous, actor-based backend, it bridges the gap between Web2 arcade action and Web3 ownership.