x402 payment flow

Payment enforcement happens at the Caddy gateway. The API publishes payment requirements through discovery and OpenAPI; the gateway verifies and settles via the facilitator.

1. Preflight Call a paid route without PAYMENT-SIGNATURE. Gateway returns 402 with PAYMENT-REQUIRED.
2. Sign Client wallet builds and signs the USDC transfer payload expected by the facilitator.
3. Retry Resend the request with PAYMENT-SIGNATURE. Caddy verifies and settles via facilitator.
4. Success Paid route returns 200 and may include PAYMENT-RESPONSE settlement metadata.

Required headers

Typical accept policy fields

Per-route pricing (defaults)

Confirm against live discovery before integrating. Documented defaults:

Free: /health, /discovery, /openapi.json, /v1/alpha/execution/shapes. See the endpoint catalog for current values from discovery metadata.

Unsigned execution quotes

  1. Call free GET /v1/alpha/execution/shapes to learn supported builders.
  2. Preflight paid POST /v1/alpha/execution/quotes, satisfy its x402 requirement, and retry with PAYMENT-SIGNATURE.
  3. Sign only the returned userSignIndexes / unsignedTxnsBase64, then submit through your own Algod client.

Amarok never receives wallet keys and never submits orders. meta.executionSubmitted is always false.

MCP server (agent tools)

Agents can connect to the remote Amarok MCP endpoint instead of calling HTTP endpoints directly. The MCP layer is walletless: paid tools return payment requirements first, then accept a caller-supplied paymentSignature on retry.

Full setup, tool list, and paid-tool flow: MCP documentation.

{
  "mcpServers": {
    "amarok": {
      "url": "https://amarok-mcp.compx.io/mcp"
    }
  }
}

Common failure modes

curl -i https://amarok-api.compx.io/v1/alpha/opportunities