@molpha/sdk is the TypeScript client for Molpha. This page covers installation, initialization and the main methods; for an end-to-end walkthrough, start with the backend quickstart.
The SDK has three parts:
sdk.gateway(MolphaGateway) runs signing rounds and returns anAttestation.sdk.solana(MolphaSolanaClient) manages subscriptions, submits attestations to SolanaFeedaccounts and reads them.- Verifier argument builders (
buildEvmVerifierArgs,buildStarknetVerifierArgs) map anAttestationonto the EVM and Starknetverifycalls, with no ethers, viem or starknet.js dependency.
Installation
- Requires Node.js
>=20.19.0. The package is ESM-only and marked"sideEffects": false. @anchor-lang/coreandbn.jsare peer dependencies used by the Solana client. You do not need@solana/web3.js,@coral-xyz/anchoror@solana/spl-token.- Node-only helpers (
walletFromKeypairFile,loadKeypair) live in the@molpha/sdk/utilssubpath so they stay out of browser bundles.
Initialize
walletFromKeypairFile reads the path as given and does not expand ~.
Main methods
You can also construct
MolphaGateway or MolphaSolanaClient on their own; see clients.
Wallet
MolphaWallet is an Anchor Wallet with an optional signAuthMessage. Every gateway request carries a signature over a RequestAuth digest (see gateways). A keypair wallet from walletFromKeypairFile signs it with its payer key automatically. A browser wallet adapter has no payer, so supply signAuthMessage:
as MolphaWallet assertion is needed because the Anchor Wallet type declares payer. A wallet with neither payer nor signAuthMessage sends an all-zero auth signature, which the gateway rejects with HTTP 401.
Backend quickstart
Subscribe, request and submit end to end.
Gateway client
Rounds, retries and errors.
Reference
Every exported type and function.