Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 35 additions & 10 deletions docs/development-guide/nevermined-x402.mdx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
title: "Nevermined x402"

Check warning on line 2 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L2

Did you really mean 'Nevermined'?
description: "Nevermined provides first-class support for the x402 payment protocol, enabling AI agents, APIs, and services to charge per-request using secure, locally-signed payment authorizations."

Check warning on line 3 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L3

Did you really mean 'Nevermined'?
icon: "credit-card"
---

# Nevermined x402

Check warning on line 7 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L7

Did you really mean 'Nevermined'?

Nevermined provides first-class support for the x402 payment protocol, enabling AI agents, APIs, and services to charge per-request using secure, locally-signed payment authorizations.

Check warning on line 9 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L9

Did you really mean 'Nevermined'?

<Note>
For the complete technical specification, see the [x402 Smart Accounts Extension Spec](/docs/specs/x402-smart-accounts).
Expand All @@ -17,9 +17,9 @@
This section explains:

- The x402 HTTP 402 handshake and `PAYMENT-SIGNATURE` retry pattern
- How Nevermined extends x402 with Smart Account-based settlement

Check warning on line 20 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L20

Did you really mean 'Nevermined'?
- How subscribers generate and sign x402 payment proofs
- How permissions, session keys, and delegated execution work
- How delegations, session keys, and delegated execution work
- How the facilitator verifies and settles requests
- How to use the Python and TypeScript x402 client libraries
- Advanced integration with Google A2A/AP2
Expand All @@ -28,7 +28,7 @@

- [Payment Models](/docs/products/x402-facilitator/payment-models)

Nevermined's x402 implementation is compatible with the standard protocol while adding programmable settlement layers powered by Nevermined smart contracts.

Check warning on line 31 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L31

Did you really mean 'Nevermined's'?

Check warning on line 31 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L31

Did you really mean 'Nevermined'?

## Background: What x402 Solves

Expand All @@ -43,21 +43,21 @@
- Checks balance/permissions
- Settles payment on-chain (EIP-3009 or equivalent)

Nevermined extends this with ERC-4337 Smart Accounts, session keys, and programmable billing models, allowing much more complex behavior than standard EIP-3009-based transfers.

Check warning on line 46 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L46

Did you really mean 'Nevermined'?

## Why Nevermined Extends x402

Check warning on line 48 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L48

Did you really mean 'Nevermined'?

x402 itself focuses on single ERC-20, pay-per-request flows.

Nevermined introduces:

Check warning on line 52 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L52

Did you really mean 'Nevermined'?

| Area | x402 | Nevermined |

Check warning on line 54 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L54

Did you really mean 'Nevermined'?
| --------------------- | --------------- | ------------------------------------------------------------------- |
| Payment authorization | EIP-3009 | ERC-4337 UserOps + session keys |
| Wallet model | EOA signatures | Smart Accounts with granular permissions |
| Billing models | Pay-per-request | Subscriptions, credits, time windows, credit-burning |
| Delegated execution | Basic | Fully programmable “burn”, “order”, “redeem”, plan-specific actions |
| Settlement layer | ERC-20 | Nevermined smart-contract settlement |

Check warning on line 60 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L60

Did you really mean 'Nevermined'?


This means a subscriber can grant a server the ability to redeem credits or burn usage units while maintaining strict control over what the server can do.
Expand All @@ -79,20 +79,20 @@

- Subscriber: owns a Smart Account; delegates permissions through smart account policies
- Server/Agent: exposes an API secured by x402
- Facilitator: Nevermined component that verifies and settles payments

Check warning on line 82 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L82

Did you really mean 'Nevermined'?
- Blockchain: executes credit burns, orders, or other plan-specific actions

Check warning on line 83 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L83

Did you really mean 'Blockchain'?


## The Nevermined x402 Extensions

Check warning on line 86 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L86

Did you really mean 'Nevermined'?

Nevermined introduces two x402 schemes for different payment rails:

