PUBLIC DOCUMENTATION
Exclusively for AI agents

Connect your AI agent

The public integration guide for AetherForge: discovery, quotes, x402 payments and report delivery.

For developers integrating an AI agent. AetherForge services are delivered to AI agents; the agent conducts the request, payment and retrieval flow.

PUBLIC APIBase URL for your agent
https://api.aetherforgeagent.com/commerce/v1

Integration overview

AetherForge exposes its commercial API at https://api.aetherforgeagent.com/commerce/v1. All relative routes in this guide use that base URL.

Your agent discovers the available products, opens a session, requests an offer, checks the quote against its spending policy, pays through x402 and retrieves the report. The website introduces the services; the API is the integration interface.

Read the public contract before constructing a request. It specifies product parameters and payment methods. The quote returned for a particular order determines the asset and amount to authorize.

  • Public discovery: agent card and API contract.
  • Authenticated interaction: session token, A2A messages and delivery routes.
  • Order continuity: retain the order identifiers, request hash and recovery information.

Discover the API

The agent card describes the public service. The JSON contract describes the commercial interface, product parameters and payment options.

These two GET requests are public and require no session authorization. They retrieve discovery documents; they do not create an order or submit a payment.

curl https://api.aetherforgeagent.com/commerce/v1/.well-known/agent-card.json

curl https://api.aetherforgeagent.com/commerce/v1/contract.json

curl https://api.aetherforgeagent.com/commerce/v1/defi/markets.json
ResourceRelative route
A2A agent card/.well-known/agent-card.json
Public API contract / catalogue/contract.json
DeFi market directory/defi/markets.json

Open an agent session

Send POST /sessions with the payer's EVM address and a freshly generated sessionSecret. The client agent generates and retains this secret.

Store the payer and sessionSecret privately before sending. HTTP 201 returns token and payer. Reopening with the same pair restores access to the same buyer identity. Use the session token in Authorization on A2A and delivery requests.

// Node.js
import { randomBytes } from "node:crypto";
const api = "https://api.aetherforgeagent.com/commerce/v1";
const payer = "<PAYER>";
const sessionSecret = randomBytes(32).toString("hex");
const response = await fetch(`${api}/sessions`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({payer, sessionSecret}),
  redirect: "error"
});
if (response.status !== 201) throw Error(`HTTP ${response.status}`);
const { token } = await response.json();
ParameterMeaning
payerEVM address of the agent's paying wallet.
sessionSecret32 random bytes, encoded as lowercase hexadecimal; retained by the client.

Request and accept an offer

Send JSON to POST /a2a with Content-Type: application/json and the session Bearer. The JSON-RPC id is a string and must equal messageId. Each message contains exactly one data part. Use a fresh message ID for each call and retain the same clientRequestId when retrying the same offer.

Read result.message.parts[0].data after checking the matching JSON-RPC id and role ROLE_AGENT. For an offer, this object contains id, service, requestHash and recovery. Confirm service matches your product. Store id, requestHash, recovery.token and its three returned paths before accepting or signing.

For recovery after a connection failure, keep the same clientRequestId and the same request. A new identifier represents a new request.

FieldPurpose
clientRequestIdStable identifier for this request: 8–100 letters, digits, hyphens or underscores.
productProduct identifier from the public catalogue.
payerPaying address associated with the session.
paymentChainChain ID on which the agent intends to pay.
languageRequested report language: en, fr, es, pt, ru, ar, zh or ko.
dataProduct-specific input, following its published schema.
data.chainChain to analyze when the product's schema uses this field. It is separate from paymentChain.
Full offer message
{
  "jsonrpc": "2.0",
  "id": "message-1",
  "method": "SendMessage",
  "params": {
    "message": {
      "messageId": "message-1",
      "role": "ROLE_USER",
      "parts": [
        {
          "data": {
            "operation": "offer",
            "clientRequestId": "<CLIENT_REQUEST_ID>",
            "request": {
              "product": "contract-review",
              "payer": "<PAYER>",
              "paymentChain": 8453,
              "language": "en",
              "data": {
                "source": "pragma solidity ^0.8.20; contract Units { function one() external pure returns (uint256) { return 1; } }"
              }
            }
          }
        }
      ]
    }
  }
}
Accept the order
{
  "jsonrpc": "2.0",
  "id": "message-2",
  "method": "SendMessage",
  "params": {
    "message": {
      "messageId": "message-2",
      "role": "ROLE_USER",
      "parts": [
        {
          "data": {
            "operation": "accept",
            "orderId": "<OFFER_ID>",
            "requestHash": "<OFFER_REQUEST_HASH>"
          }
        }
      ]
    }
  }
}
Read order status
{
  "jsonrpc": "2.0",
  "id": "message-3",
  "method": "SendMessage",
  "params": {
    "message": {
      "messageId": "message-3",
      "role": "ROLE_USER",
      "parts": [
        {
          "data": {
            "operation": "status",
            "orderId": "<OFFER_ID>"
          }
        }
      ]
    }
  }
}

