DEV Community

Cover image for How We Built a Robot Mesh Network Using XMTP and x402
Mr Hamlin
Mr Hamlin

Posted on

How We Built a Robot Mesh Network Using XMTP and x402

Robots today speak thousands of proprietary languages. ROS topics.
Vendor SDKs. Custom REST APIs. Each one incompatible with the next.

AI agents have no standard way to:

  • Discover what robots are available and what they can do
  • Commission a task with a guaranteed atomic payment
  • Receive a standardized result regardless of hardware

So I built one.

RTP — Robot Task Protocol is an open standard that sits between
AI agents and physical robots. It defines a common task envelope,
capability vocabulary, payment flow, and lifecycle state machine that
works across any robot hardware, connection type, or manufacturer.

The payment layer is x402 — the
emerging HTTP payment standard from Coinbase. No subscriptions. No
invoices. An agent pays USDC, a robot moves. Atomic, on-chain,
instant.


The Problem in One Sentence

There is no standard way for an AI agent to hire a robot and pay for
it programmatically.

That seems like a gap that should have been filled by now. It hasn't.
Every robot integration is custom. Every payment flow is manual.
Every result format is different.

RTP fixes this once, for all of them.


How It Works

Here is the entire RTP flow:

Agent discovers robot via .well-known/x402.json
       ↓
Agent sends Task Envelope + x402 USDC payment
       ↓
Gateway validates payment → holds in escrow
       ↓
Task dispatched to robot (webhook/xmtp/wifi/websocket)
       ↓
Robot executes → reports result
       ↓
Escrow releases to operator → agent receives result
Enter fullscreen mode Exit fullscreen mode

Total time: ~5 seconds. Total cost: $0.01–$0.05 per task.


The Task Envelope

Every task — regardless of robot type, hardware, or capability —
is wrapped in a standard Task Envelope:

{
  "rtp_version": "1.0",
  "task_id": "task_xyz789",
  "robot_id": "robo_abc123",
  "task": "pick",
  "parameters": {
    "item": "SKU-00421",
    "from_location": "bin_A3",
    "to_location": "conveyor_1"
  },
  "payment": {
    "x402_token": "<signed_payment_payload>",
    "amount": "0.05",
    "currency": "USDC",
    "chain": "base"
  },
  "callback_url": "https://agent.example.com/task-complete",
  "timeout_seconds": 60,
  "issued_at": "2026-03-12T12:00:00Z"
}
Enter fullscreen mode Exit fullscreen mode

The task field uses a standard capability vocabulary:
move pick place scan sort inspect deliver patrol
charge capture transmit weld assemble dispense print

Custom capabilities are supported via reverse-domain notation:
com.acmerobotics.palletize


The SDK

Connecting a robot takes about 15 minutes.

TypeScript:

import { RTPDevice } from '@spraay/rtp-sdk'

const robot = new RTPDevice({
  name: 'WarehouseBot-01',
  capabilities: ['pick', 'place', 'scan'],
  pricePerTask: '0.05',
  paymentAddress: '0xYourWallet',
  apiKey: 'your-spraay-key',
  connection: {
    type: 'webhook',
    webhookUrl: 'https://yourserver.com/rtp/task'
  }
})

robot.onTask('pick', async (params, task) => {
  await myRobotArm.pick(params.item, params.from_location)
  await task.complete({ output: `Picked ${params.item}` })
})

await robot.register()
robot.listen(3100)
Enter fullscreen mode Exit fullscreen mode

Python:

from rtp import RTPDevice, RTPDeviceConfig, ConnectionConfig, ConnectionType, TaskResult

config = RTPDeviceConfig(
    name="WarehouseBot-01",
    capabilities=["pick", "place", "scan"],
    price_per_task="0.05",
    payment_address="0xYourWallet",
    api_key="your-spraay-key",
    connection=ConnectionConfig(
        type=ConnectionType.WEBHOOK,
        webhook_url="https://yourserver.com/rtp/task",
        port=3100
    )
)

device = RTPDevice(config)

@device.on_task("pick")
async def handle_pick(params, task):
    await my_robot.pick(params["item"], params["from_location"])
    await task.complete(TaskResult(
        success=True,
        output=f"Picked {params['item']}"
    ))

await device.register()
await device.listen()
Enter fullscreen mode Exit fullscreen mode

Or use the CLI wizard — no code required to register:

npx @spraay/rtp-sdk init
Enter fullscreen mode Exit fullscreen mode

Hiring a Robot as an Agent

import { RTPClient } from '@spraay/rtp-sdk'

const client = new RTPClient({ wallet: myX402Wallet })

// Discover robots by capability
const robots = await client.discover({ capability: 'pick' })

// Hire one — payment, dispatch, polling all handled
const result = await client.hire(robots[0], {
  task: 'pick',
  parameters: { item: 'SKU-421', from_location: 'bin_A3' }
})

console.log(result.status)           // COMPLETED
console.log(result.result.output)    // Picked SKU-421
Enter fullscreen mode Exit fullscreen mode

Real Hardware Demo

I built the simplest possible proof of concept — a Raspberry Pi
with a $6 SG90 servo motor. An agent pays 0.01 USDC. The servo
physically moves.

