Skip to main content
@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:

Installation

  • Requires Node.js >=20.19.0. The package is ESM-only and marked "sideEffects": false.
  • @anchor-lang/core and bn.js are peer dependencies used by the Solana client. You do not need @solana/web3.js, @coral-xyz/anchor or @solana/spl-token.
  • Node-only helpers (walletFromKeypairFile, loadKeypair) live in the @molpha/sdk/utils subpath 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:
The 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.