@molpha/sdk is the recommended way to integrate Molpha from TypeScript. MolphaSDK wires the gateway client and the Solana client together behind a single wallet, and the package also ships framework-agnostic EVM/Starknet argument builders.
For AI agent workflows in Cursor, Claude Desktop, or Codex, use the Molpha MCP server — it wraps this SDK behind typed MCP tools. For the fastest path by audience, see the Backend quickstart or AI agent quickstart.
What you can build
Installation
Install the package along with the Solana peer dependencies (required for MolphaSDK / MolphaSolanaClient):
- ESM, browser-first, with
"sideEffects": false
- Tree-shakeable Solana path — gateway-only or read-only apps that skip the Solana imports can tree-shake the Anchor-heavy path entirely
- Node.js
>=20.19.0
- Node-only helpers (e.g.
walletFromKeypairFile) live under the @molpha/sdk/utils subpath so they never enter browser bundles
@anchor-lang/core provides the Anchor Wallet / Connection types the Solana client expects. bn.js is used by the Solana / Anchor path. The SDK pulls in @solana/kit and @noble/* as direct dependencies — you do not need @solana/web3.js, @coral-xyz/anchor, or @solana/spl-token for the consumer flow.
Initialize
By default the SDK talks to https://dev-gateway.molpha.io/. Override with endpoints (string or array for failover):
walletFromKeypairFile is Node.js-only. In the browser, pass a MolphaWallet backed by a wallet adapter:
Gateway execution requires a real Ed25519 authSig. Keypair-backed wallets (walletFromKeypairFile) derive auth from Wallet.payer automatically. Browser adapters should provide signAuthMessage. The gateway rejects all-zero signatures.
Facade surface
requestAndSubmit is equivalent to:
Solana client (sdk.solana)
All methods target the Molpha program (MoLFGDpFoVnQgwbkTNScKPohCxhbfd61JjFrnotuwzh on devnet); PDAs are derived internally from the documented seeds.
Plans and subscriptions
maxPriceUsdc is a safety bound: the transaction aborts if the on-chain price is higher than what the user approved. The SDK currently exports PlanType.Basic (0). On-chain plan ordinals remain Basic = 0, Standard = 1, Professional = 2, Enterprise = 3.
Derive a feed ID
There is no separate create instruction. The first successful submitDataUpdate creates the Solana Feed account if it does not exist. Settlement writes round receipts only.
Request
Live gateway rounds return fresh: true. Gateway execution is authenticated via signAuthMessage (or a keypair-derived signer); the HTTP gateway rejects all-zero authSig values.
For private APIs, pass encrypt: { secrets: { ... } } — MolphaSDK authenticates gateway node keys against on-chain Node accounts before encrypting. See the SDK gateway API.
Submission and reads
feed.value is the on-chain byte array (number[]), not the human-readable DataUpdateResult.value string. Decode it per your feed schema (see Read and verify).
submit_data_update is permissionless on-chain — the program re-verifies the aggregate signature on every write and only accepts a value whose canonical_timestamp is strictly greater than the stored one.
Direct verification
For Solana, use one of two paths:
- submit through
submitDataUpdate, then read the Feed account;
- verify directly in Rust with
molpha-verifier.
For EVM and Starknet, build verifier arguments with the helpers in SDK Reference.