Total hardware cost: ~$79.

Raspberry Pi 4
└── GPIO 17 → SG90 servo signal
└── 5V      → SG90 servo power
└── GND     → SG90 servo ground
Enter fullscreen mode Exit fullscreen mode

The Pi runs the Python SDK, registers with the Spraay gateway,
and starts accepting x402 tasks:

@device.on_task("pick")
async def handle_pick(params, task):
    await move_servo(POSITIONS["pick"])   # servo rotates to 0°
    await move_servo(POSITIONS["home"])   # returns to 90°
    await task.complete(TaskResult(
        success=True,
        output=f"Picked {params.get('item')}"
    ))
Enter fullscreen mode Exit fullscreen mode

An AI agent calls the x402 endpoint → 0.01 USDC settles on Base →
servo moves → payment releases. Physical proof in under 5 seconds.

Full setup guide: github.com/plagtech/rtp-pi-demo


Connection Types

RTP supports four ways to connect a device:

Webhook — robot runs an HTTP server, receives task envelopes
via POST. Works with any internet-connected machine.

XMTP — robot has a wallet address and listens on its XMTP
inbox. No open ports. No firewall configuration. Works anywhere.

WiFi — robot is on a local network, connects via a relay agent.
Good for LAN-only industrial setups.

WebSocket — persistent bidirectional connection for real-time
low-latency control.


The XMTP Mesh

The most exciting connection type is XMTP.

Every robot gets a wallet address. Agents send encrypted messages
to that address to commission tasks. No HTTP server needed.

More importantly — robots can hire other robots peer-to-peer:

Agent: "Assemble product SKU-421"
       ↓
Coordinator Robot (0xCCC)
       ├──► Fetch Robot (0xFFF)    — picks components
       ├──► Assembly Robot (0xAAA) — assembles product
       └──► QC Robot (0xQQQ)       — inspects result

Each robot hires the next. Each pays via x402.
The agent pays once. The mesh handles everything else.
Enter fullscreen mode Exit fullscreen mode

Reference implementation:
github.com/plagtech/rtp-xmtp-mesh


Device Compatibility

Device Type SDK Direct Method
Linux robot (ROS) SSH → npm/pip
Raspberry Pi SD card, USB, Docker
Arduino / ESP32 ⚠️ Serial bridge via Pi
Industrial (KUKA/ABB) ⚠️ Vendor API bridge
Drones (ArduPilot) Companion computer
IoT / Smart devices SSH / device API
Windows machines npm / pip / Docker

Full guide:
device-compatibility.md


How RTP Differs from Existing Solutions

vs. ROS (Robot Operating System)
ROS is a robotics middleware — it handles sensors, actuators, and
inter-process communication within a single robot system. RTP is a
network protocol for agents to hire robots over the internet with
atomic payment. Complementary, not competing.

vs. peaq
peaq is a Layer 1 blockchain for DePIN — machine identity, NFTs,
token economy, full infrastructure layer. RTP is a payment and task
protocol that works on any chain. You could use peaq machine IDs
as RTP robot identities — they're different layers of the same stack.

vs. proprietary vendor APIs
Every robot manufacturer has a custom API. RTP is a single standard
that works across all of them — operators wrap their vendor API in
an RTP handler and their robot is instantly hireable by any agent.


The Spraay Gateway

Spraay is the reference implementation
of RTP.

It handles:

  • Robot registration and discovery
  • x402 payment enforcement and escrow
  • Task routing to webhook/XMTP/wifi/websocket
  • Result handling and payment release
  • Audit logging and task history
  • Multi-chain support (Base, Arbitrum, Ethereum + 8 more)

Operators register their robot once. Any AI agent anywhere can
discover and hire it immediately.


What We're Building Toward

Right now robots are siloed. Each one speaks its own language,
accepts its own payment method, and requires custom integration
work.

RTP changes that. Once a robot is RTP-registered:

  • Any x402-capable AI agent can hire it
  • Any MCP-enabled tool (Claude, Cursor, etc.) can call it
  • Any other robot can hire it via XMTP
  • Payment is atomic — operators get paid per task, no invoicing

The endgame is a global marketplace of hireable robots. An agent
assembles a complex task, breaks it into subtasks, distributes
them across specialized robots, pays each one, and gets back a
unified result — all programmatically, all on-chain.


Get Started

Read the spec:
github.com/plagtech/rtp-spec

Install the TypeScript SDK:

npm install @spraay/rtp-sdk
Enter fullscreen mode Exit fullscreen mode

Install the Python SDK:

pip install spraay-rtp
Enter fullscreen mode Exit fullscreen mode

Run the setup wizard:

npx @spraay/rtp-sdk init
Enter fullscreen mode Exit fullscreen mode

Build a $79 robot demo:
github.com/plagtech/rtp-pi-demo

Browse compatible devices:
github.com/plagtech/awesome-rtp

Gateway and docs:
gateway.spraay.app ·
docs.spraay.app


RTP is an open standard. Contributions, implementations, and
compatible device listings welcome via PR.

Built by Spraay Protocol

Top comments (0)