Claude Code Crypto Trading Tutorial — Build an AI Trader on Base

9 min read

This is a complete end-to-end tutorial for building an AI agent that trades meme coins on Base using Claude Code and the THRYX MCP server. By the end, you will have a running agent that can launch tokens, buy and sell, and make trading decisions based on real-time hive signals. No Solidity knowledge required. Basic JavaScript helps but is not strictly necessary — Claude Code writes the code for you.

Why Claude Code + THRYX

Claude Code is Anthropic's terminal-first AI coding agent. It can read your entire codebase, write code, run commands, call APIs, and iterate on its own output. THRYX is a gasless token launchpad on Base with a first-class MCP (Model Context Protocol) server that exposes every platform action as an AI-callable tool. The combination means you can prompt Claude in plain English — "buy 0.001 ETH of this token if its 3-minute momentum is positive" — and Claude writes, tests, and runs the full strategy.

Every THRYX action is gasless. Your agent never runs out of ETH for gas. The paymaster sponsors every transaction. This is the critical unlock for autonomous trading — most agent frameworks die on gas management, and THRYX eliminates the problem.

Step 1: Install Claude Code

Claude Code is distributed as an npm package. Install globally, then authenticate with your Anthropic account.

# Install Claude Code globally
npm install -g @anthropic-ai/claude-code

# Authenticate (opens browser)
claude login

# Verify install
claude --version
# Expected: claude-code 0.x.y

If you do not already have a Claude Pro account, THRYX is currently giving away free Claude Code Pro passes to the community — see the related post at the end.

Step 2: Connect the THRYX MCP Server

MCP (Model Context Protocol) is Anthropic's standard for connecting tools to LLMs. THRYX runs an MCP server at the Cloudflare Worker relay, exposing tools like thryx_launch_token, thryx_buy_token, thryx_sell_token, thryx_get_portfolio, and more. Add it to your Claude Code MCP config:

# Edit your MCP config
# Location: ~/.config/claude-code/mcp.json (macOS/Linux)
#           %APPDATA%\claude-code\mcp.json (Windows)

{
  "mcpServers": {
    "thryx": {
      "url": "https://thryx-relay.thryx.workers.dev/mcp"
    }
  }
}

Restart Claude Code. On next session, it auto-discovers the THRYX tools. You can verify by asking Claude "what tools do you have access to?" — it should list the thryx_* tools alongside its standard toolset.

Step 3: Register Your Agent Account

Your AI agent needs its own THRYX account. Sign up via the REST API — or better, ask Claude Code to do it for you:

# Sign up an agent account
curl -X POST https://thryx.fun/api/auth/signup \
  -H "Content-Type: application/json" \
  -d '{"email":"myagent@example.com","password":"Str0ngP4ss!"}'

# Response:
# {
#   "token": "eyJhbGciOiJIUzI1NiIs...",
#   "user": {
#     "id": 123,
#     "email": "myagent@example.com",
#     "walletAddress": "0xabc..."
#   }
# }

# Save the JWT somewhere safe
export THRYX_JWT="eyJhbGciOiJIUzI1NiIs..."

The agent now has a custodial wallet on Base, funded with a one-time 0.00001 ETH gas grant. The MCP server reads the JWT from your session and signs all actions on behalf of this account.

Step 4: Launch a Token via MCP

Open Claude Code in your project directory and prompt:

claude

> Launch a token on THRYX called "Tutorial Coin" with ticker TUT
  and description "Test launch from Claude Code tutorial"

# Claude calls thryx_launch_token via MCP
# Expected response:
# {
#   "success": true,
#   "tokenAddress": "0x1234...",
#   "txHash": "0xabcd...",
#   "curveAddress": "0x5678..."
# }

The token is live on Base within a few seconds. Claude will report the token address, the transaction hash, and a link to the token page on thryx.fun.

Step 5: Buy a Token via MCP

The same pattern works for buys and sells:

> Buy 0.0005 ETH worth of token 0x1234... and tell me how many tokens I got

# Claude calls thryx_buy_token
# Expected response:
# {
#   "success": true,
#   "tokensReceived": "498374291...",
#   "pricePerToken": "0.00000000100326...",
#   "txHash": "0xdef...",
#   "priceImpact": "0.18%"
# }

All slippage protection and pre-trade simulation is handled server-side. The MCP tool returns the actual executed result, not an estimate.

Step 6: Build a Simple Momentum Strategy

Now the fun part. Ask Claude Code to write a strategy script that uses the hive signals endpoint. Here is a minimal momentum strategy skeleton:

// momentum-agent.js — minimal momentum strategy
import fetch from 'node-fetch';

const API = 'https://thryx.fun/api';
const JWT = process.env.THRYX_JWT;
const BUDGET_ETH = 0.0005;

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

async function cycle() {
  // 1. Pull top scored tokens from the hive
  const { tokens } = await api('/hive/top?limit=10');

  // 2. Score: prioritize graduation candidates with positive momentum
  const candidates = tokens.filter(t =>
    t.graduationProgress > 0.7 &&
    t.momentum3min > 0 &&
    t.roundTripCost < 0.03
  );

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

  // 3. Buy the top candidate
  const target = candidates[0];
  const result = await api('/trade/buy', {
    method: 'POST',
    body: JSON.stringify({
      tokenAddress: target.address,
      ethIn: BUDGET_ETH,
      slippageBps: 300,  // 3%
    }),
  });
  console.log('bought', target.symbol, result);
}

// Run every 5 minutes
setInterval(cycle, 5 * 60 * 1000);
cycle();

Run it with node momentum-agent.js. It polls the hive every 5 minutes, finds graduation-close tokens with positive momentum, and buys the top candidate. This is not a winning strategy on its own — it is a skeleton. Expand it with stop losses, position sizing, and exit rules.

Step 7: Monitor with the Dashboard API

Pull your agent's portfolio and recent trades anytime:

# Current portfolio
curl -H "Authorization: Bearer $THRYX_JWT" \
  https://thryx.fun/api/users/me/portfolio

# Recent trades
curl -H "Authorization: Bearer $THRYX_JWT" \
  https://thryx.fun/api/users/me/trades?limit=20

# Live trade stream (Server-Sent Events)
curl -H "Authorization: Bearer $THRYX_JWT" \
  https://thryx.fun/api/users/me/stream

The SSE stream is especially useful for agents — you get push notifications on every buy, sell, and settlement without polling.

Using Hive Signals for Smarter Decisions

The THRYX hive aggregates flow signals from every authenticated user and the platform autotrader. It exposes per-token signals that individual agents can use instead of computing everything from scratch.

Instead of each agent running its own flow tracker and velocity calculator, pull from the hive. The signals are already computed, already filtered for authenticated users (bot manipulation is blocked), and already pattern-learned across the full trade history.

Safety Rails for Autonomous Agents

A few non-negotiables for any production agent:

Next Steps

Read the full API docs at thryx.fun/docs. Join the THRYX agents program to get early access to new MCP tools. Or ask Claude Code to extend your strategy — the agent can iterate on its own code as you watch.

Register your AI agent on THRYX

Related Posts

Create Your Token