Inputs for the six products

Replace request.data in the offer with the matching object below, set request.product to the shown identifier and select the report language. The figures illustrate the request format. Angle brackets identify values supplied by the buyer. PAYER and RECIPIENT are EVM addresses, TRANSACTION_HASH and EIP3009_NONCE are 0x plus 64 hex digits, and SHA256 is the 64-character digest of the referenced invoice evidence.

For Firewall, replace the example Unix-millisecond expiry in both the mission and policy, use the transaction’s real nonce and choose the policy limits you authorize. Keep mission.language equal to request.language. The simulated transfer in this example is one wei. Guardian’s invoice, amount and nonce describe the payment you want reviewed. The purchase of its report has a separate quote.

For Guardian, INSPECTED_PAYER is the payer of the payment being checked. EXPECTED_AMOUNT_UNITS is a positive decimal integer string in the token’s smallest unit. Use the original invoice ID (1–120 letters, digits or _.:-) and reference (up to 500 characters). For an inspected Permit2 payment, set method to permit2 and supply nonce as an unsigned decimal string.

The DeFi template uses a supported market from GET /defi/markets.json. Find alternatives in its requests array and check products.defi-validator.required for your type. An optional DeFi question goes in params.message.metadata with keys buyerQuestion and language. Sentinel and Forensic take the question in data.question. Contract Review takes one Solidity source string, including the dependencies you want examined.

Transaction Firewall · transaction-firewall
{
  "firewallVersion": "AF_FIREWALL_M5",
  "mission": {
    "version": "AF_MISSION_M2",
    "id": "transfer_check",
    "language": "en",
    "expiresAt": 1893456000000,
    "steps": [
      {
        "id": "one",
        "chainId": 8453,
        "actor": "<PAYER>",
        "to": "<RECIPIENT>",
        "data": "0x",
        "value": "1",
        "gas": "21000",
        "nonce": "0",
        "dependsOn": [],
        "requiresExternalProof": false
      }
    ],
    "checks": [
      {
        "id": "balance",
        "kind": "balance",
        "chainId": 8453,
        "token": "native",
        "account": "<PAYER>",
        "minDelta": "-1",
        "maxDebit": "1"
      }
    ]
  },
  "policy": {
    "version": "AF_POLICY_M2",
    "id": "agent_policy",
    "expiresAt": 1893456000000,
    "maxReportAgeMs": 30000,
    "allowedChains": [
      8453
    ],
    "allowedActors": [
      "<PAYER>"
    ],
    "allowedTargets": [
      {
        "chainId": 8453,
        "address": "<RECIPIENT>",
        "selectors": [
          "0x"
        ]
      }
    ],
    "maxGasPerTx": "21000",
    "maxNativeValue": {
      "8453": "1"
    }
  },
  "report": {
    "requestedOperation": "MISSION_SIMULATION",
    "question": "Does the one-wei transfer comply with this policy?"
  },
  "expectations": []
}
Payment Guardian · payment-guardian
{
  "expected": {
    "schema": "AF_GUARDIAN_EXPECTED_ORDER_1",
    "id": "<INVOICE_ID>",
    "chainId": 8453,
    "asset": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
    "payer": "<INSPECTED_PAYER>",
    "recipient": "<RECIPIENT>",
    "amountUnits": "<EXPECTED_AMOUNT_UNITS>",
    "method": "eip3009",
    "nonce": "<EIP3009_NONCE>",
    "source": {
      "reference": "<INVOICE_REFERENCE>",
      "sha256": "<SHA256>"
    }
  },
  "transaction": "<TRANSACTION_HASH>"
}
DeFi Validator · defi-validator
{
  "chaine": 42161,
  "contrat": "0x05d28a86e057364f6ad1a88944297e58fc6160b3",
  "actif": "0xaf88d065e77c8cc2239327c5edb3a432268e5831",
  "type": "placement",
  "montant": "250",
  "jours": "90"
}
Stablecoin Sentinel · stablecoin-sentinel
{
  "chain": 8453,
  "token": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
  "amount": "1",
  "question": "Was the price above 1.005 USD for five minutes?"
}
Forensic Snapshot · forensic-snapshot
{
  "chain": 8453,
  "reference": {
    "chain": 8453,
    "tx": "<TRANSACTION_HASH>"
  },
  "topics": [
    "amount"
  ],
  "question": "What amount was transferred?"
}
Contract Review · contract-review
{
  "source": "pragma solidity ^0.8.20; contract Units { function one() external pure returns (uint256) { return 1; } }"
}
Optional DeFi question · params.message.metadata
{
  "buyerQuestion": "What are the net proceeds under these assumptions?",
  "language": "en"
}

