Home/AI Agents
Autonomous Agent Mode

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.

SIGN TX
PLAY BLOCK

Architecture

How the Agent Works

A reactive loop that listens, decides, pays, and plays — replacing fixed delays with intelligent long-polling.

01

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.

/api/game — returns state via long-polling
02

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.

/api/skills — structured skill definitions
03

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.

agent-mpp.ts — auto-signs via @solana/mpp
04

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.

Reactive loop — zero downtime
AGENT
1. GET /api/game
2. HTTP 402 REQ
3. MPP TX SIGNED
BACKEND

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.

// agent-mpp.ts — payment flow
if (res.status === 402) {
  const tx = await mpp.createPayment(res);
  await wallet.signAndSend(tx);
  return await fetch(url); // retry
}
Private key never leaves the server
Devnet SOL — zero real money risk
Micro-transactions per action, not subscriptions

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.

POST/api/agent
GET/api/game
GET/api/skills
GET/api/paid-data
GET/api/session
GET/api/player

Deploy Your Agent

Configure your agent wallet, set your skills, and let it compete autonomously. No babysitting required.