Metadata-Version: 2.4
Name: ergo-agent-pay
Version: 0.3.0
Summary: Python reference SDK for the Ergo rail of Accord Protocol — agent payments, Note operations, LangChain / OpenAI integrations. Mirrors the legacy npm package of the same name; the canonical Python Accord layer will publish later under a different PyPI name.
License: MIT
Project-URL: Homepage, https://github.com/accord-protocol/accord-protocol
Project-URL: Documentation, https://github.com/accord-protocol/accord-protocol/blob/main/docs/api-reference.md
Project-URL: Repository, https://github.com/accord-protocol/accord-protocol
Project-URL: Issues, https://github.com/accord-protocol/accord-protocol/issues
Keywords: accord-protocol,ergo,blockchain,agent,ai-agent,payments,autonomous,langchain,openai,eUTXO,acceptance-predicate,note,agent-economy,bearer-instrument
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Office/Business :: Financial
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Provides-Extra: langchain
Requires-Dist: langchain>=0.1.0; extra == "langchain"
Requires-Dist: pydantic>=2.0; extra == "langchain"
Provides-Extra: openai
Requires-Dist: openai>=1.0.0; extra == "openai"
Provides-Extra: all
Requires-Dist: langchain>=0.1.0; extra == "all"
Requires-Dist: pydantic>=2.0; extra == "all"
Requires-Dist: openai>=1.0.0; extra == "all"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
Requires-Dist: mypy>=1.0; extra == "dev"
Requires-Dist: ruff>=0.1; extra == "dev"

# ergo-agent-pay (Python)

Python reference SDK for the **Ergo rail** of [Accord Protocol](https://github.com/accord-protocol/accord-protocol). Agent payments, Note operations, balance + UTxO inspection, LangChain / OpenAI integrations.

The package keeps its legacy npm-mirror name. A canonical Python Accord layer (port of `@accord-protocol/core`) is not yet published; when it is, it will live under a different PyPI name and import from this package as a rail dependency.

Zero required dependencies — uses Python standard library only.

```bash
pip install ergo-agent-pay
```

## Quick start

```python
from ergo_agent_pay import ErgoAgentPay

agent = ErgoAgentPay(address="YOUR_ADDRESS", network="testnet")

# Check balance
balance = agent.get_balance()
print(f"Balance: {balance['ergs']} ERG")

# Inspect a Note
note = agent.check_note("abc123...")
print(f"Note value: {note.value_erg} ERG")
print(f"Expired: {note.is_expired}")
print(f"Task hash: {note.task_hash}")

# Compute task hash for acceptance predicate
task_hash = ErgoAgentPay.compute_task_hash("task output here")
```

## LangChain integration

```python
from ergo_agent_pay import ErgoAgentPay

agent = ErgoAgentPay(address="YOUR_ADDRESS", network="testnet")
tool = agent.as_langchain_tool(server_url="http://localhost:3000")

# Use in any LangChain agent
from langchain.agents import AgentExecutor
tools = [tool]
```

## OpenAI function calling

```python
definition = agent.as_openai_function()

response = openai.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Pay 0.001 ERG to <address>"}],
    tools=[{"type": "function", "function": definition}],
)
```

## Transaction building

Python doesn't have a Fleet SDK equivalent. For full transaction building, use:
- **TypeScript SDK** (recommended): run `ergo-agent-pay` TypeScript server, call via HTTP
- **ergpy**: `pip install ergpy` — AppKit JVM wrapper
- **sigma-rust**: Python bindings for Rust-based TX builder

See [example 06](../../examples/06-python-agent/) for the HTTP delegation pattern.

## Note lifecycle — what Python can do

| Operation | Python | TypeScript |
|---|---|---|
| Get balance | ✅ | ✅ |
| Get UTxOs | ✅ | ✅ |
| Check note (decode registers) | ✅ | ✅ |
| Compute task hash | ✅ (BLAKE2b-256) | ✅ (BLAKE2b-256) |
| LangChain tool | ✅ | ✅ |
| OpenAI function | ✅ | ✅ |
| Build TX (issueNote, pay) | Via HTTP server | ✅ native |
| Sign TX | External | ✅ signer fn |
| Submit TX | ✅ | ✅ |

## API reference

Full API reference: [docs/api-reference.md](../../docs/api-reference.md)
