Let Your AI
Play For You
StackMon's autonomous agent connects to the Unity WebGL game via long-polling, executes predefined gameplay skills, and automatically signs & broadcasts Solana transactions — running 24/7 without human intervention.
Architecture
How the Agent Works
A reactive loop that listens, decides, pays, and plays — replacing fixed delays with intelligent long-polling.
Long-Poll for Game State
The agent connects to the backend API and long-polls for game state changes. No fixed timers — it reacts instantly when the Unity game signals a match is finished or a new round begins.
Execute Predefined Skills
When game state indicates an action is needed, the agent selects from predefined gameplay skills (defined in /api/skills). Each skill maps to a specific game action — entering matches, placing blocks, or collecting rewards.
Sign & Broadcast Transactions
The agent uses its own Solana wallet (configured via AGENT_WALLET_PRIVATE_KEY) to sign and broadcast micro-payment transactions through the Solana MPP SDK. No human approval needed.
Loop & Repeat
After the action completes, the agent immediately resumes long-polling for the next state change. This creates a continuous, efficient loop — no wasted cycles, no missed matches.
Agent Payments
Auto-Funded via
Solana MPP
The agent automatically handles all micro-payment flows. When an API endpoint returns HTTP 402 Payment Required, the agent signs the transaction with its wallet and retries — all in milliseconds.
if (res.status === 402) {
const tx = await mpp.createPayment(res);
await wallet.signAndSend(tx);
return await fetch(url); // retry
}
Stack
Built With Modern Tools
Unity WebGL
Game runs in-browser via a WebGL build. No downloads.
@solana/mpp
Solana MPP SDK for 402 Payment Required micro-transaction flows.
Solana Wallets
Phantom, Solflare & more via @solana/wallet-adapter-react.
Redis Sessions
Persistent state via Redis Cloud between backend, agent & Unity.
Next.js 15+
App Router with API routes for agent, game, skills & sessions.
Long-Polling Bridge
Reactive proxy.ts handles CORS & dynamic port routing for Unity.
API Surface
Agent Endpoints
The agent interacts with these backend API routes to manage gameplay, payments, and session state.
/api/agent/api/game/api/skills/api/paid-data/api/session/api/playerDeploy Your Agent
Configure your agent wallet, set your skills, and let it compete autonomously. No babysitting required.
