Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Environment variables
.env
.env.*
!.env.sample

# Python virtual environments
.venv/
Expand Down
29 changes: 22 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,37 @@ Each language-specific implementation (e.g., `python/x402_a2a`) contains its own

The `examples/` directory contains various demonstrations of the x402 extension. Each example also has its own `README.md` with instructions on how to run it.

### 🎯 **Nevermined Demo**

We provide a complete, production-ready demo showcasing x402 payments with **Nevermined** blockchain integration:

- **[ADK Demo with Nevermined](python/examples/adk-demo/README.md)**: A full end-to-end payment flow demonstration using Google's ADK (Agent Development Kit) and Nevermined's payment infrastructure. This demo shows:
- Client and merchant agents communicating via the A2A protocol
- Real on-chain payment verification and settlement
- X402 access token generation and validation
- Complete payment flow from request to completion

The Nevermined demo uses the `payments_py` SDK for payment processing and demonstrates how to integrate x402 payments into production agent systems.

## 🏗️ **Architecture**

The `x402_a2a` libraries follow a **functional core, imperative shell** architecture:

* **Core Protocol:** The fundamental data structures and functions for creating, signing, and verifying payments.
* **Executors:** Middleware that automates the payment flow, making it easy to add payment capabilities to any agent.
- **Core Protocol:** The fundamental data structures and functions for creating, signing, and verifying payments.
- **Executors:** Middleware that automates the payment flow, making it easy to add payment capabilities to any agent.

This design provides both flexibility and ease of use, allowing developers to either build custom payment logic with the core protocol or use the executors for a more hands-off approach.

## 📚 **Learn More**

* **[Specification](spec/v0.1/spec.md)**: The complete technical specification for the x402 extension.
* **[Python Library](python/x402_a2a/README.md)**: The documentation for the Python implementation of the x402 extension.
* **[Python Examples](python/examples/)**: The directory containing demonstration applications for the Python implementation.
* **[A2A Protocol](https://github.com/a2aproject/a2a-python)**: The core agent-to-agent protocol.
* **[x402 Protocol](https://x402.gitbook.io/x402)**: The underlying payment protocol.
- **[Specification](spec/v0.1/spec.md)**: The complete technical specification for the x402 extension.
- **[Python Library](python/x402_a2a/README.md)**: The documentation for the Python implementation of the x402 extension.
- **[Nevermined Demo](python/examples/adk-demo/README.md)**: Complete end-to-end payment flow demonstration with Nevermined integration.
- **[Python Examples](python/examples/)**: The directory containing demonstration applications for the Python implementation.
- **[A2A Protocol](https://github.com/a2aproject/a2a-python)**: The core agent-to-agent protocol.
- **[x402 Protocol](https://x402.gitbook.io/x402)**: The underlying payment protocol.
- **[Nevermined Documentation](https://docs.nevermined.app/)**: Documentation for Nevermined's payment infrastructure.
- **[Payments-py SDK](https://github.com/nevermined-io/payments-py)**: The Python SDK for Nevermined payments.

## 🤝 **Contributing**

Expand Down
76 changes: 76 additions & 0 deletions python/examples/adk-demo/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Nevermined X402 Demo - Environment Configuration Template
# Copy this file to .env and fill in your values
#
# This demo always uses REAL BLOCKCHAIN TRANSACTIONS
# All payments will burn credits on-chain

# =============================================================================
# Nevermined Configuration (REQUIRED)
# =============================================================================

# Server Agent (Merchant) - API key with permissions to verify/settle payments
# This represents the merchant/service provider
# Get this from: https://nevermined.app/api-keys
NVM_API_KEY_SERVER=nvm:your-merchant-jwt-token-here

# Client Agent (Subscriber) - API key with permissions to generate access tokens
# This represents the subscriber/customer
# Get this from: https://nevermined.app/api-keys
NVM_API_KEY_CLIENT=nvm:your-subscriber-jwt-token-here

# Nevermined environment: sandbox, staging, or production
# - sandbox: For development and testing (uses testnet)
# - staging: For pre-production validation
# - production: For live deployments
NVM_ENVIRONMENT=sandbox

# =============================================================================
# Google ADK Configuration
# =============================================================================

# Google Generative AI API key
# Get from: https://makersuite.google.com/app/apikey
GOOGLE_API_KEY=your-google-api-key-here

# =============================================================================
# Agent Configuration (Payment Plans)
# =============================================================================

# Credits Plan ID from Nevermined (REQUIRED)
# This is the primary payment plan for credits-based payments
# Users can purchase credits upfront and use them for multiple transactions
NVM_CREDITS_PLAN_ID=your-credits-plan-id-from-nevermined

# Pay-as-you-go Plan ID from Nevermined (OPTIONAL)
# If set, creates a second payment option where users pay per request
# Leave empty or omit to only offer the credits plan
# You can create a pay-as-you-go plan using: uv run create-payasyougo-plan
NVM_PAYASYOUGO_PLAN_ID=your-payasyougo-plan-id-from-nevermined

# AI Agent ID from Nevermined (REQUIRED)
# The agent that will be associated with the payment plans
# Users subscribed to these plans can access this agent
NVM_AGENT_ID=your-agent-id-from-nevermined

# Credits to charge per transaction (default: 2)
# This is the max_amount: Number of credits to burn per transaction
NVM_PAYMENT_AMOUNT=2

# Blockchain network (default: base-sepolia)
# Options: base-sepolia, arbitrum-sepolia, etc.
NVM_NETWORK=base-sepolia

# =============================================================================
# IMPORTANT NOTES
# =============================================================================

# 1. ALL TRANSACTIONS ARE REAL - Credits will be burned on the blockchain
# 2. Ensure you have sufficient credits in your Nevermined plan
# 3. Never commit this file with real credentials to version control
# 4. Transaction hashes can be verified on blockchain explorers
# 5. No mock or simulation mode - always uses real blockchain
# 6. Multiple Plans: If both NVM_CREDITS_PLAN_ID and NVM_PAYASYOUGO_PLAN_ID
# are set, users will be able to choose between the two payment options
# 7. To attach a plan to an existing agent, use:
# uv run attach-plan-to-agent --agent-id <agent_id> --plan-id <plan_id>

Loading