* feat(bnb): read-only on-chain proof verification Close the BNB SDK lane's gap: proof artifacts were self-attested (hashes recomputable) but nothing confirmed the chain. Add a new read-only BSC JSON-RPC verifier and surface it everywhere proof is shown. - crates/chain-verifier: eth_chainId, eth_getCode, eth_getTransactionReceipt. ABI-free, no keys/signing, offline-safe (skipped when BSC_RPC_URL unset). 11 unit tests. - /proof/verify: append onchain_* checks + onchain_configured; passed now means "no check failed" so skipped does not block. - dashboard /proof: dedicated On-chain Verification section, skipped handling. - clients/proof-verifier/verify.py: --rpc / BSC_RPC_URL opt-in, stdlib urllib, mirrors the Rust checks; offline default unchanged. - docs: BNB_AGENT_IDENTITY, proof-verifier README, PRIZE_MAP, WHATS_NEW. Verified against live BSC mainnet: competition contract 0x212c61…aed5 returns ~2.5 KB of deployed bytecode via eth_getCode (chain id 56). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(ci): green rust clippy + cargo-deny (pre-existing failures) These failures predate the on-chain-verification feature and block the merge; fixing them here unblocks it and moves the repo toward green. - clippy (CI clippy 1.96 is stricter than local 0.1.94): convert three unnecessary_sort_by key-extraction sorts to sort_by_key in guardrail-cli (identity.rs, market.rs, portfolio.rs). Decimal keys are Copy+Ord. - cargo-deny: add a [licenses] allow-list (was empty, so every crate — including this MIT workspace — was rejected). Standard permissive set. Not fixed here: the docker dashboard image build (pnpm v10 frozen-lockfile + sharp build-script) — unrelated infra, non-required check; the dashboard deploys to Vercel separately. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(ci): allow CDLA-Permissive-2.0 license (webpki-roots) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
6.5 KiB
BNB Agent Identity
The bnb-agent crate owns identity, off-chain metadata, registry records, and
proof hashes, keeping all of that separate from strategy and execution logic.
Everything here is deterministic and computed off-chain — no network or chain
access — so the same inputs always yield the same identifiers, hashes, and
explorer URLs.
AgentIdentity
Binds a human-readable name to a BNB-chain wallet_address with an optional
metadata_url. The derived agent_id() is the lowercase-hex SHA-256 of
name + \0 + wallet_address (the NUL separator prevents boundary-ambiguity
collisions). The metadata URL does not affect the id. The runtime computes the
agent id at startup from the agent name and the TWAK wallet address
(agent-runtime/src/runtime.rs).
AgentMetadata
The off-chain JSON document an agent publishes (typically at metadata_url).
It commits to the agent's behavior by embedding strategy_hash and
policy_hash (both SHA-256 hex), alongside name, description, and version.
Serializes to/from JSON via to_json / to_json_pretty / from_json.
Registry records (ERC-8004 / ERC-8183)
Erc8004Record and Erc8183Record are typed, off-chain mirrors of the
on-chain registry record shapes for the two AI-Agent identity standards. They
are not chain transactions — they enumerate exactly the fields that would be
written to the registry so they can be hashed, signed, or shown to a judge
deterministically. Both are built from an AgentIdentity + AgentMetadata via
build(...).
Erc8004Record(schema = "erc8004:1"):schema,agent_id,owner,metadata_uri,strategy_hash,policy_hash,version.Erc8183Record(schema = "erc8183:1"):schema,agent_id,agent_name,controller,metadata_uri,policy_hash,version.
Registration artifacts
registration.rs builds the payload that would be submitted to a registry.
build_registration_request(identity, metadata) assembles a
RegistrationRequest; its registration_id() is the SHA-256 of the request's
canonical JSON (field-ordered, stable) — a deterministic id with no chain call.
build_registration_receipt(request, tx) records the outcome, optionally
carrying a transaction hash anchored out-of-band (e.g. the TWAK competition
registration tx). The on-chain registration itself runs through TWAK — see
TWAK_INTEGRATION.md.
Hashing and proof
report_hash provides sha256_hex(bytes) and sha256_hex_str(&str) producing
deterministic lowercase-hex digests for report artifacts and the strategy/policy
commitments.
AgentProof (proof.rs) is the judge-facing bundle: agent_id,
wallet_address, optional registration_tx, policy_hash, and report_hash.
It formats BscScan explorer links (BSCSCAN_BASE_URL = https://bscscan.com):
address_url()→https://bscscan.com/address/{wallet_address}tx_url()→https://bscscan.com/tx/{registration_tx}(when a tx is present)
These are pure string formatting — no network access.
End-to-end proof flow in the runtime
agent-runtime/src/runtime.rs ties the commitments to the running agent:
- At startup it hashes the loaded risk policy file (
policy_hash = sha256_hex_str(policy_raw)) and derivesagent_idfrom the name + wallet. - The
AgentStartedevent recordsagent_id,wallet, andpolicy_hash. - At the end of the run it hashes the run summary (
report_hash), builds anAgentProof, and emits the BscScanaddress_url/registration_tx_urlin theAgentReportPublishedevent and the on-disk run report. This lets a judge verify the agent's identity, its committed policy, and its published report from chain links alone.
"Best Use of BNB AI Agent SDK" map
| Criterion | Where it lives |
|---|---|
| Standards compliance | Erc8004Record (erc8004:1) and Erc8183Record (erc8183:1) mirror the BNB AI-Agent identity registry shapes. |
| Verifiable identity | AgentIdentity::agent_id() deterministic SHA-256; RegistrationRequest::registration_id() deterministic over canonical JSON. |
| Policy/report commitments | policy_hash and report_hash bind the running agent to its exact policy and published report. |
| On-chain proof | AgentProof + BscScan address_url/tx_url; competition registration tx anchored via TWAK (contract 0x212c61b9b72c95d95bf29cf032f5e5635629aed5). |
| Independent on-chain verification | chain-verifier performs read-only BSC JSON-RPC checks that confirm the contract is deployed and the registration tx was mined — verifiable, not self-attested (see below). |
| Separation of concerns | Identity/proof isolated in bnb-agent (deterministic, chain-free); the optional on-chain reads live in a separate chain-verifier crate, so the core artifacts stay reproducible and testable. |
Independent on-chain verification (chain-verifier)
The hashing and proof artifacts above are deterministic and self-attested —
a verifier can recompute them, but recomputation alone does not prove the claim
is anchored on the chain. The chain-verifier crate closes that gap with
read-only BSC JSON-RPC calls (no keys, no signing, cannot move funds):
| Check | RPC method | What it proves |
|---|---|---|
onchain_chain_id |
eth_chainId |
The endpoint is BSC mainnet (chain id 56). |
onchain_contract_code |
eth_getCode |
The competition contract has deployed bytecode on-chain. |
onchain_registration_receipt |
eth_getTransactionReceipt |
The registration tx (when anchored) was mined with status=success and to = the competition contract. |
The checks are ABI-free on purpose — they never guess a registry view
selector, so every claim is one a judge can reproduce with cast/curl.
Registration may be sponsored by a paymaster/relayer, so a from other than the
agent wallet is not treated as a failure (it is only noted when it matches).
Offline-safe. When BSC_RPC_URL is unset the checks return skipped rather
than failing, so the paper/demo flow stays green. Set BSC_RPC_URL to verify
against the live chain.
Three surfaces consume it:
- API —
GET /proof/verifyappends the on-chain checks (readsBSC_RPC_URL). - Dashboard —
/proofrenders a dedicated "On-chain Verification" section. - Standalone —
clients/proof-verifier/verify.py --rpc <URL>mirrors the exact same checks using only the Python standard library.
Verified against live BSC mainnet: the competition contract
0x212c61b9b72c95d95bf29cf032f5e5635629aed5returns ~2.5 KB of deployed bytecode viaeth_getCode.