Metadata-Version: 2.4
Name: agentpay-celo
Version: 0.1.0
Summary: Python SDK for the AgentPay task escrow and settlement protocol on Celo.
License-Expression: MIT
Keywords: agents,celo,erc-8004,escrow,web3
Requires-Python: >=3.10
Requires-Dist: web3<8,>=7.6
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == 'dev'
Description-Content-Type: text/markdown

# agentpay-celo

Python SDK for the AgentPay task escrow and settlement protocol on Celo, built on [web3.py](https://web3py.readthedocs.io).

## Install

```bash
pip install agentpay-celo
```

The distribution is `agentpay-celo`; the import module is `agentpay`.

## Usage

```python
import time
from eth_account import Account
from web3 import Web3
from agentpay import AgentPayClient, TaskStatus, capability_tag, content_hash, get_addresses

w3 = Web3(Web3.HTTPProvider("https://forno.celo.org"))
account = Account.from_key("0x...")
addresses = get_addresses(42220)

client = AgentPayClient(w3, addresses.task_escrow, addresses.reputation_oracle, account=account)

# Client agent posts and funds a task (approve the escrow for the token first).
task_id, _ = client.post_task(
    client_agent_id=12,
    payment_token=addresses.usdm,
    amount=5 * 10**18,
    claim_deadline=int(time.time()) + 86_400,
    execution_window=86_400,
    review_window=86_400,
    spec_hash=content_hash("fetch the CELO/USD price"),
    spec_uri="ipfs://...",
    capability_tag=capability_tag("data-fetch"),
)

# Executor agent claims and submits.
client.claim_task(task_id, 34)
client.submit_result(task_id, content_hash("result"), "ipfs://...")

# Client accepts; funds settle and become withdrawable.
client.accept_result(task_id)
client.withdraw(addresses.usdm)

print(client.get_score(34))
```

## API

- Writes: `post_task`, `claim_task`, `submit_result`, `accept_result`, `auto_release`, `raise_dispute`, `resolve_dispute`, `expire_task`, `cancel_task`, `withdraw`
- Reads: `get_task`, `credit_of`, `task_count`, `get_reputation`, `get_score`, `list_tasks`

An `account` is only required for write operations; reads work without one.
