Skip to main content
The Molpha Gateway turns an API request into a signed DataUpdateResult. It derives the feed identity, checks authorization or payment, dispatches a node round, validates the aggregate signature, and returns a payload that can be submitted to Solana or verified on EVM/Starknet.

Base URL

The SDK default (DEFAULT_GATEWAY_ENDPOINT) is:

Endpoint overview

Agent endpoints require agent.enabled: true and a configured gateway keypair (settlement.gateway_keypair_path).

Feed ID derivation

Clients do not send an on-chain create transaction. The gateway and SDK derive the feed identity from the caller, config hash, and quorum:
  • Subscription path: owner is consumerAuthority.
  • Agent path: owner is the payer.
  • signatures_required is appended as a single byte.
The gateway derives feedId and echoes it in successful responses. The Solana Feed account is created lazily on first successful submit_data_update. Settlement creates a round receipt; it does not write the feed.

Subscription-backed rounds

POST /v1/round/execute

Runs a signing round for a subscription owner or active delegate.
consumerAuthority signs:
timestamp must be within ~300s of the gateway clock. registryVersion must equal the current on-chain registry version. The signature is single-use per (feed_id, timestamp) — retries need a fresh timestamp and signature. An all-zero authSig is rejected.

x402 agent rounds

POST /v1/agent/execute

Runs a self-funded pay-per-request round. Agent-specific fields use snake_case; apiConfig matches the subscription execute shape. The payer funds a per-gateway escrow ATA, locks an exact USDC amount equal to the computed round price, signs AgentRequestAuth, and receives the signed result. Settlement via settle_agent_round is asynchronous.
Round price (USDC atomic units):
amount must equal that price exactly. agent_request_auth_sig may be omitted on the unfunded first request of the 402 discovery flow. AgentRequestAuth hash:
If the escrow ATA is underfunded (available balance = ATA − committed unsettled amounts), the gateway returns a standard x402 envelope:
402 flow:
  1. Call execute (signature optional) → receive 402.
  2. Create/fund payTo with at least maxAmountRequired USDC.
  3. Sign AgentRequestAuth over the extra fields.
  4. Retry with the same canonical_timestamp and the signature.

GET /v1/agent/{payer}/status

Advisory read of escrow state. Optional query signatures_required (default 1) controls the price quote. The escrow is per (payer, gateway) — the gateway derives and returns both addresses.
USDC amounts are decimal strings of atomic units. exists: false is normal before the first successful settlement.

Data response

Successful round responses return the same signed payload shape. Live rounds always set fresh: true.

Serve lifecycle

  1. Validate JSON, pubkeys, timestamps, and API config.
  2. Derive api_config_hash and feed_id.
  3. Verify request auth or x402 funding + AgentRequestAuth.
  4. Read advisory on-chain state.
  5. Reserve the round in the settlement outbox.
  6. Dispatch to nodes.
  7. Validate returned aggregate signature identity.
  8. Complete the outbox record (pending).
  9. Return the signed payload.
Settlement worker drains pending rows into settle_round_receipt or settle_agent_round when settlement.enabled is true.

Round-record PDAs

Replay protection is the unique round-record PDA init:

Self-hosting

The gateway is a Go service configured by YAML and environment variables. There is no separate operator “run-gateway” guide — use this section and the gateway repository config.
When agent.enabled is true, settlement.gateway_keypair_path is required because AgentRequestAuth binds the gateway PDA. If settlement is disabled, served rounds can remain pending indefinitely. Settlement uses the on-chain protocol_config.usdc_mint; solana.usdc_mint only overrides serve-time ATA derivation and must match on-chain.

Operational notes

  • Use durable storage for the settlement outbox.
  • Monitor pending outbox records and round timeout rates.
  • Keep Solana RPC latency low for escrow and subscription reads.
  • Verify returned payloads before application use.