Stream Onchain Money
Accept streaming payments
Overview & Concepts
For a one-time transaction, an agent signs a payment and the exchange clears in a single HTTP round trip - that's Move Onchain Money. Streaming works differently: an agent signs one authorization with a spending cap, and zerohash's Payments Streaming Engine meters actual usage and settles in increments as the session runs - crediting the business in near real-time and never charging beyond what was consumed.
The solution encompasses the following steps:
- Configure the zerohash x402 middleware connector for your Platform's to support streaming
- Configure merchants x402 payins parameters such as defining a metering unit (per second, token, or megabyte), a price-per-unit, a maximum session spend cap, and a settlement/increment period.
- Integrate to the Agentic Streaming integration guide, below.
- Start accepting streaming agentic payments.
zerohash is applying this streaming payments rail to:
- Streaming and metered access: Live data feeds, running model output, and video or audio streams billed by the second, the token, or the megabyte.
- Creator and publisher paywalls: Per-article, per-video, or per-download pricing collected at the moment of access, with no subscription required.
- Public API monetization for AI agents: Market data, inference, geolocation, or search APIs that charge per call instead of running on API keys and postpaid invoices.
- Agentic commerce for platforms: Marketplaces and SaaS platforms exposing usage-based tools directly to autonomous agents, on the same settlement model as their existing merchants.
Roles
| Role | Example | Description |
|---|---|---|
| Platform | Fetch | Integrates zerohash and configures the x402 middleware; makes the API calls to zerohash on behalf of merchants |
| Merchant | Skyline Weather Co. | The business exposing a paid endpoint (e.g., /forecast); returns the 402 Payment Required response and fulfills the request once payment settles |
| Shopper | John Smith | The human accountable under KYA for the agent's actions |
| Shopper's Agent | John's research agent | Initiates the payment request on behalf of the Shopper |
| zerohash | - | Acts as payment facilitator |
- Shopper's Agent initiates an x402 request. The agent calls the x402-enabled endpoint directly:
GET /forecast?city=chicago. The merchant can configure the x402 payins parameters such as price-per-endpoint-access, maximum spend limits, and specific asset & network acceptance either through your own x402 middleware or zerohash's middleware solution. - Merchant returns payment requirements in response to Shopper's Agent. The merchant's middleware responds with
402 Payment Requiredwith the KYA requirements to onboard a Shopper's agent, price to access the endpoint requested, supported assets, amount limits, chains, and destination address for payment. - Shopper's Agent resubmits x402 request with payment & KYA requirements - Shopper's agent includes all requirements in
X-PAYMENTheader of request. - zerohash authorize's the payment via
POST /verify. The Platform submits the payment and KYA requirements to zerohash's/verifyendpoint on the agent's behalf. zerohash checks the request against the merchant's configuredproduct_permissionsand transaction limits (see Set agent permissions and limits) and confirms whether it's authorized - no funds move at this step.
Streaming Integration Guide
The agent's session spend cap is enforced against merchant's x402 streaming configuration. A session cap is the maximum amount a merchant wants an agent to spend within a given frame.
x402 streaming occurs either through the zerohash middleware or through your own middleware that uses zerohash as a payment facilitator. The spend sessions are defined at first x402 request, and settlement terms are done in batches according to the merchant's configuration.
How a streaming session completes:
1 - Shopper's Agent initiates an x402 request - The agent calls the merchant's x402 streaming enabled endpoint, requesting access: GET /stream/market-data
2 - Merchant returns streaming payment requirements in response to Shopper's Agent. The merchant's middleware responds with 402 Payment Required with the KYA requirements to onboard a Shopper's agent, metering unit, price-per-unit, and maximum cap it will accept.
{
//KYA requirements
"accepts": [
{
"scheme": "upto",
"network": "base",
"asset": "USDC",
"price_per_unit": "0.0001",
"unit": "second",
"max_session_amount": "5.00",
"pay_to": "0xSkylineAddress"
}
]
}3 - Authorize the session via POST /verify: The Platform submits the proposed cap to zerohash, referencing the agent's participant_code and account_label. zerohash checks the cap against the agent's existing product_permissions and transaction limits (same check as Move) and, if authorized, opens a session - reserving the ceiling, not charging it.
Response:
{
"status": "verified",
"session_id": "SESSION-8821",
"participant_code": "CUST01",
"account_label": "AGENT01"
}4 - Usage accrues. As the agent consumes the metered resource, usage is tracked against the price-per-unit for the duration of session_id.
5 - Increments settle via POST /settle. Rather than a single settlement, /settle is called once per settlement period (e.g., every 60 seconds) for the duration of the session, each call debiting only what's been consumed since the last increment. As with Move, this is a free internal ledger transfer if the merchant is also zerohash-custodied, or a real onchain transfer otherwise.
POST /settle call:
{
"session_id": "SESSION-8821",
"participant_code": "CUST01",
"account_label": "AGENT01",
"increment_amount": "0.006",
"asset": "USDC.BASE"
}Response:
{
"status": "settled",
"settlement_type": "internal_ledger",
"session_id": "SESSION-8821",
"cumulative_amount": "0.006",
"remaining_cap": "4.994",
"settled_at": "2026-07-29T12:01:00Z"
}
NoteIf cumulative usage would exceed
max_session_amount, the session is closed automatically and no further increments are charged - the agent is never billed beyond its authorized cap.
6 - Session closes: When the agent's task ends, or the cap is reached, the Platform (or the merchant, or an idle timeout) closes the session. A final /settle call reconciles any remaining metered usage since the last increment; the unspent portion of the cap is never charged.
The agent's funds are held in a wallet outside zerohash's custody. Because a streaming session settles in many increments over time, this model requires the agent's wallet to support session keys - a delegated, scoped signing authority that can be granted once and used repeatedly, up to a defined cap, without re-signing per increment. This is supported by ERC-4337 smart contract wallets and by EIP-7702, which lets an existing wallet (e.g., MetaMask) temporarily gain this capability without changing its address. A plain private-key wallet with no smart-account capability cannot support streaming and should use Move Onchain Money instead.
This flow assumes the merchant (optional) has been onboarded - see Onboard your merchant.
1 - Register the agent's external wallet
Before the agent can open a streaming session, the Platform registers its wallet address against the participant_code + account_label established during KYA onboarding - the same registration and control-verification-challenge process used in Move's external-wallet guide.
POST /wallets/register call:
{
"participant_code": "CUST01",
"account_label": "AGENT01",
"wallet_address": "0xAgentExternalAddress",
"network": "base",
"wallet_type": "smart_account"
}
Note
wallet_typedistinguishes a smart-account wallet from a plain EOA. Streaming sessions can only be opened against a registered wallet markedsmart_account
2 - Agent grants a session key
Rather than signing a single-use transferWithAuthorization, the agent's wallet grants a scoped session permission - a session key authorized to spend up to a defined cap, for a defined duration, restricted to a specific recipient. This follows the same pattern as ERC-7715/ERC-7710: the agent's account grants permission once; the session key spends against that permission repeatedly.
"I grant a session key authority to spend up to 5.00 USDC to 0xSkylineAddress,
expiring at [timestamp]."3 - Agent opens a session, attaching the session key grant
GET /stream/market-data
Header: SESSION-GRANT: <base64-encoded session key grant>4 - Customer returns session requirements
The Customer's server - configured per Configure zerohash as a payments facilitator - responds 402 Payment Required with the metering unit, price-per-unit, and maximum cap it will accept.
{
"accepts": [
{
"scheme": "upto",
"network": "base",
"asset": "USDC",
"price_per_unit": "0.0001",
"unit": "second",
"max_session_amount": "5.00",
"pay_to": "0xSkylineAddress"
}
]
}5 - Verify the session grant via POST /verify
The Platform forwards the session key grant to zerohash's /verify endpoint. zerohash checks:
- Is the grant cryptographically valid, and does it come from a registered wallet (step 1)?
- Does the granted cap and expiry satisfy the merchant's stated max_session_amount?
- Has this grant already been opened as a session (replay protection)?
No funds move at this step.
POST /verify call:
{
"session_grant": "<base64-encoded session key grant>",
"session_requirements": {
"asset": "USDC.BASE",
"max_session_amount": "5.00",
"price_per_unit": "0.0001",
"unit": "second",
"pay_to": "0xSkylineAddress",
"scheme": "upto"
}
}Response:
{
"status": "verified",
"session_id": "SESSION-9042",
"payer_address": "0xAgentExternalAddress"
}6 - Usage accrues, and increments settle via POST /settle
As usage accrues, the Platform calls /settle on each settlement period, using the session key's delegated authority to authorize each increment on-chain - no new signature from the agent is required per increment, since the session key itself carries the scoped spending authority granted in step 2.
POST /settle call:
{
"session_id": "SESSION-9042",
"increment_amount": "0.006",
"asset": "USDC.BASE"
}Response:
{
"status": "settled",
"settlement_type": "onchain",
"session_id": "SESSION-9042",
"transaction_hash": "0xdef456...",
"cumulative_amount": "0.006",
"remaining_cap": "4.994",
"settled_at": "2026-07-29T12:01:00Z"
}
NoteBecause this is an external wallet, every increment settlement is a real on-chain transaction authorized by the session key — unlike the zerohash-controlled model, there is no internal-ledger settlement option here.
7 - Session closes
When the agent's task ends, the cap is reached, or the session key's expiry passes, the session closes. A final /settle call reconciles any remaining metered usage; the unspent portion of the granted cap is never charged and the session key's authority lapses.
Updated 2 minutes ago