Skip to content

About

Solana payment method for the Machine Payments Protocol (MPP) — USDC transfers via @solana/kit

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

@solobank/mpp-solana

Solana USDC payment method for the Machine Payments Protocol (MPP). Client and server implementations built on @solana/kit v2 with SPL Token transfers.

npm CI License: MIT

Note: This is the standalone version. The MPP Solana payment method is also bundled into @solobank/sdk.

Install

npm install @solobank/mpp-solana mppx @solana/kit

Accept Payments (Server)

import { Mppx } from 'mppx';
import { solanaServer, SOLANA_USDC_MINT } from '@solobank/mpp-solana';

const mppx = Mppx.create({
  methods: [
    solanaServer({
      currency: SOLANA_USDC_MINT,
      recipient: 'YOUR_SOLANA_WALLET',
      rpcUrl: 'https://mainnet.helius-rpc.com/?api-key=YOUR_KEY',
    }),
  ],
});

The server verifies Solana signatures via RPC using instruction-level checks and token balance deltas.

Make Payments (Client)

import { createKeyPairSignerFromBytes } from '@solana/kit';
import { Mppx } from 'mppx/client';
import { solanaClient } from '@solobank/mpp-solana';

const signer = await createKeyPairSignerFromBytes(secretKeyBytes);

const mppx = Mppx.create({
  methods: [
    solanaClient({
      rpcUrl: 'https://mainnet.helius-rpc.com/?api-key=YOUR_KEY',
      signer,
    }),
  ],
});

The client loads SPL token accounts, builds transferChecked instructions, creates the recipient ATA if needed, signs and broadcasts, then returns the Solana signature as the MPP credential.

Exports

// Client
import { solanaClient } from '@solobank/mpp-solana';
import { solanaClient } from '@solobank/mpp-solana/client';

// Server
import { solanaServer } from '@solobank/mpp-solana/server';

// Utilities
import {
  SOLANA_USDC_MINT,
  USDC_DECIMALS,
  parseAmountToRaw,
  fetchTokenAccounts,
  buildTransferPlan,
} from '@solobank/mpp-solana';

Development

pnpm install
pnpm build            # Build ESM + CJS + types
pnpm typecheck        # Type checking
pnpm test             # 22 unit tests

Tech Stack

  • Solana: @solana/kit v2 (RPC, transactions, signing)
  • SPL Token: @solana-program/token (transferChecked, ATA)
  • MPP: mppx protocol framework
  • RPC: Helius
  • Build: tsup (ESM + CJS)
  • Testing: Vitest

Related Repos

License

MIT

About

Solana payment method for the Machine Payments Protocol (MPP) — USDC transfers via @solana/kit

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages