Skip to main content
Every public export of @molpha/sdk, grouped by area. For usage, see the SDK overview and the gateway client. Hex strings are lowercase without 0x unless noted.

Clients

MolphaSDK

MolphaSDKOptions (connection, wallet, endpoints?, programId?, idl?, commitment?) is described in Initialize.

MolphaGateway

A standalone gateway client needs getRegistrySelectionConfig (for example () => solana.getRegistrySelectionConfig()) or a full context on each request; without either, requestSignedData throws. MolphaGatewayOptions: defaultSubscriptionOwner, defaultConsumerAuthority, programId (default MOLPHA_PROGRAM_ID), verifyNodeKeys, allowUnverifiedNodeKeysForPrivateApi (default false; unsafe), and the test hooks random and sleep.

MolphaSolanaClient

FeedAccount

The decoded Solana Feed account (see feeds):

Submit options

SubmitAttestationOptions:

Batch submit

Sends one submit_attestation instruction per attestation, in timestamp order, in one transaction.
  • All attestations must share sourceId and signaturesRequired and have distinct timestamps. Registry version and signer set may differ.
  • The transaction is atomic: if one instruction fails (typically because a newer value landed first), none applies.
  • rawValue is not supported; submit those with submitAttestation.
  • If they do not fit in one transaction, it throws BatchTooLargeError before sending.
  • opts takes computeUnitLimit and priorityFeeMicroLamports (SubmitAttestationsOptions).
Sizing helpers:

requestMany

Updates many feeds. Reads the registry once, bounds concurrency adaptively (halves on 503/429, grows on success) and runs Solana submits on a separate limiter. Results come back in input order, and one feed failing does not stop the others. BulkFeed is { apiConfig, signaturesRequired, label? }. BulkResult has index, label?, ok (round succeeded), attestation?, signature?, feedAddress?, error? and submitError?; attestation is kept when only the submit failed. Also exported: AdaptiveLimiter and spreadOffsetMs(sourceIdHex, spreadMs).

Request and result types

RequestSignedDataOptions

Behaviour of each option is described in requestSignedData.

APIConfig

Without aggregation, every signer must fetch the identical value. With it, the selected nodes exchange signed observations, drop stale ones and outliers beyond maxDeviationBps, and sign the lower median of signaturesRequired surviving values as an int256 scaled by 10^decimals. aggregation is part of the sourceId and needs signaturesRequired >= 3 (MIN_TOLERANCE_SIGNATURES). mode: "exact" is rejected with AggregationConfigError.

RoundContext

Returned by prepareContext(). RegistrySelectionConfig is the same without nodes.

Attestation

A completed round. payload and signature are signed; value and fresh are gateway metadata. Field meanings and the signed message are in attestations.

MolphaWallet

Wallet is the @anchor-lang/core type. Without signAuthMessage, gateway auth is derived from Wallet.payer. See Wallet.

PlanType

The values are the on-chain plan ordinals (PlanId). planVariant(planId) and planIdFromVariant(variant) convert to and from the Anchor enum form.

Source identity and values

Derivation helpers

The owner and signaturesRequired are not part of the sourceId; see feeds.

int256 helpers

Message and selection helpers

The math is described in attestations.

Timing helpers

Verifier arguments

buildEvmVerifierArgs

Maps an Attestation onto verify(Attestation calldata, uint64 maxAge) of the EVM verifier. maxAge (seconds) is required; 0 disables the freshness check. Integers are range-checked against their Solidity types (RangeError). signature.s becomes signature.signature and commitmentAddr becomes commitment; timestamp and signersBitmap become bigint. The full struct layout is on the EVM verifier page.

buildStarknetVerifierArgs

Maps an Attestation onto verify(attestation, max_age) of the Starknet verifier. maxAge is required, in seconds; 0 disables the freshness check. Field names become snake_case, 32-byte values become u256 (bigint) and the commitment address becomes a felt252. The struct and calldata layout are on the Starknet verifier page.

Result codes

VERIFY_CODES maps the names of the codes both verifiers return (OK = 0 through STALE = 10) to their numbers; the EVM verifier page explains each one. verifyCodeName(code) returns the name, or undefined for a code this SDK does not know. Types: VerifyCode, VerifyCodeName.

Paywalled API sources

Types and functions behind sourcePayment:

Solana addresses

PDA helpers

Each helper takes the program id last (MOLPHA_PROGRAM_ID for the default deployment) and returns a base58 Address. feedPda takes sourceId as 32 bytes (deriveSourceId), not hex. deriveGatewayPda(authority, programId) and deriveGatewayPdaAddress(...) are async variants used for request auth.

Request auth

Constants

Byte utilities are exported too: bytesToHex, bytesToHex0x, hexToBytes, bytesToBase64, base64ToBytes, utf8, concatBytes, u8, u32be, u32le, u64be, u64le, u256beFromBigInt, bigIntFromBytesBe, ensureLength, toFixedBytes, normalizeSecp256k1PublicKeyHex and secp256k1PublicKeyFromCoordinates.

Errors

Which HTTP statuses are retried is in retries and errors.