Metadata-Version: 2.4
Name: openlibx402-core
Version: 0.1.1
Summary: Core implementation of X402 payment protocol for autonomous AI agent payments
Project-URL: Homepage, https://openlib.xyz
Project-URL: Documentation, https://openlibx402.github.io/docs
Project-URL: Repository, https://github.com/openlibx402/openlibx402
Author-email: OpenLibx402 Contributors <hello@openlibx402.org>
License: MIT License
        
        Copyright (c) 2025 OpenLibx402 Contributors
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: agents,openlibx402,payments,solana,x402
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Office/Business :: Financial :: Accounting
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Requires-Python: >=3.8
Requires-Dist: httpx>=0.24.0
Requires-Dist: solana>=0.30.0
Requires-Dist: solders>=0.18.0
Provides-Extra: dev
Requires-Dist: black>=23.0.0; extra == 'dev'
Requires-Dist: mypy>=1.0.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
Requires-Dist: pytest>=7.0.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Description-Content-Type: text/markdown

# openlibx402-core

Core Python implementation of the X402 payment protocol for autonomous AI agent payments.

## Overview

The `openlibx402-core` package provides the fundamental building blocks for implementing the X402 payment protocol. This package handles payment processing on the Solana blockchain, including transaction creation, verification, and error handling.

## Features

- Payment request and authorization models
- Solana blockchain payment processing
- Comprehensive error handling for payment workflows
- Protocol primitives and data structures
- Transaction verification and validation

## Installation

```bash
pip install openlibx402-core
```

## Core Components

### Payment Models

```python
from openlibx402_core import PaymentRequest, PaymentAuthorization

# PaymentRequest: Represents a payment requirement
# PaymentAuthorization: Represents completed payment details
```

### Payment Processor

```python
from openlibx402_core import SolanaPaymentProcessor
from solders.keypair import Keypair

# Initialize payment processor
keypair = Keypair()  # Your wallet keypair
processor = SolanaPaymentProcessor(
    wallet_keypair=keypair,
    rpc_url="https://api.devnet.solana.com"
)

# Process payments (typically used by higher-level packages)
```

### Error Handling

```python
from openlibx402_core import (
    X402Error,
    PaymentRequiredError,
    PaymentExpiredError,
    InsufficientFundsError,
    PaymentVerificationError,
    TransactionBroadcastError,
    InvalidPaymentRequestError,
)

try:
    # Payment operations
    pass
except PaymentRequiredError as e:
    print(f"Payment required: {e}")
except InsufficientFundsError as e:
    print(f"Insufficient funds: {e}")
```

## Usage

This package is typically used as a dependency by higher-level packages like:

- **openlibx402-client**: HTTP client with automatic payment handling
- **openlibx402-fastapi**: FastAPI middleware for payment-required endpoints
- **openlibx402-langchain**: LangChain agent integration
- **openlibx402-langgraph**: LangGraph workflow integration

For most use cases, you'll want to use one of these higher-level packages rather than using `openlibx402-core` directly.

## Documentation

For complete API reference and guides, see:
- [Documentation](https://openlibx402.github.io/docs)
- [GitHub Repository](https://github.com/openlibx402/openlibx402)

## Testing

```bash
pytest tests/
```

## License

MIT License - See [LICENSE](LICENSE) file for details.
