Agent Payment Service
Payment infrastructure for AI agents on TRON
Overview
MERX Agent Payment Service enables AI agents to send and receive any TRC20 token (USDT, USDC, USDD, and more) on TRON without understanding energy, bandwidth, or blockchain mechanics. Real-time payment detection (<3 seconds), persistent address watching with per-token filtering, and x402 protocol support.
Base URL: https://agent.merx.exchange
x402 Facilitator: https://x402.merx.exchange
Authentication
All endpoints require an API key via X-Api-Key header.
curl -X GET https://agent.merx.exchange/api/v1/agent/status \ -H "X-Api-Key: sk_live_your_key_here"
Endpoints
POST /api/v1/agent/register
Register your TRON address with the agent service.
{
"tron_address": "TYourAddress...",
"label": "my-trading-agent"
}POST /api/v1/agent/send
Send any TRC20 token with smart resource provisioning. MERX estimates energy + bandwidth needed, purchases only the delta from the cheapest provider, then broadcasts your pre-signed TX.
{
"to": "TRecipientAddress",
"amount_usdt": "5.00",
"signed_tx": "{...pre-signed TX JSON...}"
}POST /api/v1/agent/receive
Watch for incoming TRC20 payment. Detection in <3 seconds. Optional token_contract filter.
{
"expected_amount": "5.00",
"token_contract": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
"tolerance_pct": 0,
"timeout_seconds": 300,
"webhook_url": "https://your-agent.com/paid"
}
token_contract: optional - filter to specific TRC20 (omit for any token)POST /api/v1/agent/watch
Persistent address monitoring for any TRC20 token. Runs 24/7, fires webhook on matching transfers. Filter by token_contract or event type (usdt_incoming, usdc_incoming, usdd_incoming, trc20_incoming).
{
"address": "TAnyTronAddress",
"event_types": ["trc20_incoming"],
"token_contract": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
"min_amount": "1.00",
"webhook_url": "https://your-agent.com/events",
"ttl_hours": 720
}
event_types: usdt_incoming, usdc_incoming, usdd_incoming, trc20_incoming, trx_incoming
token_contract: optional - filter to specific TRC20 (omit for any token)POST /api/v1/agent/invoice/create
Create a payment invoice with QR code and payment URL.
{
"amount_usdt": "25.00",
"description": "Analysis of 50 documents",
"expires_in_seconds": 3600
}GET /api/v1/agent/status
Current agent state: active receives, watches, invoices.
Billing
| Operation | Cost | Free Tier (monthly) |
|---|---|---|
| watch() | $0.02/day | 3 active |
| receive() | $0.10/detection | 10 |
| send() | $0.05/broadcast | 20 |
| swap() | $0.02/swap | 5 |
| x402 | $0.01/settlement | 50 |
Top up via USDT/USDC transfer to your deposit address (see billing endpoints).
x402 Facilitator
MERX is the x402 facilitator for TRON. Any server can accept TRON payments by returning a 402 response with our facilitator URL.
POST https://x402.merx.exchange/facilitate
{ "txid": "abc123...", "amount": 100000, "to": "TMerx..." }
Response:
{ "authorization": "eyJ...", "expires_at": "2026-04-05T..." }
GET https://x402.merx.exchange/verify/{txid}
{ "valid": true, "used": false, "expires_at": "..." }Swap
Swap between any TRC20 tokens via SunSwap V2. Get quotes without auth, execute swaps with API key.
GET /api/v1/prices/swap-quote
curl "https://merx.exchange/api/v1/prices/swap-quote?from=USDC&to=USDT&amount=5.00"
Response:
{
"from_symbol": "USDC",
"to_symbol": "USDT",
"amount_in": "5.00",
"amount_out": "4.98",
"rate": "0.996",
"price_impact": "0.01%"
}POST /api/v1/swap
curl -X POST https://merx.exchange/api/v1/swap \
-H "X-Api-Key: sk_live_..." \
-H "Content-Type: application/json" \
-d '{"from_token":"USDC","to_token":"USDT","amount":"5.00","slippage_pct":0.5}'Supported Tokens
MERX supports any TRC20 token for watch/receive/send operations. Known tokens with metadata:
GET https://agent.merx.exchange/api/v1/agent/tokens USDT TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t (6 decimals) USDC TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8 (6 decimals) USDD TPYmHEhy5n8TCEfYGqW2rPxsghSfzghPDn (18 decimals) BTT TAFjULxiVgT4qWk6UZwjqwZXTSaGaqnVp4 (18 decimals) WIN TLa2f6VPqDgRE67v1736s7bJ8Ray5wYjU7 (6 decimals) JST TCFLL5dx5ZJdKnWuesXxi1VPwjLVmWZZy9 (18 decimals) SUN TKkeiboTkxXKJpbmVFbv4a8ov5rAfRDMf9 (18 decimals) NFT TFczxzPhnThNSqr5by8tvxsdCFRRz6cPNq (6 decimals) Any other TRC20 contract address works too - just pass the contract address.
SDK
JavaScript / TypeScript
npm install merx-sdk
import { MerxClient } from 'merx-sdk'
const merx = new MerxClient({ apiKey: process.env.MERX_API_KEY })
// Swap
const quote = await merx.swap.quote('USDC', 'USDT', '5.00')
await merx.swap.execute({ from: 'USDC', to: 'USDT', amount: '5.00' })
// Agent payments
await merx.agent.register('TYourAddress')
await merx.agent.send({ to: 'T...', amount_usdt: '5.00', signed_tx: '...' })
await merx.agent.receive({ amount: '5.00', tokenContract: 'TR7NHq...' })
await merx.agent.watch({ address: 'T...', eventTypes: ['trc20_incoming'], webhookUrl: '...' })
await merx.agent.createInvoice({ amount: '25.00', description: '...' })Python
pip install merx-sdk
from merx import MerxClient
merx = MerxClient(api_key="sk_live_...")
# Swap
quote = merx.swap.quote("USDC", "USDT", "5.00")
merx.swap.execute("USDC", "USDT", "5.00")
# Agent payments
merx.agent.register("TYourAddress")
merx.agent.receive(amount="5.00", token_contract="TR7NHq...")
merx.agent.watch(address="T...", webhook_url="...", event_types=["trc20_incoming"])
merx.agent.create_invoice(amount="25.00")Webhook Format
POST {your_webhook_url}
X-Merx-Signature: sha256=...
X-Merx-Timestamp: 1743768003
// Payment detected (~3 seconds)
{
"event": "payment.detected",
"txid": "...",
"amount": "5000000",
"contract": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
"from": "TSender...",
"confirmed": false
}
// Payment confirmed (~54 seconds, irreversible)
{
"event": "payment.confirmed",
"txid": "...",
"amount": "5000000",
"contract": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
"confirmed": true
}
// Payment timeout
{ "event": "payment.timeout", "payment_id": "..." }