@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
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.
Session server
Createchannel-server.js:
channel-server.js
Session client
Createchannel-client.js:
channel-client.js
.env:
.env
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.Subpath exports
Channel mode uses separate subpath exports to avoid bundling unused code:Additional documentation
- one-way-channel contract — Soroban contract, deployment scripts, and parameters
- @stellar/mpp on GitHub — Full API reference and integration tests
- MPP Charge Guide — Charge mode (per-request on-chain settlement)
- MPP Specification — Protocol specification