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.
- The Play-then-Sync model enables 60fps arcade gameplay by running the physics simulation client-side.
- The Sails framework automatically generates TypeScript SDKs to treat Rust smart contracts like standard microservices.
- Gear Protocol’s Actor Model allows for asynchronous state updates across multiple contracts without blocking game logic.
- Rust implementation uses saturating math to prevent integer underflows during rapid on-chain economic transactions.
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.
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.
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.
| Feature | v-starship (Actor Model) | Standard EVM Games |
|---|---|---|
| Execution | Asynchronous / Parallel | Sequential / Blocking |
| State Sync | Event-driven (Play-then-Sync) | Polling / Indexing |
| Developer Experience | Auto-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.