Read and authorize the x402 quote

After accepting the offer, request GET /orders/{orderId}/delivery. A 402 response supplies the x402 quote in PAYMENT-REQUIRED. A 202 response means preparation is still in progress.

Read the HTTP 402 JSON body as q and decode PAYMENT-REQUIRED as Base64 UTF-8 JSON. For a compact header, compare extensions["af-commitment"].info.orderId with the order and its sha256 with the canonical hash of q. Verify resource and accepts also match. Otherwise the decoded header must match q. For Firewall, send AF-Quote-Profile: commitment-421 to request the compact header.

Before authorizing, compare q.orderId, binding.request, binding.requestHash and resource.url with the accepted order. Check the exact scheme, network, token, payTo and integer amount in accepts[0], the fee policy and the validity window. validAfter and validBefore are Unix seconds, expiresAt is Unix milliseconds. Use the quoted nonce and timestamps exactly. The examples below show the selected rail after those checks.

For EIP-3009 sign TransferWithAuthorization. For Permit2 the token allowance to Permit2 is separate from the signed spender (the exact settlement proxy). Authorize only the required amount. Sign typedData with the paying account, then use that signature in payment.payload. Buyer-funded network gas after sponsor failure requires explicit agreement on the same order. Check the product’s buyerPaidGas in the contract before opting in.

Submit the x402 v2 authorization required by that quote in the PAYMENT-SIGNATURE header of a new request to the same delivery URL. Network fees, when applicable, are separate from the service price.

RailUse
EIP-3009USDC payments on Base, Arbitrum One, Polygon PoS, OP Mainnet, Avalanche C-Chain and Linea Mainnet.
Permit2Binance-Peg USDC on BNB Smart Chain and USDg on Robinhood Chain. Any necessary token approval is a separate operation with its own fees and authorization.
Canonical SHA-256
// Node.js — UTF-8 / SHA-256
import { createHash } from "node:crypto";
function canonical(value) {
  if (Array.isArray(value)) return "[" + value.map(canonical).join(",") + "]";
  if (value !== null && typeof value === "object") {
    return "{" + Object.keys(value).sort().map(key =>
      JSON.stringify(key) + ":" + canonical(value[key])).join(",") + "}";
  }
  return JSON.stringify(value);
}
const digest = value => createHash("sha256")
  .update(canonical(value), "utf8").digest("hex");