Check warning on line 88 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L88

Did you really mean 'Nevermined'?

| Scheme | Network | Use Case | Settlement |
|--------|---------|----------|------------|
| `nvm:erc4337` | `eip155:84532` | Crypto payments | ERC-4337 UserOps + session keys |

Check warning on line 92 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L92

Did you really mean 'Crypto'?
| `nvm:card-delegation` | `stripe` | Fiat/credit card | Stripe PaymentIntent + credit burn |

For the complete card-delegation specification, see the [Card Delegation Spec](/docs/specs/x402-card-delegation).
For the complete delegation specification, see the [Delegation Spec](/docs/specs/x402-card-delegation).

### `nvm:erc4337` — Smart Account Extension

Expand All @@ -111,7 +111,7 @@

When a server requires payment, it returns a `402` response with a `payment-required` header. The scheme depends on the plan's pricing configuration:

**Crypto plan (`nvm:erc4337`):**

Check warning on line 114 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L114

Did you really mean 'Crypto'?

```json
{
Expand Down Expand Up @@ -204,7 +204,7 @@

## Complete Payment & Execution Flow

Below is the Nevermined x402 Smart Account flow (verification + settlement).

Check warning on line 207 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L207

Did you really mean 'Nevermined'?

```mermaid
sequenceDiagram
Expand Down Expand Up @@ -267,7 +267,7 @@
- Execute order (if needed) to top up credits
- Execute burn to deduct usage
- Submit UserOps on-chain
- Return tx hashes to the server

Check warning on line 270 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L270

Did you really mean 'tx'?

## Developer Guide: Subscriber Flow

Expand All @@ -281,7 +281,7 @@

### Step 2 — Build a payment payload

Using Nevermined Payments libraries (Python or TS), you generate an x402 access token:
Using Nevermined Payments libraries (Python or TS), you generate an x402 access token. Token generation requires a `delegationConfig` that controls spending limits and duration. You can either auto-create a delegation inline (Pattern A) or create one explicitly and reuse its ID (Pattern B).

Check warning on line 284 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L284

Did you really mean 'Nevermined'?

<Tabs>
<Tab title="TypeScript">
Expand All @@ -306,8 +306,20 @@
// Extract planId and agentId from accepts array
const { planId, agentId } = paymentRequired.accepts[0]

// Generate the x402 access token
const { accessToken } = await payments.x402.getX402AccessToken(planId, agentId)
// Pattern A: Auto-create a delegation inline
const { accessToken } = await payments.x402.getX402AccessToken(planId, agentId, {
delegationConfig: { spendingLimitCents: 10000, durationSecs: 604800 }
})

// Pattern B: Create a delegation explicitly, then reuse its ID
const delegation = await payments.delegation.createDelegation({
provider: 'erc4337',
spendingLimitCents: 10000,
durationSecs: 604800
})
const { accessToken: token } = await payments.x402.getX402AccessToken(planId, agentId, {
delegationConfig: { delegationId: delegation.delegationId }
})
}
```
</Tab>
Expand All @@ -316,7 +328,7 @@
import base64
import json
import requests
from payments_py import Payments, PaymentOptions

Check warning on line 331 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L331

Did you really mean 'payments_py'?

payments = Payments.get_instance(
PaymentOptions(nvm_api_key="nvm:subscriber-key", environment="sandbox")
Expand All @@ -335,15 +347,28 @@
plan_id = payment_required["accepts"][0]["planId"]
agent_id = payment_required["accepts"][0].get("extra", {}).get("agentId")

# Generate the x402 access token
token_res = payments.x402.get_x402_access_token(plan_id, agent_id)
# Pattern A: Auto-create a delegation inline
token_res = payments.x402.get_x402_access_token(plan_id, agent_id, {
'delegationConfig': { 'spendingLimitCents': 10000, 'durationSecs': 604800 }
})
access_token = token_res["accessToken"]

# Pattern B: Create a delegation explicitly, then reuse its ID
delegation = payments.delegation.create_delegation({
'provider': 'erc4337',
'spendingLimitCents': 10000,
'durationSecs': 604800
})
token_res = payments.x402.get_x402_access_token(plan_id, agent_id, {
'delegationConfig': { 'delegationId': delegation['delegationId'] }
})
access_token = token_res["accessToken"]
```
</Tab>
</Tabs>

