Skip to main content

RequestSignedDataOptions

Options for MolphaGateway.requestSignedData and the second argument to MolphaSDK.requestAndSubmit:
export interface RequestSignedDataOptions {
  apiConfig: object;
  maxAge?: number;
}
apiConfig must match the job’s committed configuration. maxAge (seconds) lets the gateway return a cached result when one is fresh enough.

RoundContext

Cached registry version, node set, and job config produced by sdk.gateway.prepareContext(jobId). Subsequent requestSignedData calls reuse this context so each round is a single gateway POST.

DataUpdateResult

A completed gateway round, ready to submit on-chain:
export interface DataUpdateResult {
  jobId: string;
  /** Human-readable value. */
  value: string;
  /** 32-byte packed value, hex. */
  valuePacked: string;
  /** canonicalTimestamp (seconds). */
  timestamp: number;
  registryVersion: number;
  signaturesRequired: number;
  /** 32-byte big-endian bitmap, hex. */
  signersBitmap: string;
  /** 32-byte scalar, hex. */
  s: string;
  /** 20-byte commitment address, hex. */
  commitmentAddr: string;
  /** Whether the value was freshly fetched this round. */
  fresh: boolean;
}

MolphaWallet

The wallet interface the SDK expects — satisfied by keypair-backed wallets (walletFromKeypairFile) or browser wallet adapters:
interface MolphaWallet {
  publicKey: PublicKey;
  signTransaction(tx): Promise<Transaction>;
  signAllTransactions(txs): Promise<Transaction[]>;
  signAuthMessage(msg: Uint8Array): Promise<Uint8Array>;
}

PlanType

enum PlanType { Basic = 0, Standard = 1, Professional = 2, Enterprise = 3 }

Derivation helpers

// jobId = keccak256("MOLPHA_JOB_V1" || owner || apiConfigHash)
export function deriveJobId(owner: Uint8Array, apiConfigHash: Uint8Array): Uint8Array;

// 32-byte keccak commitment to an off-chain API configuration
export function deriveApiConfigHash(apiConfig: object): Uint8Array;
Both inputs to deriveJobId must be exactly 32 bytes (owner is a Solana public key).

buildEvmVerifierArgs

Converts a DataUpdateResult into the two structs the EVM verifier’s verify() takes — a pure mapping with zero runtime dependency (use the output with ethers, viem, or a raw eth_call).
Gateway DataUpdateResultEVM struct field
jobIdDataUpdate.jobId
registryVersionDataUpdate.registryVersion
signaturesRequiredDataUpdate.signaturesRequired
valuePackedDataUpdate.value
timestampDataUpdate.canonicalTimestamp
sSchnorrSignature.signature
commitmentAddrSchnorrSignature.commitment
signersBitmapSchnorrSignature.signersBitmap
See Verify on EVM for the consumer-contract side.

buildStarknetVerifierArgs

Converts a DataUpdateResult into the Cairo verifier’s calldata structs, with no starknet.js runtime dependency.
Gateway DataUpdateResultCairo struct fieldCairo type
jobIddata_update.job_idu256
registryVersiondata_update.registry_versionu32
signaturesRequireddata_update.signatures_requiredu32
valuePackeddata_update.valueu256
timestampdata_update.canonical_timestampu64
sschnorr_data.signatureu256
commitmentAddrschnorr_data.commitmentfelt252 (low 160 bits)
signersBitmapschnorr_data.signers_bitmapu256
See Verify on Starknet for the consumer-contract side.