OpenAutoPay: Mesh of L402, MCP, and Nostr will revolutionize Agentic AI payments. It will empower developers to build autonomous, AI-driven payment systems that are secure, scalable, and interoperable across decentralized networks
A Python SDK for implementing the Decentralised Agentic Mesh Payments Protocol (DAMPP), integrating L402 (Lightning Network), MCP (Model Context Protocol), and Nostr.
openautopay/
├── autopay-sdk/
│ ├── __init__.py
│ ├── payments.py # L402 payment handling
│ ├── context.py # MCP context fetching
│ ├── comms.py # Nostr communication
│ └── sdk.py # Main SDK class
├── examples/
│ └── marketplace.py # Example usage
└── README.md
pip install requests pynostr lnurl cryptographySee examples/marketplace.py for a sample implementation.
from autopay.sdk import OpenAutoPaySDK
# Mock keys and URLs
WALLET_KEY = "mock_lightning_wallet_key"
NOSTR_KEY = "your_nostr_private_key_hex" # 64-char hex string
SERVICE_URL = "http://marketplace.example.com/api/data"
MCP_SERVER = "http://mcp.example.com"
# Initialize SDK
sdk = OpenAutoPaySDK(WALLET_KEY, NOSTR_KEY, MCP_SERVER)
# Process a transaction
result = sdk.process_transaction(SERVICE_URL, "Get marketplace pricing")
print(f"Transaction completed: {result}")- L402-based payments via Lightning Network
- MCP context fetching for AI-driven decisions
- Nostr communication for decentralized messaging
OpenAutoPay is a groundbreaking open-source Free and Open Source Software (FOSS) code repository designed to redefine Agentic AI payments. By integrating the Lightning Network’s L402 protocol, the Model Context Protocol (MCP), and the Nostr protocol, OpenAutoPay empowers developers to create autonomous, AI-driven payment systems that are secure, scalable, and interoperable across decentralized networks. This repository provides a robust framework for AI agents to handle microtransactions, access external data and tools, and communicate in a decentralized ecosystem—all while leveraging the speed and efficiency of the Lightning Network.
L402 Integration: L402, a Lightning Network-native payment protocol, enables pay-per-use API access and microtransactions with minimal fees. OpenAutoPay uses L402 to allow AI agents to autonomously pay for services, data, or computational resources in real-time, fostering a machine-payable economy where agents operate independently.
MCP (Model Context Protocol): MCP is an open standard for connecting Large Language Models (LLMs) to external data sources and tools. In OpenAutoPay, MCP equips AI agents with a standardized interface to dynamically fetch relevant data—such as pricing, user preferences, or transaction history—ensuring payments are intelligent and contextually appropriate.
Nostr Protocol: Nostr, a decentralized communication protocol, offers secure, censorship-resistant messaging and identity management. OpenAutoPay leverages Nostr for peer-to-peer communication between AI agents, users, and service providers, ensuring reliable exchange of payment requests, confirmations, and transaction metadata in a trustless environment.
Designed with modularity and extensibility, OpenAutoPay provides developers with tools, libraries, and documentation to craft custom Agentic AI payment solutions. From automating subscription payments to enabling AI-driven marketplace transactions or powering decentralized service ecosystems, OpenAutoPay lays the groundwork for a new era of autonomous financial interactions. Licensed under a permissive FOSS license (e.g., MIT or Apache 2.0), the project invites community contributions to evolve its capabilities and adapt to emerging use cases in the AI and blockchain space, with the Decentralised Agentic Mesh Payments Protocol (DAMPP) as its flagship protocol.
The Decentralised Agentic Mesh Payments Protocol (DAMPP) is a novel protocol that unifies the strengths of L402, MCP, and Nostr into a cohesive standard for Agentic AI payments and interactions in a decentralized environment. Below is a detailed specification of DAMPP.
DAMPP enables autonomous AI agents to perform secure, context-aware payments and communications in a decentralized network by meshing L402’s payment capabilities, MCP’s context integration, and Nostr’s decentralized messaging.
Mechanism: Utilizes L402’s HTTP-based payment flow, where AI agents present a Lightning Network payment preimage and macaroon to access services or data. Enhancement: Extends L402 with dynamic pricing metadata, allowing agents to negotiate payment terms based on context (e.g., resource demand or service priority). Workflow: 1. Agent requests a service via a DAMPP endpoint. 2. Service provider responds with an L402 challenge (payment hash + macaroon). 3. Agent completes the payment over Lightning Network and gains access.
Mechanism: Adopts MCP’s client-server model to connect AI agents to external data sources (e.g., APIs, databases, or file systems) and tools. Enhancement: Introduces a “Context Request Payload” (CRP) that encapsulates payment-related data (e.g., transaction purpose, budget constraints) alongside traditional MCP context queries. Workflow: 1. Agent sends a CRP to a DAMPP server specifying the data/tools needed. 2. Server authenticates the request (via L402) and returns structured context data. 3. Agent processes the data to inform payment decisions or actions.
Mechanism: Leverages Nostr’s public-key-based messaging for secure, decentralized communication between agents, users, and services. Enhancement: Adds a “Payment Event Type” to Nostr’s event structure, enabling agents to broadcast payment intents, confirmations, or disputes to the network. Workflow: 1. Agent generates a signed Nostr event (e.g., "Payment Intent: 500 sats for API access"). 2. Event is relayed across Nostr nodes to the service provider. 3. Provider responds with a confirmation event after payment is verified via L402.
- Initialization: An AI agent identifies a task requiring payment, data, and communication (e.g., purchasing API access to fetch market data).
- Context Fetch: The agent sends a CRP to a DAMPP server via MCP, authenticated by an L402 macaroon, to retrieve necessary context (e.g., API pricing).
- Payment Execution: Using L402, the agent completes a Lightning Network payment based on the retrieved context.
- Communication: The agent broadcasts a Nostr Payment Event to confirm the transaction, logged by the network for transparency.
- Action: The agent accesses the service/data and completes its task, with all interactions standardized under DAMPP.
- Interoperability: Seamlessly integrates L402, MCP, and Nostr, allowing existing implementations to adopt DAMPP incrementally.
- Security: Combines L402’s macaroon-based authentication, MCP’s OAuth 2.1 subset, and Nostr’s cryptographic signatures for end-to-end trust.
- Scalability: Leverages Lightning Network for high-volume microtransactions and Nostr’s relay system for distributed communication.
- Agent Autonomy: Enables AI agents to negotiate, pay, and communicate without human oversight, using context-aware decision-making.
An AI agent managing a decentralized marketplace uses DAMPP to:
- Query product pricing via MCP.
- Pay for the listing fee via L402 over Lightning Network.
- Notify the seller and buyer via Nostr events, all in a single, standardized flow.
DAMPP servers can be built as extensions to existing MCP servers, with added L402 payment gateways and Nostr relay compatibility. OpenAutoPay could serve as the reference implementation, providing sample code and libraries in Python, Rust, or JavaScript.
plaintext
# Example Nostr Payment Event
{
"kind": 7000, // Custom Payment Event Type
"content": "Payment Intent: 500 sats for API access",
"pubkey": "<agent-public-key>",
"signature": "<cryptographic-signature>"
}
- Test: Add unit tests with mocked servers for L402, MCP, and Nostr.
- Expand: Implement error handling, retries, and logging.
- Deploy: Package as a PyPI module, npm package, or Rust crate.