EIP-3009 · signing fields
// q = JSON returned with HTTP 402
import { authorizationTypes } from "@x402/evm";
const a = q.accepts[0], b = q.binding;
const chainId = Number(a.network.split(":")[1]);
const authorization = {
  from: payer, to: a.payTo, value: a.amount,
  validAfter: b.validAfter, validBefore: b.validBefore, nonce: b.nonce
};
const typedData = {
  domain: {name:a.extra.name, version:a.extra.version, chainId, verifyingContract:a.asset},
  types: authorizationTypes, primaryType: "TransferWithAuthorization",
  message: { ...authorization, value:BigInt(a.amount),
    validAfter:BigInt(b.validAfter), validBefore:BigInt(b.validBefore) }
};
// signature = EIP-712 signature of typedData by payer
const payment = {x402Version:2, resource:q.resource, accepted:a,
  payload:{authorization, signature}};
Permit2 · signing fields
// q = JSON returned with HTTP 402; a.extra.assetTransferMethod === "permit2"
import { permit2WitnessTypes } from "@x402/evm";
const a = q.accepts[0], b = q.binding;
const chainId = Number(a.network.split(":")[1]);
const permit2 = "0x000000000022D473030F116dDEE9F6B43aC78BA3";
const proxy = "0x402085c248EeA27D92E8b30b2C58ed07f9E20001";
const permit2Authorization = {from:payer, permitted:{token:a.asset, amount:a.amount},
  spender:proxy, nonce:BigInt(b.nonce).toString(), deadline:b.validBefore,
  witness:{to:a.payTo, validAfter:b.validAfter}};
const typedData = {domain:{name:"Permit2",chainId,verifyingContract:permit2},
  types:permit2WitnessTypes, primaryType:"PermitWitnessTransferFrom",
  message:{permitted:{token:a.asset,amount:BigInt(a.amount)},spender:proxy,
    nonce:BigInt(b.nonce),deadline:BigInt(b.validBefore),
    witness:{to:a.payTo,validAfter:BigInt(b.validAfter)}}};
// signature = EIP-712 signature of typedData by payer
const payment = {x402Version:2, resource:q.resource, accepted:a,
  payload:{permit2Authorization, signature}};
Send the signed envelope
// Node.js
const delivery = `${api}/orders/${offer.id}/delivery`;
const reply = await fetch(delivery, {
  method: "GET", redirect: "error",
  headers: {
    Authorization: `Bearer ${token}`,
    "PAYMENT-SIGNATURE": Buffer.from(JSON.stringify(payment), "utf8").toString("base64")
  }
});
  • Use the exact asset, amount and network returned for the order.
  • For Permit2, verify the token and spender and authorize the quoted amount.
  • If an authorization has already been submitted, check the existing order's status before attempting another payment.

Retrieve, recover and acknowledge

Follow the same order while preparation or settlement is in progress. Once payment is confirmed and the report is available, the delivery route returns 200.

The JSON delivery contains the report in artifact, its SHA-256 hash in artifactHash and payment evidence in payment. Preserve the hash with the report you receive.

The recovery paths already start with /commerce/v1/. Resolve them against the API origin and use recovery.token. Poll statusPath, then GET reportPath when paymentConfirmed and reportAvailable are true. Verify orderId, the payment receipt and the canonical artifact hash before ACK. If the quote has binding.artifactHash, compare it with the delivered hash. For verified-analysis-v1, recompute binding.evidenceHash over {orderId,product,requestHash,preview}, compare the report evidence, and check any fresh Firewall revision against the quoted original snapshot.

After receiving the report, POST artifactHash and ackToken to the returned ackPath to acknowledge that exact version. Use the paths supplied for the order; do not construct private recovery or acknowledgement URLs yourself.

A lost response or another 402 after sending a signature leaves settlement uncertain. Keep the existing order and check its status and receipt before any further authorization. ACK returns the order status including buyerAcknowledgedAt.

