Deprecated 2026-05-09. Use
@solana/mpp— the official Solana Foundation implementation — instead. Package remains on npm for existing consumers; no new development. Seemppsol/sdkfor the deprecation context and migration notes.
Shared TypeScript types and canonical encodings for MPP.sol — the Machine Payments Protocol on Solana.
This package is the dependency-free foundation that
@mppsol/server,
@mppsol/agent, and
@mppsol/cpi all consume.
npm install @mppsol/core- Wire types —
SolanaChallenge,SolanaAuthorization,SolanaReceiptmatching the HTTP header structures defined inspec/wire.md. - On-chain types —
Session,SessionState,PayReturn,SessionSettleReturnmatching the structures inspec/session.mdandspec/cpi.md. - Canonical debit encoding —
encodeDebit/decodeDebitfor the 122-byte off-chain debit message that gets Ed25519-signed. - Constants — domain separators (
DEBIT_DOMAIN_SEP,RESULT_DOMAIN_SEP), CPI return-data discriminators, default batching parameters, and well-known mint/program IDs. - Errors —
MppErrorCodeenum andMppSolErrorclass matching the error vocabulary inspec/wire.md§9.
import {
encodeDebit,
DEBIT_DOMAIN_SEP,
type Debit,
} from '@mppsol/core';
const debit: Debit = {
session: new Uint8Array(32), // session PDA pubkey bytes
nonce: new Uint8Array(32), // server-issued challenge nonce
amount: 1000n, // atomic units
expiry: BigInt(Math.floor(Date.now() / 1000) + 60),
sequence: 1n,
domainSep: DEBIT_DOMAIN_SEP,
};
const bytes = encodeDebit(debit); // 104 bytes
// sign `bytes` with the session's authorized_signer Ed25519 key,
// send {session, debit: base64url(bytes), signature: base64url(sig)}
// in the Authorization: Payment header.- No Solana SDK dependency. Pubkeys are exposed as base58
stringvalues; consumers convert toPublicKeyfrom@solana/web3.js, Kit, or any other SDK as they prefer. This package builds without pulling in a Solana runtime. bigintfor u64/i64. All on-chain integer fields arebigintto preserve full precision. Wire-level (HTTP) amounts remainstringper the spec.- Canonical encoding only. This package does not Ed25519-sign, hash, or talk to RPCs. Higher-level packages do that on top of these primitives.
v0.1 draft, fully implemented and tested. All wire-format types, encoders/decoders, and parsers ship as production code. 37 vitest tests passing. Breaking changes possible before v1.0.
| Capability | Status |
|---|---|
Wire types (SolanaChallenge, SolanaAuthorization, SolanaReceipt) |
✅ |
| Header parser/serializer | ✅ |
Canonical 104-byte debit encoding (encodeDebit / decodeDebit) |
✅ |
On-chain account types (read-side) — Session, PayReturn, SessionSettleReturn |
✅ |
| Constants (domain separators, well-known mints, defaults) | ✅ |
Errors (MppErrorCode, MppSolError) |
✅ |
This is the foundation package — all other @mppsol/* packages depend
on it. No runtime dep on @solana/web3.js or @solana/kit; pubkeys
are exposed as base58 strings.
Apache-2.0. Maintained by psyto.