Skip to main content
The gateway is Molpha’s HTTP entry point. It authenticates the caller, checks the subscription or the x402 payment, stamps the round’s timestamp, dispatches the round to the selected nodes and returns the signed attestation. Gateways are operated by Molpha and registered on chain by the protocol authority. Most integrations use the gateway through the SDK or MCP. Use the HTTP API directly when you work in another language or need full control.

Base URL

GET /v1/info returns the gateway’s identity. On devnet: Read these values from /v1/info rather than hardcoding them: RequestAuth and the x402 memo both bind the program ID and the Gateway PDA.

Endpoints

The same gateway also serves the Molpha Data routes under /v1/data. They have their own reference: see Molpha Data. Every round, signed or failed, is also reported to the public round archive, where you can look a round up by its roundId.

Requests

A round request names a source by its source document, a quorum (signaturesRequired) and the current registryVersion. You never send a timestamp, and a sourceId is optional (a cross-check):
  • The gateway, SDK and nodes each derive the sourceId from the source; the gateway answers 400 if a sourceId you send differs from its own. See Source ID.
  • registryVersion must equal the current on-chain version; a stale one gets 400. signaturesRequired must be at least the protocol minimum (3 on devnet) and at most the current node count (5 on devnet).
  • A source that reads a chain is accepted only for a chain this gateway has enabled and only with a finality and lagMs inside that chain’s bounds; anything else gets 400 naming the field. See Chain data sources.
  • requireProvider asks for a round that the source’s data provider also signs. No provider signer is registered on the devnet deployment yet, so such a request is 400 there.

Round timing

The gateway stamps each round after admitting it (after verifying the payment, on the x402 route). The timestamp is unix milliseconds on a fixed 100 ms grid, floor(nowMs / 100) * 100 from the gateway’s clock, and is returned in data.attestation.payload.timestamp. The 100 ms tick is a protocol constant: it is not configuration and /v1/info does not report it. See Round timing.
  • One round per feed per tick. A feed is a source, a quorum and a registry version. Requests for one feed inside one tick share one round ID: the nodes run the round once and every caller gets the result. Each caller still spends its own quota unit or payment.
  • One request per consumer per tick. A second request by the same consumer (or x402 payer) for the same source and quorum in the same tick is 409, with nothing reserved or spent. Retry one full tick later (100 ms plus a small jitter). Do not compute tick boundaries from your own clock.
  • No idempotency key. A retried request is a new round and spends another quota unit or needs another payment.

Authentication

RequestAuth

POST /v1/round/execute carries subscriptionOwner, consumerAuthority (the owner itself or one of its delegates), authTimestamp and authSig, an Ed25519 signature by consumerAuthority over:
authTimestamp is unix seconds. The gateway rejects it with 401 when it is further from its clock than requestAuthWindowSeconds (see /v1/info; 60 on devnet). Sign a fresh one for every attempt, including a retry after 409. RequestAuth is checked before any chain read, so a request that cannot authenticate costs nothing. It only authorizes use of the subscription: it is not part of the round ID, the signed message or any payment.

Sign-in sessions

Instead of RequestAuth, a caller can sign in once with its wallet (Sign-In-With-X in its Solana form, SIWS) and send Authorization: Bearer <token>. Sessions are available when GET /v1/info reports sessionAuth: true; otherwise the /v1/session routes answer 404.
  1. GET /v1/session/challenge?address=<wallet>[&owner=<owner>] returns the message to sign (data.message) and its terms (data.info). A delegate must name its owner.
  2. Sign the message’s UTF-8 bytes with the wallet (Ed25519). It is a message, not a transaction.
  3. POST /v1/session with a SIGN-IN-WITH-X header: base64 JSON of the info fields plus address, chainId, type: "ed25519", signatureScheme: "siws" and the base58 signature. It answers 201 with data.token and data.expiresAt.
  4. Send Authorization: Bearer <token> on POST /v1/round/execute, with no authSig or authTimestamp. Sending both is 400.
  5. GET /v1/session shows the subscription and this term’s usage. DELETE /v1/session signs out.
A token is valid only at the gateway that issued it. On devnet it lasts 30 minutes by default (sessionTtlSeconds), at most 60 minutes on request (sessionMaxTtlSeconds), and never past the subscription term; a challenge must be exchanged within 5 minutes (sessionChallengeTtlSeconds). A token identifies the caller only: the subscription and delegate are read from chain (through a cache of a few seconds) on every round, exactly as with RequestAuth. The hosted MCP server and the web app at https://app.molpha.io use this flow.

x402

POST /v1/x402/execute takes no RequestAuth and no session: the payment is the authorization. See x402 pay-per-request.

Admission

  • Capacity. The gateway runs at most maxInflightRounds rounds at once (see /v1/info; 200 on devnet), with a short queue for bursts. Beyond that it answers 503 with Retry-After before reading the request, so nothing is reserved or spent. A client that drives many feeds should keep its own concurrency near this number.
  • Per-consumer rate. The gateway can cap the request rate of each authenticated consumer key on POST /v1/round/execute; over it, the answer is 429 with Retry-After. It is checked after RequestAuth, so nobody can spend another key’s allowance.
  • Subscription rounds need an active subscription, a quorum within the subscription’s max_signers, and remaining quota. Quota is counted per 30-day term across the owner and its delegates, and a delegate’s rounds also count against its own max_data_requests. A round that fails after it is reserved gives its unit back. See Subscriptions.
  • x402 rounds need a verified payment of the quoted price to the protocol treasury. See x402 pay-per-request.
The Solana program does not settle rounds one by one and checks neither quota nor payment: the gateway enforces both at admission.

Response

Both execute routes return 200 with data.attestation:
  • payload: value, sourceId, registryVersion, signaturesRequired, timestamp (unix ms)
  • signature: signature, commitment, signersBitmap
and beside it:
  • roundId: the round’s ID, shared by every request for the feed in that tick. Look it up in the round archive.
  • value: the decimal rendering of payload.value (not signed).
  • valuePreimage: for a source with a keccak256 output, the bytes that were hashed. The response is their only copy.
  • outcome and reason: for a source with a policy, conclusive, or fallback with the INCONCLUSIVE reason code. The label is not signed; what you can rely on is the signed value compared with the source’s declared fallback.
The x402 route also returns a PAYMENT-RESPONSE header. Field meanings are in Rounds and attestations.
A gateway response is not proof of anything on its own. Verify the attestation before you act on it: see the consumer checklist.

Status codes

Errors are JSON, {"error": "<message>"}, except 402, whose body is the x402 payment-required object. 409, 429 and the capacity 503 are answered before anything is reserved or spent. Any other retry is a new round that spends quota or a payment again.