<Note>
The SDK auto-detects the payment scheme from plan metadata. For fiat plans (`isCrypto: false`), use `resolveScheme()` (TypeScript) or `resolve_scheme()` (Python) to determine the correct scheme. Middleware handles this automatically — see the [Express.js](/docs/integrate/add-to-your-agent/express) and [FastAPI](/docs/integrate/add-to-your-agent/fastapi) integration guides.
The SDK auto-detects the payment scheme from plan metadata. For fiat plans (`isCrypto: false`), use `resolveScheme()` (TypeScript) or `resolve_scheme()` (Python) to determine the correct scheme. For fiat plans, use `provider: 'stripe'` in the delegation; for crypto plans, use `provider: 'erc4337'`. Middleware handles this automatically — see the [Express.js](/docs/integrate/add-to-your-agent/express) and [FastAPI](/docs/integrate/add-to-your-agent/fastapi) integration guides.

Check warning on line 371 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L371

Did you really mean 'crypto'?
</Note>

### Step 3 — Submit with HTTP header
Expand Down Expand Up @@ -475,7 +500,7 @@
</Tab>
<Tab title="Python">
```python
from payments_py import Payments, PaymentOptions

Check warning on line 503 in docs/development-guide/nevermined-x402.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/development-guide/nevermined-x402.mdx#L503

Did you really mean 'payments_py'?

payments = Payments.get_instance(
PaymentOptions(nvm_api_key="nvm:agent-key", environment="sandbox")
Expand Down Expand Up @@ -556,8 +581,8 @@

- **x402** gives a universal payment-required protocol
- **Nevermined** enriches it with Smart Accounts, UserOps, and advanced billing models using the `nvm:erc4337` and `nvm:card-delegation` schemes
- **Card delegation** enables fiat/credit card payments via `nvm:card-delegation`, with auto-detection from plan metadata
- **Subscribers** delegate controlled permissions using session keys
- **Delegations** provide a unified permission model for both crypto (`nvm:erc4337`) and fiat (`nvm:card-delegation`) schemes, with auto-detection from plan metadata
- **Subscribers** delegate controlled permissions using `DelegationConfig` (spending limits and duration)
- **Servers** use `payment-signature` headers and verify/settle via the facilitator
- **Facilitators** verify and settle on-chain
- **Python & TypeScript libraries** provide turnkey developer tooling
Expand Down
10 changes: 5 additions & 5 deletions docs/integrate/patterns/fiat-payments.mdx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
---
title: "Fiat Payments"
description: "Accept credit cards via Stripe with no crypto wallet required. The easiest path for mainstream and enterprise adoption."

Check warning on line 3 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L3

Did you really mean 'crypto'?
icon: "credit-card"
---

Accept credit cards via Stripe in **USD or EUR**, with no crypto wallet required. Fiat payments are the fastest path to mainstream adoption -- your users can start paying with a card they already have.

Check warning on line 7 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L7

Did you really mean 'crypto'?

## When to Use Fiat Payments

<CardGroup cols={2}>
<Card title="Enterprise Adoption" icon="building">
Organizations that already pay for SaaS with corporate cards can onboard without touching crypto.

Check warning on line 13 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L13

Did you really mean 'crypto'?
</Card>

<Card title="Mainstream Users" icon="users">
Expand All @@ -28,14 +28,14 @@

## Fiat Payment Scenarios

Nevermined supports fiat payments in two scenarios:

Check warning on line 31 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L31

Did you really mean 'Nevermined'?

- **Human-to-Agent**: A user visits the Nevermined App checkout page and purchases a plan with their credit card. This is the simplest flow for onboarding new customers.

Check warning on line 33 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L33

Did you really mean 'Nevermined'?
- **Agent-to-Agent**: An agent owner enrolls a credit card and delegates payment permissions to an agent. The agent can then make autonomous payments on behalf of the owner, charging the delegated card per request.

## Pay-per-request or a bundle of credits

Nevermined offers two distinct fiat payment flows depending on whether you want upfront plan purchases or per-request charging.

Check warning on line 38 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L38

Did you really mean 'Nevermined'?

<CardGroup cols={2}>
<Card title="Plan Purchase" icon="cart-shopping">
Expand All @@ -49,15 +49,15 @@

## Human-to-Agent Purchase Flow

The simplest way to accept fiat. Users complete a standard Stripe Checkout session, and Nevermined handles the rest.

Check warning on line 52 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L52

Did you really mean 'Nevermined'?

<Steps>
<Step title="Select a plan">
The user browses available plans in the Nevermined App or your custom UI and selects one priced in fiat.

Check warning on line 56 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L56

Did you really mean 'Nevermined'?
</Step>

<Step title="Redirect to Stripe Checkout">
Nevermined creates a Stripe Checkout session and redirects the user to complete payment with their card.

Check warning on line 60 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L60

Did you really mean 'Nevermined'?
</Step>

<Step title="Payment completes">
Expand All @@ -65,7 +65,7 @@
</Step>

<Step title="Webhook confirms payment">
Nevermined receives a webhook from Stripe confirming the successful payment.

Check warning on line 68 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L68

Did you really mean 'Nevermined'?
</Step>

<Step title="Credits minted on-chain">
Expand All @@ -73,19 +73,19 @@
</Step>
</Steps>

Both one-time and recurring plan purchases are supported. For recurring plans, Stripe handles rebilling and Nevermined mints fresh credits each billing cycle.

Check warning on line 76 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L76

Did you really mean 'rebilling'?

Check warning on line 76 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L76

Did you really mean 'Nevermined'?

## Agent-to-Agent Purchase Flow

Fully autonomous agent-to-agent payments in fiat are enabled through card delegation. This allows an agent to charge a user's card on-demand, without the user needing to pre-purchase credits. Instead of buying credits upfront, the user authorizes Nevermined to charge their card within defined limits.

Check warning on line 80 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L80

Did you really mean 'Nevermined'?

<Steps>
<Step title="Card Enrollment">
The user enrolls a card as a payment method via **Settings > Credit Cards** in the [Nevermined App](https://nevermined.app/cards). The card is registered through VGS (Very Good Security) to ensure PCI compliance, and a token is created that represents the card without exposing sensitive data.

Check warning on line 84 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L84

Did you really mean 'Nevermined'?
</Step>

<Step title="Authorize delegation">
The user authorizes a card delegation through **Settings > Credit Cards** in the [Nevermined App](https://nevermined.app/cards), setting spending limits (max total spend, max transactions, expiration date).

Check warning on line 88 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L88

Did you really mean 'Nevermined'?
</Step>

<Step title="Receive delegation token">
Expand All @@ -107,13 +107,13 @@

## Permission Model

Card delegations enforce strict spending limits to protect the cardholder. Each delegation has three controls:
Delegations enforce strict spending limits to protect the cardholder. The delegation model (`DelegationConfig`) is shared between crypto and fiat payment providers. Each delegation has the following controls:

Check warning on line 110 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L110

Did you really mean 'crypto'?

| Limit | Description |
|-------|-------------|
| `spendingLimitCents` | Maximum total amount (in cents) that can be charged across all transactions |
| `maxTransactions` | Maximum number of individual charges allowed |
| `expiresAt` | Expiration date after which the delegation becomes invalid |
| `durationSecs` | Duration in seconds after which the delegation expires |
| `maxTransactions` | (Optional) Maximum number of individual charges allowed |

A delegation moves through a simple lifecycle:

Expand All @@ -128,16 +128,16 @@

## Security and PCI Compliance

Card data never reaches Nevermined servers. All sensitive card information is tokenized through **VGS (Very Good Security)**, a PCI-compliant proxy, before it reaches the facilitator. Nevermined only stores Stripe tokens, never raw card numbers.

Check warning on line 131 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L131

Did you really mean 'Nevermined'?

Check warning on line 131 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L131

Did you really mean 'Nevermined'?

<Note>
**Nevermined is PCI compliant** (PCI SAQ D level). VGS tokenizes card data in transit, and Stripe manages secure storage and charging. Your users' card data is protected by industry-standard security at every step.

Check warning on line 134 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L134

Did you really mean 'tokenizes'?
</Note>


## Revenue Routing with Stripe Connect

When a user pays with a card, Nevermined routes the revenue to the builder's connected Stripe account using Stripe Connect. Fees are deducted automatically before the payout reaches the builder.

Check warning on line 140 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L140

Did you really mean 'Nevermined'?

This means you receive funds directly in your Stripe account -- no manual transfers or reconciliation needed.

Expand All @@ -145,13 +145,13 @@

| Item | Cost |
|------|------|
| Nevermined fee | 2% of the transaction amount |

Check warning on line 148 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L148

Did you really mean 'Nevermined'?
| Stripe processing fee | Fixed fee + % per transaction (varies by currency/region; see Stripe pricing) |
| Supported currencies | USD, EUR |
| Settlement | Via Stripe PaymentIntents to builder's connected account |

<Warning>
Fiat payments carry higher fees than stablecoin payments (2% + Stripe fees vs. 1% flat). For high-volume or high-value use cases, consider [stablecoin payments](/docs/integrate/patterns/stablecoin-payments) to reduce costs.

Check warning on line 154 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L154

Did you really mean 'stablecoin'?

Check warning on line 154 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L154

Did you really mean 'stablecoin'?
</Warning>

## Supported Plan Types
Expand All @@ -170,7 +170,7 @@
</Card>

<Card title="Recurring" icon="arrows-rotate">
Automatic rebilling at the end of each period. Stripe manages the billing cycle.

Check warning on line 173 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L173

Did you really mean 'rebilling'?
</Card>
</CardGroup>

Expand All @@ -178,11 +178,11 @@

<CardGroup cols={2}>
<Card title="Stablecoin Payments" icon="coins" href="/docs/integrate/patterns/stablecoin-payments">
Accept crypto payments with the lowest fees and on-chain transparency

Check warning on line 181 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L181

Did you really mean 'crypto'?
</Card>

<Card title="x402 Card Delegation Spec" icon="file-lines" href="/docs/specs/x402-card-delegation">
Full technical specification for the card delegation extension
<Card title="x402 Delegation Spec" icon="file-lines" href="/docs/specs/x402-card-delegation">
Full technical specification for the delegation extension (crypto and fiat)

Check warning on line 185 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L185

Did you really mean 'crypto'?
</Card>

<Card title="Payment Models" icon="calculator" href="/docs/products/x402-facilitator/payment-models">
Expand All @@ -190,6 +190,6 @@
</Card>

<Card title="Manage Plans" icon="sliders" href="https://nevermined.app">
Create and manage payment plans in the Nevermined App

Check warning on line 193 in docs/integrate/patterns/fiat-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/fiat-payments.mdx#L193

Did you really mean 'Nevermined'?
</Card>
</CardGroup>
34 changes: 22 additions & 12 deletions docs/integrate/patterns/stablecoin-payments.mdx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
title: "Stablecoin Payments"

Check warning on line 2 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L2

Did you really mean 'Stablecoin'?
description: "Accept USDC, EURC, or any ERC-20 token on-chain with the lowest fees and full transparency."
icon: "coins"
---

Accept USDC, EURC, or any ERC-20 token directly on-chain. Stablecoin payments are Nevermined's native payment method, purpose-built for crypto users and autonomous agent-to-agent commerce.

Check warning on line 7 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L7

Did you really mean 'Stablecoin'?

Check warning on line 7 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L7

Did you really mean 'Nevermined's'?

Check warning on line 7 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L7

Did you really mean 'crypto'?

## When to Use Stablecoins

Check warning on line 9 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L9

Did you really mean 'Stablecoins'?

<CardGroup cols={2}>
<Card title="Agent-to-Agent Payments" icon="robot">
Expand All @@ -14,19 +14,19 @@
</Card>

<Card title="Human-to-Agent Purchases" icon="user">
Users buy plans through the Nevermined App checkout page, paying with tokens from their connected wallet.

Check warning on line 17 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L17

Did you really mean 'Nevermined'?
</Card>

<Card title="Crypto-Native Users" icon="wallet">
Your audience already holds stablecoins and prefers on-chain payments over traditional card flows.

Check warning on line 21 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L21

Did you really mean 'stablecoins'?
</Card>

<Card title="Lowest Fees" icon="piggy-bank">
Just 1% Nevermined fee with no additional processing surcharges. Ideal for high-volume or high-value use cases.

Check warning on line 25 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L25

Did you really mean 'Nevermined'?
</Card>

<Card title="On-Chain Transparency" icon="magnifying-glass">
Every payment settles on-chain, giving both parties a verifiable, auditable record of every transaction.

Check warning on line 29 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L29

Did you really mean 'auditable'?
</Card>
</CardGroup>

Expand All @@ -34,19 +34,19 @@

<Steps>
<Step title="Fund a smart account">
The subscriber funds their Nevermined smart account with ERC-20 tokens (USDC, EURC, or another supported token). This account is an ERC-4337 smart account that supports programmable permissions.

Check warning on line 37 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L37

Did you really mean 'Nevermined'?
</Step>

<Step title="Create session keys">
The subscriber generates scoped session keys that grant the facilitator permission to execute specific actions (order plans, burn credits, redeem access) on their behalf. Each key follows the principle of least privilege.
<Step title="Create a delegation">
The subscriber creates a delegation that grants the facilitator permission to execute specific actions (order plans, burn credits, redeem access) on their behalf. Each delegation is scoped by spending limits and duration, following the principle of least privilege.
</Step>

<Step title="Payment settles on-chain">
When the subscriber purchases a plan or makes a request, the facilitator submits a UserOperation to the smart contract. The payment settles on-chain and credits are minted to the subscriber.
</Step>

<Step title="Credits consumed per request">
Each API call or agent query burns credits according to the plan configuration. If the subscriber's balance runs low, the system can auto-order more credits (if the wallet has sufficient balance and the session key permits it).
Each API call or agent query burns credits according to the plan configuration. If the subscriber's balance runs low, the system can auto-order more credits (if the wallet has sufficient balance and the delegation permits it).
</Step>
</Steps>

Expand All @@ -54,42 +54,52 @@

Payments settle on the **Base** network. The most common tokens are:

| Token | Description | Base Mainnet | Base Sepolia |

Check warning on line 57 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L57

Did you really mean 'Mainnet'?

Check warning on line 57 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L57

Did you really mean 'Sepolia'?
|-------|-------------|-------------|-------------|
| USDC | USD-pegged stablecoin by Circle | `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` | `0x036CbD53842c5426634e7929541eC2318f3dCF7e` |

Check warning on line 59 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L59

Did you really mean 'stablecoin'?
| EURC | EUR-pegged stablecoin by Circle | `0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42` | `0x808456652fdb597867f38412077A9182bf77359F` |

Check warning on line 60 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L60

Did you really mean 'stablecoin'?

<Tip>
Nevermined supports any ERC-20 token on Base. If you need to accept a custom token, you can specify its contract address when creating your plan's price configuration.

Check warning on line 63 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L63

Did you really mean 'Nevermined'?
</Tip>

## Permission Model

Session keys are the core of the stablecoin permission model. Instead of giving the facilitator full control over a wallet, subscribers create scoped keys that limit exactly what can be done.
Delegations are the core of the stablecoin permission model. Instead of giving the facilitator full control over a wallet, subscribers create scoped delegations that limit exactly what can be done. The delegation model is shared between crypto (`erc4337`) and fiat (`stripe`) payment providers.

Check warning on line 68 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L68

Did you really mean 'stablecoin'?

Check warning on line 68 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L68

Did you really mean 'crypto'?

Each session key enforces the **principle of least privilege** through three limits:
Each delegation enforces the **principle of least privilege** through two limits:

| Limit | Description |
|-------|-------------|
| `orderLimit` | Maximum token amount the key can spend on plan purchases |
| `redemptionLimit` | Maximum number of credit burn or redeem operations the key can perform |
| `expiresAt` | Expiration date after which the key becomes invalid |
| `spendingLimitCents` | Maximum total amount (in cents) that can be spent across all transactions |
| `durationSecs` | Duration in seconds after which the delegation expires |

When any limit is reached, the session key stops working. The subscriber must generate a new one with fresh limits to continue.
When the spending limit is exhausted or the delegation expires, it stops working. The subscriber must create a new delegation with fresh limits to continue.

Delegations are created via the SDK before generating an x402 access token:

```typescript
// Create a delegation for crypto payments
const delegation = await payments.delegation.createDelegation({
provider: 'erc4337',
spendingLimitCents: 10000,
durationSecs: 604800 // 7 days
})
```

<Note>
Session keys are revocable at any time by the smart account owner. You always retain full control over your wallet.
Delegations are revocable at any time by the smart account owner. You always retain full control over your wallet. Under the hood, delegations create the appropriate session keys for the chosen provider.
</Note>

## Fees and Settlement

| Item | Cost |
|------|------|
| Nevermined fee | 1% of the plan price |

Check warning on line 98 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L98

Did you really mean 'Nevermined'?
| Processing surcharge | None |
| Settlement | On-chain via Nevermined smart contracts on Base |

Check warning on line 100 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L100

Did you really mean 'Nevermined'?

Because there's no payment processor in the middle, stablecoin payments carry no additional fees beyond the 1% Nevermined fee. This makes them the most cost-effective option, especially for high-volume use cases.

Check warning on line 102 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L102

Did you really mean 'stablecoin'?

Check warning on line 102 in docs/integrate/patterns/stablecoin-payments.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/integrate/patterns/stablecoin-payments.mdx#L102

Did you really mean 'Nevermined'?

## Supported Plan Types

Expand Down Expand Up @@ -124,13 +134,13 @@
When a subscriber's credit balance runs low, the system can automatically purchase more credits on their behalf. This happens seamlessly if:

- The subscriber's wallet has sufficient token balance
- The active session key has remaining `orderLimit` capacity
- The active delegation has remaining spending capacity (`spendingLimitCents` not exhausted)
- The plan supports re-ordering

This keeps agent-to-agent workflows running without interruption.

<Warning>
If the session key's `orderLimit` or `redemptionLimit` is exhausted, auto-ordering stops. The subscriber must create a new session key with fresh limits to resume.
If the delegation's `spendingLimitCents` is exhausted or the delegation has expired, auto-ordering stops. The subscriber must create a new delegation with fresh limits to resume.
</Warning>

## Next Steps
Expand Down
37 changes: 31 additions & 6 deletions docs/products/x402-facilitator/how-it-works.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
- [Making x402 programmable](https://nevermined.ai/blog/making-x402-programmable)
- [Building Agentic Payments with Nevermined, x402, A2A, and AP2](https://nevermined.ai/blog/building-agentic-payments-with-nevermined-x402-a2a-and-ap2)

## The Nevermined x402 programmable extension

Check warning on line 18 in docs/products/x402-facilitator/how-it-works.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/products/x402-facilitator/how-it-works.mdx#L18

Did you really mean 'Nevermined'?

Nevermined extends x402 with the `nvm:erc4337` scheme, enabling **programmable settlement** (credits/subscriptions/PAYG) using ERC-4337 smart accounts and session keys.

Check warning on line 20 in docs/products/x402-facilitator/how-it-works.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/products/x402-facilitator/how-it-works.mdx#L20

Did you really mean 'Nevermined'?

### PaymentRequired Response (402)

Expand Down Expand Up @@ -124,7 +124,7 @@

### Step 2: Generate x402 access token

Use the Nevermined SDK to generate an x402 access token with the required session keys:
Use the Nevermined SDK to generate an x402 access token. Token generation requires a `delegationConfig` that controls spending limits and duration. You can either auto-create a delegation inline or reuse an existing one.

Check warning on line 127 in docs/products/x402-facilitator/how-it-works.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/products/x402-facilitator/how-it-works.mdx#L127

Did you really mean 'Nevermined'?

<Tabs>
<Tab title="TypeScript">
Expand All @@ -136,21 +136,46 @@
environment: 'sandbox'
})

// Generate the x402 access token
const { accessToken } = await payments.x402.getX402AccessToken(planId, agentId)
// Pattern A: Auto-create a delegation inline
const { accessToken } = await payments.x402.getX402AccessToken(planId, agentId, {
delegationConfig: { spendingLimitCents: 10000, durationSecs: 604800 }
})

// Pattern B: Create a delegation explicitly, then reuse its ID
const delegation = await payments.delegation.createDelegation({
provider: 'erc4337',
spendingLimitCents: 10000,
durationSecs: 604800
})
const { accessToken: token } = await payments.x402.getX402AccessToken(planId, agentId, {
delegationConfig: { delegationId: delegation.delegationId }
})
```
</Tab>
<Tab title="Python">
```python
import os
from payments_py import Payments, PaymentOptions

Check warning on line 158 in docs/products/x402-facilitator/how-it-works.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/products/x402-facilitator/how-it-works.mdx#L158

Did you really mean 'payments_py'?

payments = Payments.get_instance(
PaymentOptions(nvm_api_key=os.environ['NVM_API_KEY'], environment='sandbox')
)

# Generate the x402 access token
token_res = payments.x402.get_x402_access_token(plan_id, agent_id)
# Pattern A: Auto-create a delegation inline
token_res = payments.x402.get_x402_access_token(plan_id, agent_id, {
'delegationConfig': { 'spendingLimitCents': 10000, 'durationSecs': 604800 }
})
access_token = token_res['accessToken']

# Pattern B: Create a delegation explicitly, then reuse its ID
delegation = payments.delegation.create_delegation({
'provider': 'erc4337',
'spendingLimitCents': 10000,
'durationSecs': 604800
})
token_res = payments.x402.get_x402_access_token(plan_id, agent_id, {
'delegationConfig': { 'delegationId': delegation['delegationId'] }
})
access_token = token_res['accessToken']
```
</Tab>
Expand Down Expand Up @@ -300,7 +325,7 @@
</Tab>
<Tab title="Python">
```python
from payments_py import Payments, PaymentOptions

Check warning on line 328 in docs/products/x402-facilitator/how-it-works.mdx

View check run for this annotation

Mintlify / Mintlify Validation (neverminedag) - vale-spellcheck

docs/products/x402-facilitator/how-it-works.mdx#L328

Did you really mean 'payments_py'?

payments = Payments.get_instance(
PaymentOptions(nvm_api_key=os.environ['NVM_API_KEY'], environment='sandbox')
Expand Down Expand Up @@ -389,7 +414,7 @@
Client->>Agent: GET /resource (no payment)
Agent->>Client: 402 + payment-required header

Client->>Client: Generate x402 token via SDK
Client->>Client: Create delegation + generate x402 token via SDK
Client->>Agent: POST /resource + payment-signature header

Agent->>Facilitator: POST /verify
Expand Down
Loading