Skip to content

Latest commit

 

History

18 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AgentCred

AgentCred is the trust layer for agent economies: a Python SDK giving AI agents an identity, a wallet, and a reputation that follows them between applications. Money movement leaves an auditable transaction trail, reputation is derived purely from recorded work outcomes, and the whole core runs on the standard library alone. It is the SDK underneath AgentMarket, a marketplace where agents hire and pay each other — with real testnet ETH settlement.

Part of a three-repo stack. AgentCred is the trust layer; AgentExchange (an ETH prediction-market competition) and AgentMarket (a hiring marketplace where reputation gates who gets paid) are the applications built on it. Reputation earned in one agent economy is portable to the next — that is the thesis.

Install

Requires Python 3.10+.

pip install "agentcred @ git+https://github.com/dannym231/agentcred.git"

For the Coinbase CDP server-wallet utilities (real Base Sepolia wallets):

pip install "agentcred[cdp] @ git+https://github.com/dannym231/agentcred.git"

Quickstart

from agentcred import AgentCredAgent

client = AgentCredAgent("acme-client", initial_balance="100.00")
worker = AgentCredAgent("summarizer-7", metadata={"specialty": "research"})

# Identity: deterministic, derived from name + metadata (no registry).
print(worker.identity.agent_id)      # agent_0052de... (same on every machine)
print(worker.identity.address)       # 0x0052de...

# Pay for completed work: one call moves credits and records reputation,
# linked by transaction id so the score is auditable against the money.
transaction, event = client.pay_for_completed_task(
    worker, "12.50", category="research", details="protocol summary"
)
print(worker.wallet.balance)         # 112.50
print(worker.reputation.score)       # 55.0  (neutral 50 +5 per completion)
print(event.transaction_id == transaction.transaction_id)  # True

# Everything snapshots to JSON and restores losslessly.
restored = AgentCredAgent.from_json(worker.to_json())
print(restored.reputation.score)     # 55.0

API overview

Module What it owns
agentcred.agent AgentCredAgent — the bundle applications hold
agentcred.identity Identity — deterministic id + address from name/metadata
agentcred.wallet Wallet, BaseWallet, Transaction — Decimal balances, atomic transfers, append-only history
agentcred.reputation Reputation, ReputationEvent — outcome log and the bounded score derived from it (+5 completed, −10 failed, void neutral, clamped 0–100)
agentcred.exceptions One base class (AgentCredError) covering every SDK error
agentcred.cdp (extra) Coinbase CDP server wallets on Base Sepolia: idempotent load-or-create by name, the flat gas-buffer constant, stale-replica balance polling, exact ETH/wei conversion

Everything above is importable from the package root except agentcred.cdp, which needs the [cdp] extra and CDP credentials in the environment. The package ships py.typed; the full compatibility contract with production consumers is documented in docs/api_surface.md.

The agentcred.cdp utilities encode operational lessons from running real transfers: wallet names are primary keys (re-resolving a name can never mint a duplicate wallet), affordability checks must reserve a flat gas buffer because CDP's transfer API exposes no estimate, and balance reads after a broadcast must poll past stale RPC replicas instead of trusting the first answer. The docstrings explain each in detail.

Used in production by

AgentMarket (v1.1.0) — every market participant is an AgentCredAgent; escrow funding, payouts, and refunds move through Wallet.send with the transaction ids recorded in its audit ledger; verified work outcomes accrue through record_completed / record_failed / record_void. As of v1.1.0 its hiring gate reads reputation.score as a permission — a worker below the threshold has its bid rejected before any money moves — and its on-chain mode builds directly on this SDK's agentcred.cdp server-wallet utilities. On-chain settlement uses real Base Sepolia ETH — transcript with Basescan links.

Scope, honestly

  • Local credits are mock money. The core Wallet is exact bookkeeping, not a blockchain; it exists so applications can develop and test economic logic deterministically, and so on-chain settlement has an exact ledger to reconcile against.
  • On-chain means Base Sepolia, custodial, testnet-tiny. The cdp module is pinned to the testnet; wallets are CDP server wallets (Coinbase holds the keys), and it reads state rather than moving money — broadcasting transfers remains application policy.
  • Reputation is arithmetic, not judgment. The score is a transparent function of recorded outcomes; deciding what counts as completed or failed work belongs to the application (AgentMarket uses a deterministic verifier).

Tests

pip install -e ".[cdp,dev]"
python -m pytest tests/

61 tests, all offline: CDP interactions run against fakes. Without the [cdp] extra the cdp tests self-skip and the stdlib-only core remains fully tested — CI runs both shapes.

Roadmap

  • Shipped in AgentMarket v1.1.0: reputation-gated hiring built on these primitives, and AgentMarket's on-chain backend migrated onto agentcred.cdp (it no longer carries its own copies of the wallet/gas/polling patterns).
  • PyPI publication once the API stabilizes at 1.0.
  • A chain-backed BaseWallet adapter, so application money logic can run unchanged against real settlement.
  • Promote the reputation scoring toward a first-class policy surface once a second consumer needs to tune it (AgentMarket keeps the policy — the threshold — on its side today; the SDK owns only the math).

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages