Files
hanzoai_agent/sdk/python/docs
Abhishek Krishna 38e687e42e feat(web3): MPC-signing integration for Web3 agents (closes #3)
Closes the two integration stubs and one broken import that block
hanzo_agents.extensions.web3 from doing real threshold-signed work:

1. New `mpc_client.py` — pydantic-typed `MpcClient` with `keygen`,
   `sign`, `verify`. HTTP-only against the `hanzoai/mpc` HTTP bridge
   (`POST /v1/{keygen,sign,verify}`). Configurable endpoint, timeout,
   retries, parties/threshold, optional bearer auth. Retries 5xx with
   exponential backoff; 4xx fail fast.

2. `web3_agent.verify_payment` — actually checks the chain. Pulls the
   tx receipt + tx, validates status==1, value >= expected (in wei),
   recipient == self.wallet.address, and >= configurable confirmations.
   Optional MPC cross-verification of the block-hash signature so a
   single party cannot spoof an ack. Mock-wallet path preserves legacy
   "trust the caller" behavior so existing tests keep passing.

3. `wallet.verify_signature` — uses `eth_account.Account.recover_message`
   with the EIP-191 prefix (matches `sign_message`). Returns False on
   malformed input rather than raising.

4. Fix `from .tee import …` → `from ..tee import …`. The `tee` package
   lives at `hanzo_agents.extensions.tee`, not under `extensions.web3`,
   so `from hanzo_agents.extensions.web3 import Web3Agent` currently
   raises `ModuleNotFoundError`.

Tests: `tests/test_web3_mpc_client.py` mocks `aiohttp.ClientSession`
and covers happy path for keygen/sign/verify, retry-on-5xx, fail-fast
on 4xx, hex validation, bearer-token header.

Docs: `docs/web3-mpc-integration.md` shows enable + wire protocol +
failure modes.

No new top-level deps. `aiohttp`, `pydantic`, `eth-account` are
already declared in `pyproject.toml`.

Total ~430 LOC across 1 new module, 2 patches, 1 test file, 1 doc.
2026-04-25 14:19:46 +05:30
..