Skip to main content
This guide explains how to use the MPP session intent with @stellar/mpp. The session intent is implemented using a one-way payment channel Soroban contract — the funder deposits tokens once, then makes many off-chain payments by signing cumulative commitments. No on-chain transaction is needed per payment, making this ideal for high-frequency AI agent interactions. This worked example assumes the channel is funded in USDC. Commitment amounts and prices below are therefore denominated in USDC, because channel commitments always use the asset deposited into the channel.

How channel payments work

Each commitment is cumulative. The server tracks the highest commitment it has seen; closing the channel batch-settles all payments in a single on-chain transaction.

Prerequisites

Before using channel mode, you need a deployed one-way-channel contract on Stellar Testnet or Mainnet. The contract is initialized with:
  • A commitment key — an ed25519 keypair. The client signs commitments with the private key; the contract verifies with the public key.
  • A token deposit — the funder’s initial balance in the channel asset. This example uses USDC.
See the one-way-channel repo for deployment instructions.

Session server

Create channel-server.js:
channel-server.js
Start the server:

Session client

Create channel-client.js:
channel-client.js
Add the commitment secret key to .env:
.env
Run the client:
Each request signs an increasing cumulative commitment off-chain. The server verifies the ed25519 signature against the on-chain commitment_key in the contract (via Soroban simulation, no transaction needed) and returns the protected content immediately.

Closing the channel

When the server wants to settle, it closes the channel using the highest commitment amount and signature it has tracked. The server must persist the highest cumulative amount and its corresponding ed25519 signature so it can supply them at close time.
Closing submits a single on-chain transaction that transfers the cumulative committed amount from the channel to the recipient. The remainder is returned to the funder.

Subpath exports

Channel mode uses separate subpath exports to avoid bundling unused code:

Additional documentation