ResponseClient action
202Follow the existing order; preparation or processing is in progress.
402 + PAYMENT-REQUIREDRead and validate the payment quote.
200Read the available report and preserve its hash.
503 + Retry-AfterRespect the indicated delay and consult the same order.
401Use the correct session token for A2A or the recovery token for the returned recovery paths.
Verify and acknowledge the report · Contract Review
// Node.js · Contract Review
const dest = (path, operation) => {
  const u = new URL(path, api);
  const expected = `/commerce/v1/recovery/${offer.recovery.reference}/${operation}`;
  if (u.origin !== new URL(api).origin || u.pathname !== expected || u.search || u.hash)
    throw Error("Unexpected recovery URL");
  return u;
};
const headers = {Authorization:`Bearer ${offer.recovery.token}`};
const statusReply = await fetch(dest(offer.recovery.statusPath,"status"), {headers,redirect:"error"});
if (!statusReply.ok) throw Error(`Status HTTP ${statusReply.status}`);
const status = await statusReply.json();
if (!status.paymentConfirmed || !status.reportAvailable) throw Error("Pending");
const res = await fetch(dest(offer.recovery.reportPath,"report"), {headers,redirect:"error"});
if (res.status !== 200) throw Error(`Report HTTP ${res.status}`);
const doc = await res.json(), a = q.accepts[0], receipt = doc.payment;
const norm = address => String(address).toLowerCase();
if (doc.orderId !== offer.id || doc.reference !== offer.recovery.reference ||
    doc.artifact.product !== "contract-review" || doc.artifact.orderId !== offer.id ||
    doc.artifact.requestHash !== offer.requestHash || !doc.ackToken ||
    digest(doc.artifact) !== doc.artifactHash || doc.artifactHash !== q.binding.artifactHash ||
    !receipt?.transaction || receipt.network !== a.network || receipt.amount !== a.amount ||
    norm(receipt.asset) !== norm(a.asset) || norm(receipt.beneficiary) !== norm(a.payTo) ||
    norm(receipt.payer) !== norm(payer)) throw Error("Report or receipt mismatch");
const ack = await fetch(dest(offer.recovery.ackPath,"ack"), {method:"POST", redirect:"error",
  headers:{...headers,"Content-Type":"application/json"},
  body:JSON.stringify({artifactHash:doc.artifactHash,ackToken:doc.ackToken})});
if (ack.status !== 200 || !(await ack.json()).buyerAcknowledgedAt)
  throw Error("ACK pending");
  • An interrupted response does not establish that a payment failed.
  • After submitting a signature, inspect statusPath before retrying or creating another order.
  • Keep session tokens, recovery tokens and acknowledgement credentials private within the client integration.

Payment networks and assets

The eight payment networks and their settlement assets are listed below. Token decimals determine the integer amount in the quote; always read the actual token contract and amount returned for your order.

paymentChain chooses the payment network. The chain analyzed by a product is a separate input, such as data.chain. Paying on a network does not by itself establish the scope of the requested analysis.

NetworkChain IDAssetDecimalsRail
Base8453USDC6EIP-3009
Arbitrum One42161USDC6EIP-3009
Polygon PoS137USDC6EIP-3009
OP Mainnet10USDC6EIP-3009
Avalanche C-Chain43114USDC6EIP-3009
BNB Smart Chain56Binance-Peg USDC18Permit2
Linea Mainnet59144USDC6EIP-3009
Robinhood Chain4663USDg6Permit2

Interpret the report's scope

Integrate both the answer and its supporting evidence: the network, block or observation window, sources and stated limits. Missing evidence can leave a question unresolved.

The public product contract defines the accepted inputs. The report defines what was actually examined. Payment confirmation establishes the purchase of a report, not a guarantee about a transaction, contract or market.

ProductScope to preserve when using its output
Transaction FirewallSimulated effects for the supplied transaction and available state; retain the block and simulation limits.
Payment GuardianPayment checks against the supplied order and available on-chain evidence.
DeFi ValidatorScenario calculations depend on the supplied assumptions and observed data.
Stablecoin SentinelPrice and duration conclusions depend on the exchanges and observations actually available.
Forensic SnapshotDocumented transfers and inspected counterparties within the examined scope; distinguish movements from attribution.
Contract ReviewTargeted static review of six pattern families in supplied Solidity, with localized findings and explicit limits.

Public client interfaces only. No agent source code, private keys or operational credentials are included.

Back to top