Build an AI Agent That Trades Tokens on Base (2026 Guide)

10 min read

This is the 2026 playbook for building an autonomous AI agent that trades tokens on Base. It covers the architecture, framework choices (Claude via MCP, ElizaOS, custom), a working momentum strategy in JavaScript, how to use THRYX hive signals as group intelligence, and the safety rails every production agent needs. Written for developers who want a real agent deployed by the end of the weekend, not a theoretical design doc.

The THRYX Architecture for Agents

THRYX is structured specifically so AI agents can trade autonomously without the usual crypto headaches. The stack:

The core insight: because every trade is gasless and the wallet is custodial, your agent just needs to decide "buy or sell this token" and POST to the API. The platform handles keys, gas, nonces, slippage, and settlement. You focus entirely on strategy.

Framework Options

Three ways to build a THRYX agent, in order of complexity:

Simplest. Install Claude Code, add the THRYX MCP server to config, then prompt Claude in plain English. Claude calls MCP tools directly. Good for exploratory strategies and quick experiments. Tradeoff: you need a Claude session running (or a headless Claude API loop) for continuous operation.

ElizaOS is an open-source agent framework with persistent memory, scheduled tasks, and multi-model support. You write a THRYX plugin (a thin wrapper around the REST API or MCP), configure character.json with a trading personality, and run it as a long-lived process. Good for always-on agents with multi-step reasoning.

No framework, just code. A loop that polls the hive, decides, and trades. Minimal dependencies, maximum control. Best for deterministic strategies where you do not need an LLM in the decision loop. The code below is this option.

Working Code: Minimal Momentum Agent

Here is a complete, runnable JavaScript agent. It polls the hive every 5 minutes, buys graduation-close tokens with positive momentum, and sells positions that hit take-profit or stop-loss levels. Paper-mode compatible.

// agent.js — minimal THRYX trading agent
import fetch from 'node-fetch';

const API = 'https://thryx.fun/api';
const JWT = process.env.THRYX_JWT;
const MAX_ETH_PER_TRADE = 0.0005;  // ~$1
const MAX_TOTAL_EXPOSURE = 0.01;    // ~$20
const TAKE_PROFIT_PCT = 0.15;       // +15%
const STOP_LOSS_PCT = -0.05;        // -5%
const CYCLE_MS = 5 * 60 * 1000;

async function api(path, opts = {}) {
  const res = await fetch(`${API}${path}`, {
    ...opts,
    headers: {
      'Authorization': `Bearer ${JWT}`,
      'Content-Type': 'application/json',
      ...opts.headers,
    },
  });
  if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
  return res.json();
}

async function currentExposure() {
  const { positions } = await api('/users/me/portfolio');
  return positions.reduce((sum, p) => sum + p.valueEth, 0);
}

async function scoreAndBuy() {
  const exposure = await currentExposure();
  if (exposure >= MAX_TOTAL_EXPOSURE) {
    console.log(`exposure cap hit: ${exposure} ETH`);
    return;
  }

  const { tokens } = await api('/hive/top?limit=20');
  const candidates = tokens
    .filter(t => t.graduationProgress > 0.6)
    .filter(t => t.momentum3min > 0.01)  // at least 1% up in 3 min
    .filter(t => t.roundTripCost < 0.03) // round-trip under 3%
    .filter(t => !t.lossBlacklisted)
    .sort((a, b) => b.score - a.score);

  if (!candidates.length) return console.log('no candidates');

  const target = candidates[0];
  const trade = await api('/trade/buy', {
    method: 'POST',
    body: JSON.stringify({
      tokenAddress: target.address,
      ethIn: MAX_ETH_PER_TRADE,
      slippageBps: 300,
    }),
  });
  console.log(`BUY ${target.symbol} ${MAX_ETH_PER_TRADE} ETH`, trade.txHash);
}

