bch-pay-client
Librería Python minimalista para aceptar pagos en Bitcoin Cash (BCH) en agentes de IA, bots y servicios automatizados.
¿Por qué? Los agentes de IA necesitan una forma nativa de monetizar sus servicios. BCH ofrece fees casi cero y pagos globales instantáneos.
💡 Integración: 5 líneas de código
💰 Sin intermediarios, sin comisiones de plataforma
🌐 Compatible con cualquier framework (FastAPI, Flask, Discord.py, Telegram)
🤖 Agentes preconstruidos listos para ejecutar
🛡️ Modo demo para pruebas sin wallet real
🚀 Quickstart
Instalación
pip install bch-pay-client
# Con soporte para QR y web frameworks
pip install bch-pay-client[all]
# Desarrollo (también funciona con poetry)
git clone https://github.com/bch-ia/bch-pay-client.git
cd bch-pay-client
pip install -e ".[all]"
Tu primer agente que cobra
from bch_pay_client import BCHPay
pay = BCHPay(network="testnet") # mainnet en producción
# 1. Crear factura
invoice = pay.create_invoice(
amount=0.01, # 0.01 BCH (~$0.50)
description="Consulta GPT-4: 1000 tokens"
)
# 2. Enviar dirección al usuario
print(f"📍 Paga a: {invoice.address}")
print(f"🔗 {pay.get_payment_url(invoice.id)}")
# 3. Verificar pago
if pay.check_payment(invoice.id):
print("✅ ¡Pagado! Entregando resultado de IA...")
¡Eso es! 5 líneas. Ahora tu agente puede cobrar en BCH.
🎯 Casos de uso
| Agente | Precio sugerido | Uso típico |
|---|---|---|
| LLM API | $0.002-0.03 / 1K tokens | API similar a OpenAI pero con pagos por uso |
| Fine-tuning | 0.1-1 BCH / modelo | Ajustar modelos personalizados |
| Dataset Marketplace | Variable | Vender datasets curados |
| GPU/CPU Rental | 0.001-0.05 BCH / hora | Alquiler de recursos de cómputo |
| Image Generation | 0.001-0.005 BCH / imagen | Stable Diffusion, DALL-E, etc. |
| Compute Rental | Por tokens/s | Cómputo genérico (inferencia, transcodificación) |
🤖 Agentes preconstruidos
Incluimos agentes funcionando en /examples/:
| Agente | Descripción | Ejecutar |
|---|---|---|
| API REST | Servidor FastAPI con endpoints /invoices, /check, /balance |
python examples/agent_api.py |
| Discord Bot | Comandos !invoice <amount>, !check <id> |
DISCORD_BOT_TOKEN=... python examples/agent_discord.py |
| Telegram Bot | Comandos /invoice, /check |
TELEGRAM_BOT_TOKEN=... python examples/agent_telegram.py |
| CLI | Interfaz de línea de comandos interactiva | bchpay-cli (tras instalación) |
| Hybrid | API + Discord + Telegram simultáneo | python examples/agent_hybrid.py |
| Fine-tuning | Servicio de fine-tuning pagado | python examples/agent_finetune.py |
| Dataset Marketplace | Venta de datasets | python examples/agent_dataset_marketplace.py |
| GPU Rental | Alquiler de GPUs por horas | python examples/agent_gpu_rental.py |
| Compute Rental | Alquiler de cómputo por tokens/s | python examples/agent_compute_rental.py |
| Image Generation | Generación de imágenes por pago | python examples/agent_image_gen.py |
| LLM API | API compatible OpenAI con balance prepago | python examples/agent_llm_api.py |
Todos los agentes son autónomos: pueden ejecutarse como servicios independientes, gestionando sus propios wallets, facturas y verificación de pagos.
💡 Consejo: Empieza con
agent_api.pyoagent_cli.pypara entender el flujo, luego adapta a tu caso.
📚 Documentación
- Quickstart - Guía detallada paso a paso
- API Reference - Referencia completa de BCHPay class
- Integration Guides - FastAPI, Discord, Telegram, Webhooks
- Troubleshooting - Soluciones comunes
- Contributing - Cómo contribuir, badges, code of conduct
- Roadmap - Lo que viene
🔧 Configuración avanzada
Nodo BCH real (mainnet)
pay = BCHPay(
network="mainnet",
bch_node_url="https://jsonrpc.your-bch-node.com",
explorer_url="https://explorer.bitcoin.com/bch"
)
Consulta our guide para configurar un nodo o usar servicios como Bitcoin.com API.
Webhooks (notificaciones automáticas)
invoice = pay.create_invoice(
amount=0.01,
description="Pago",
metadata={"user_id": "123"},
callback_url="https://tu-servidor.com/webhook/payment"
)
# Recibirás POST cuando el pago se confirme
Multi-wallet
# Los fondos se acumulan en el storage local
total_earned = pay.total_earned()
print(f"💰 Has ganado: {total_earned} BCH")
🧪 Tests
# Tests unitarios
pytest tests/
# Linting
ruff check bch_pay_client/
black --check bch_pay_client/
🤝 Contribuir
¡Contribuciones bienvenidas! Lee CONTRIBUTING.md.
Tabla de contribuidores:
| Contributor | Badge | PRs | Tipo |
|---|---|---|---|
| @tun编 | 1 | Librería base |
¿Quieres aparecer aquí? Haz tu primer PR!
📜 Licencia
MIT - ver LICENSE detalles.
💬 Contacto
- Issues: GitHub Issues
- Discord:
#bch-pay-clienten Discord BCH - Twitter: @bch_ia
Construyendo la economía de agentes autónomos con Bitcoin Cash. 🚀
"Payments should be as programmable as the agents themselves."
Metadata
Release files for bch-pay-client 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| bch_pay_client-0.1.0.tar.gz | 7.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bch_pay_client-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.5 kB
Release files / bch_pay_client-0.1.0.tar.gz
| Download URL | bch_pay_client-0.1.0.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
beec46d2c68d8015eca9e9c685edad2c95050a18b9fb0ba6e64e0f568065ed89
|
|
BLAKE2b-256 checksum How to use checksums |
9f39e55d140d238ec0480f87f6331433272d4e39b96962553617d76c21e691ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Release files / bch_pay_client-0.1.0-py3-none-any.whl
| Download URL | bch_pay_client-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
489770987a6805f4c026ef61c68076944a4aea4930c6495125a5c29a13f19569
|
|
BLAKE2b-256 checksum How to use checksums |
4c91efd2403b78cbcad5a42cf9d630ff1a3dc2665fa0c3a217a3d0efd916d01f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|