npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

aptosmpp

v0.1.2

Published

Aptos payment method for the Machine Payments Protocol (MPP)

Readme

aptosmpp — Aptos Payment Method for the Machine Payments Protocol

Aptos adapter for MPP — the open protocol by Tempo + Stripe that lets any HTTP API accept crypto payments from AI agents using HTTP 402. Solana has theirs. Now Aptos does too.


Install

npm install aptosmpp

What it does

Any HTTP API can require payment before serving a response — no signup, no credit card, no subscription. The client (an AI agent or wallet) pays per request in APT or USDC. The server verifies on-chain and returns the resource.

Two modes:

  • Charge — one payment per request, settled on-chain immediately
  • Session — client deposits once into a Move escrow contract, sends signed vouchers per request, server settles at the end. Thousands of micropayments for the cost of 2 transactions.

Server

import { MppxServer, aptos } from 'aptosmpp/server';

const mppx = MppxServer.create({
  feePayerPrivateKey: process.env.FEE_PAYER_KEY,
  methods: [
    aptos.charge({
      network: 'mainnet',
      recipient: '0xYourAddress',
      assetAddress: '0xbae207659db88bea0cbead6da0c58b8b7a695f65ef13cf2f9de3e61d83d05a7b', // USDC
      tokenStandard: 'fa',
      decimals: 6,
    }),
  ],
});

app.get('/paid', async (req, res) => {
  const result = await mppx.charge({ amount: '1000000', currency: 'USDC' })(req.headers);
  if (result.status === 402) return res.status(402).set(result.headers).json(result.body);
  res.setHeader('Payment-Receipt', result.receiptHeader);
  res.json({ data: 'your payload' });
});

Client

import { MppxClient, aptos } from 'aptosmpp/client';
import { Ed25519PrivateKey, Account } from '@aptos-labs/ts-sdk';

const account = Account.fromPrivateKey({
  privateKey: new Ed25519PrivateKey(process.env.PRIVATE_KEY),
});

const mppx = MppxClient.create({
  methods: [aptos.charge({ signer: account })],
});

// Automatically handles the 402 challenge/response
const response = await mppx.fetch('https://api.example.com/paid-endpoint');

How it works

Client                          Server                    Aptos Node
  │  GET /resource                 │                           │
  ├──────────────────────────────> │                           │
  │                                │                           │
  │  402 + WWW-Authenticate        │                           │
  │ <────────────────────────────  │                           │
  │                                │                           │
  │  Authorization: Payment <tx>   │                           │
  ├──────────────────────────────> │                           │
  │                                │  simulate + broadcast     │
  │                                ├─────────────────────────> │
  │                                │ <───────────────────────  │
  │  200 OK + Payment-Receipt      │                           │
  │ <────────────────────────────  │                           │

Pull mode (default): Client signs but doesn't broadcast. Server verifies, co-signs as fee payer, broadcasts. Client pays zero gas.

Push mode (fallback): Client broadcasts, sends the tx hash to server. Server verifies on-chain.


Payment Channels (Session Mode)

For AI agents making many calls to the same API:

// Server
const server = MppxSessionServer.create({
  methods: [{
    network: 'mainnet',
    recipient: '0xYourAddress',
    channelModuleAddress: '0xYourDeployedContractAddress',
    pricing: { unit: 'request', amountPerUnit: '10000' },
    sessionDefaults: { suggestedDeposit: '10000000', ttlSeconds: 3600 },
  }],
});

// Client
const client = MppxSessionClient.create({
  methods: [{
    signer: account,
    authorizer: new UnboundedAuthorizer(account),
    buildOpenChannelTx: async (params) => { /* submit open_channel, return hash */ },
  }],
});

The client opens a channel once (deposits funds into a Move escrow), then sends signed vouchers per request with no on-chain transaction each time. The server settles the final voucher when done.


Move Contract

The payment channel contract is in move/aptos_channel/. Deploy it once:

cd move/aptos_channel
aptos move publish --profile server --named-addresses aptos_mpp=<your-address>
aptos move run --profile server --function-id '<your-address>::channel::initialize'

Production Storage

For multi-instance deployments, swap the default in-memory stores for Redis:

import Redis from 'ioredis';
import { RedisStore } from 'aptosmpp/server';
import { RedisChannelStore } from 'aptosmpp';

const redis = new Redis(process.env.REDIS_URL);

MppxServer.create({ store: new RedisStore(redis), ... });
MppxSessionServer.create({ store: new RedisChannelStore(redis), ... });

Repo Structure

aptosmpp/
├── src/
│   ├── server/         # MppxServer, RedisStore
│   ├── client/         # MppxClient, MppxSessionClient
│   └── session/        # Voucher signing, ChannelStore, RedisChannelStore, authorizers
├── move/
│   └── aptos_channel/  # Move smart contract (escrow + payment channels)
├── demo/               # Express server + Node client demo
└── tests/              # Unit + integration tests

Testing

npm test                    # unit tests, no network needed
npm run test:integration    # runs against devnet, requires .env
npm run demo:server         # start demo server
npm run demo:client         # run demo client

Spec

Implements draft-httpauth-payment-00 and draft-payment-intent-charge-00.

Built on the MPP spec by Tempo + Stripe. This is an independent open-source implementation — not a Tempo product. Any Aptos wallet works as the paying client.


License

Apache-2.0