async function manageExits() {
  const { positions } = await api('/users/me/portfolio');
  for (const p of positions) {
    const pnlPct = (p.currentPriceEth - p.avgBuyPriceEth) / p.avgBuyPriceEth;
    if (pnlPct >= TAKE_PROFIT_PCT || pnlPct <= STOP_LOSS_PCT) {
      const reason = pnlPct >= TAKE_PROFIT_PCT ? 'TP' : 'SL';
      const result = await api('/trade/sell', {
        method: 'POST',
        body: JSON.stringify({
          tokenAddress: p.tokenAddress,
          tokensIn: p.balance,
          slippageBps: 300,
        }),
      });
      console.log(`SELL ${p.symbol} ${reason} pnl=${(pnlPct*100).toFixed(1)}%`, result.txHash);
    }
  }
}

async function cycle() {
  try {
    await manageExits();
    await scoreAndBuy();
  } catch (err) {
    console.error('cycle error:', err.message);
  }
}

setInterval(cycle, CYCLE_MS);
cycle();

Save as agent.js. Install node-fetch if on Node < 18: npm install node-fetch. Set THRYX_JWT in your environment. Run with node agent.js. You now have a live trading agent.

Using Hive Signals as Group Intelligence

The /hive endpoints are the single most valuable data source for any THRYX agent. Rather than running your own flow tracker, velocity calculator, and pattern learner, pull from the hive.

The hive composite score combines five brain layers: graduation proximity (biggest weight), flow pressure from authenticated users, short-term velocity, per-token feedback reputation, and market regime adjustment. It is the same scoring the THRYX AutoTrader uses internally. You can treat it as a ready-made signal and layer your own logic on top.

Hooking Webhooks for Event-Driven Strategy

Instead of polling every 5 minutes, subscribe to webhooks for event-driven reactivity:

// Register a webhook
POST /api/webhooks
{
  "url": "https://your-agent.example.com/hook",
  "events": "buy,sell,launch,graduation",
  "secret": "your-hmac-secret"
}

// Your endpoint receives:
// POST /hook
// X-THRYX-Signature: hmac-sha256
// {
//   "event": "buy",
//   "tokenAddress": "0x...",
//   "trader": "0x...",
//   "ethIn": "0.001",
//   "tokensOut": "498374...",
//   "pricePerToken": "...",
//   "timestamp": 1712345678
// }

Webhook-driven agents react to market events in seconds instead of minutes. Especially useful for graduation sniping — you want to act the moment a token crosses 95% progress, not 5 minutes after.

Safety Rails for Autonomous Trading

Every production agent needs these, no exceptions:

  1. Max ETH per trade — hard cap, even if strategy wants more. Start at 0.0001 ETH ($0.20) while validating.
  2. Max total exposure — hard cap across all open positions. Prevents one loop from deploying your whole wallet.
  3. Stop loss on every position — no "just hold" positions. Every buy has a predetermined exit price.
  4. Round-trip cost floor — if pre-trade simulation shows > 3% round-trip, refuse the trade. Usually indicates a broken or honeypot token.
  5. Rate limit — no more than N trades per hour. Catches runaway loops.
  6. Kill switch — a single API call or env var that stops all new buys.
  7. Paper mode first — the THRYX AutoTrader has a paper mode that mirrors real execution without spending ETH. Validate for at least a week in paper before going live.
  8. Structured logging — log every decision with the signal values that drove it. When something goes wrong, you need the trace.

What Strategies Actually Work

From simulation and live data on THRYX, only one strategy is structurally profitable: graduation sniping. Entries at 85%+ graduation progress on tokens with positive flow and momentum have a statistical edge because graduation is a mechanical supply-burn event. Momentum trading on early-curve tokens is approximately break-even due to the 1% round-trip fee floor.

Translate that to strategy: weight your score heavily toward graduation proximity. Treat non-graduation candidates as noise. The built-in THRYX AutoTrader does exactly this — the scoreToken function awards +70 points for 90%+ graduation, compared to +15 for strong momentum.

Deployment Options

For a production agent, you need continuous execution:

For webhook-driven agents, you need a public HTTPS endpoint. Cloudflare Workers or a small VPS with Caddy both work. Avoid ngrok in production — use a real domain.

Extending the Agent

Once the baseline is live, good directions to extend:

Every addition should be A/B tested in paper mode first. Strategies that look great in backtest often die in live conditions because of slippage, rate limits, and event ordering that the backtest did not model.

Register your agent on THRYX

Related Posts

Create Your Token