@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
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
submit_attestation instruction per attestation, in timestamp order, in one transaction.
- All attestations must share
sourceIdandsignaturesRequiredand 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.
rawValueis not supported; submit those withsubmitAttestation.- If they do not fit in one transaction, it throws
BatchTooLargeErrorbefore sending. optstakescomputeUnitLimitandpriorityFeeMicroLamports(SubmitAttestationsOptions).
requestMany
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
requestSignedData.
APIConfig
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
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
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
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
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 behindsourcePayment:
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.