> ## Documentation Index
> Fetch the complete documentation index at: https://docs.molpha.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Gateway API

> Run signing rounds and retrieve ready-to-submit payloads — via the SDK gateway client or the HTTP gateway directly.

The gateway accepts an execution request for a feed, dispatches a signing round to the deterministically selected node set for the current registry version, and returns a completed [`DataUpdateResult`](/sdk/reference#dataupdateresult) — a payload ready to submit to any chain's verifier. The **recommended access path is the SDK gateway client** (`sdk.gateway`), which handles auth, optional context reuse, and struct assembly.

Default base URL (also exported as `DEFAULT_GATEWAY_ENDPOINT`):

```text theme={null}
https://dev-gateway.molpha.io/
```

## `requestSignedData`

```ts theme={null}
const result = await sdk.gateway.requestSignedData({
  feedId,
  apiConfig,
  signaturesRequired,
});
```

Runs a live round against the current on-chain registry version and resolves with a [`DataUpdateResult`](/sdk/reference#dataupdateresult). The SDK may take `feedId` for local context, but the HTTP gateway **derives** feed identity from `(consumerAuthority|payer, apiConfig, signaturesRequired)` and never trusts a client-supplied feed id. Live gateway rounds return `fresh: true`.

Execution is authenticated with an `authSig` produced by the wallet's `signAuthMessage` (or derived from a keypair-backed `Wallet.payer`). The gateway requires a valid 64-byte Ed25519 `authSig` — all-zero signatures are rejected.

### Private APIs

```ts theme={null}
const result = await sdk.gateway.requestSignedData({
  feedId,
  apiConfig: {
    url: "https://api.example.com/private-price?key={{secret.apiKey}}",
    responseParser: "$.price",
  },
  signaturesRequired,
  encrypt: {
    secrets: { apiKey: process.env.API_KEY! },
  },
});
```

`MolphaSDK` wires `verifyNodeKeys` to `solana.verifyNodeKeysForPrivateApi`, which checks gateway node encryption keys against on-chain Node accounts before secrets are encrypted.

## `prepareContext`

```ts theme={null}
const context = await sdk.gateway.prepareContext(feedId);

const result = await sdk.gateway.requestSignedData({
  feedId,
  apiConfig,
  signaturesRequired,
  context,
});
```

Fetches registry version, redundancy buffer, and the node set, and returns a [`RoundContext`](/sdk/reference#roundcontext). Pass it back via `context` to skip those prelude fetches on subsequent rounds. There is no automatic client-side cache — reuse is explicit.

## Response shape

The flat `DataUpdateResult` maps 1:1 onto every chain's verifier structs via [`buildEvmVerifierArgs` / `buildStarknetVerifierArgs`](/sdk/reference), or directly into Solana's `SubmitDataUpdateArgs`:

```ts theme={null}
{
  feedId: string;
  value: string;            // human-readable value
  valuePacked: string;      // 32-byte packed value, hex
  timestamp: number;        // canonicalTimestamp (seconds)
  registryVersion: number;
  signaturesRequired: number;
  signersBitmap: string;    // 32-byte big-endian bitmap, hex
  s: string;                // 32-byte Schnorr scalar, hex
  commitmentAddr: string;   // 20-byte commitment address, hex
  fresh: boolean;           // true for live gateway rounds
}
```

## HTTP gateway notes

* **Authentication:** requests carry an `authSig` produced by the caller's wallet (`signAuthMessage` or keypair-derived). The gateway verifies it; all-zero signatures fail with `401`.
* **Freshness:** live execute responses set `fresh: true`. To read a previously submitted Solana value without a new round, [read the `Feed` account](/guides/read-and-verify).
* **Registry:** pass `prepareContext(feedId)` result as `context` to reuse registry version, redundancy buffer, and nodes across rounds.

<Note>
  The current HTTP route for subscription-backed rounds is `POST /v1/round/execute`. Clients send `apiConfig`, `signaturesRequired`, `registryVersion`, and `authSig`; the gateway derives `feedId` and echoes it in the response. Agent pay-per-request rounds use `POST /v1/agent/execute` with exact `amount` (not `max_price`). Full schemas: [Gateway API](/protocol/gateway).
</Note>
