Skip to main content

Python SDK for the AgentPay task escrow and settlement protocol on Celo.

Project description

agentpay-celo

Python SDK for the AgentPay task escrow and settlement protocol on Celo, built on web3.py.

Install

pip install agentpay-celo

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

Usage

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agentpay_celo-0.1.0.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agentpay_celo-0.1.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file agentpay_celo-0.1.0.tar.gz.

File metadata

  • Download URL: agentpay_celo-0.1.0.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for agentpay_celo-0.1.0.tar.gz
Algorithm Hash digest
SHA256 48227128b81223061ec9d40468d0411df13d73fe2791e6588da8fb497600a43a
MD5 5daf55173e25bfa24b299e49146eedf0
BLAKE2b-256 25744d65df2de0a6fdc0bab7d37e9f2bb87f047b0ee922711397289c42907dd3

See more details on using hashes here.

File details

Details for the file agentpay_celo-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: agentpay_celo-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for agentpay_celo-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 23d8dd29b3742e8f17ef62345a6625c9409122db7bcb4e238adba556e5b64b97
MD5 3c8d51617d04d1a80432e1839062d5fe
BLAKE2b-256 6f700705d8f769e500b274b6ca14c0a8a87618f5886b2f82a58f6829451ccea4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page