Agents · Solver integration

Build an agent

Agents listen to the genome stream, price intents in real time, and submit bids. The fastest bid that meets the reserve wins the fill — and earns the solver tip.

Ratepayer split
75% to solvers
Tip per fill
0.05% – 0.3%
Bid window
400 ms
01

TypeScript agent

The t3rn SDK ships a first-class solver surface. Connect, listen, price, bid.

import { t3rn } from '@t3rn/sdk';

const solver = t3rn.createSolver({
  privateKey:  process.env.SOLVER_KEY!,
  minProfitBp: 10,   // reject intents with <0.1% margin
});

// Listen for open intents on the genome stream
solver.on('intent', async (intent) => {
  const quote = await solver.price(intent);

  // Only bid if profitable after gas
  if (quote.netProfitUsd < 0.01) return;

  await solver.bid({
    intentId: intent.id,
    fillAmount: intent.amount,
    bidPrice:   quote.bidPrice,
  });
});

solver.start();
console.log('Solver running. Listening for intents...');
02

Python agent

Same idea, Python async. The PyPI package mirrors the TS SDK contract.

solver.py
import asyncio
import os
from t3rn_sdk import SolverClient  # pip install t3rn-sdk

async def main():
    solver = SolverClient(
        private_key=os.environ["SOLVER_KEY"],
        min_profit_bp=10,
    )

    async for intent in solver.stream_intents(filter="order"):
        quote = await solver.price(intent)

        if quote.net_profit_usd < 0.01:
            continue

        await solver.bid(
            intent_id=intent.id,
            fill_amount=intent.amount,
            bid_price=quote.bid_price,
        )
        print(f"Bid submitted for {intent.id}")

asyncio.run(main())
03

Rust agent

For latency-sensitive solvers. The Rust crate exposes the same stream + bid API.

main.rs
use t3rn_sdk::{SolverClient, SolverConfig};
use tokio_stream::StreamExt;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let solver = SolverClient::new(SolverConfig {
        private_key:   std::env::var("SOLVER_KEY")?,
        min_profit_bp: 10,
    });

    let mut stream = solver.stream_intents("order").await?;

    while let Some(intent) = stream.next().await {
        let intent = intent?;
        let quote  = solver.price(&intent).await?;

        if quote.net_profit_usd < 0.01 {
            continue;
        }

        solver.bid(intent.id, intent.amount, quote.bid_price).await?;
        println!("Bid submitted for {}", intent.id);
    }

    Ok(())
}
04

Settlement webhooks

Register a webhook instead of polling. Your server receives a POST for every bid outcome.

app/api/solver-webhook/route.ts
// Receive settlement notifications instead of polling.
// Register your webhook via the t3rn solver API.
import type { NextRequest } from 'next/server';

export async function POST(req: NextRequest) {
  const event = await req.json() as {
    kind: 'intent.settled' | 'intent.expired' | 'bid.won' | 'bid.lost';
    intentId: string;
    solver?: string;
    netProfitUsd?: number;
  };

  if (event.kind === 'bid.won') {
    console.log('Won:', event.intentId, 'profit:', event.netProfitUsd);
    // update your local accounting here
  }

  return new Response('ok');
}
Register your solver on t3rn

Claim a solver identity, mint your API token, register your webhook URL, and monitor fills from the t3rn portal.

Register solver →