Demonstrates PrecisionLedger's deterministic execution → on-chain attestation cycle for the HeyElsa Agentic Fellowship.
An autonomous financial agent:
- Receives a task (P&L variance analysis)
- Runs a deterministic pipeline (Decimal-based, reproducible)
- Hashes inputs + outputs (SHA-256, salted)
- Produces an attestation record suitable for on-chain recording
- Any verifier can re-run the pipeline and confirm the hash matches
┌──────────────────────────────────────────────────────────────────┐
│ VERIFICATION FLOW │
├──────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────┐ ┌──────────────────┐ ┌────────────────────┐ │
│ │ Client │───▶│ Agent (ERC-8004 │───▶│ Deterministic │ │
│ │ Task │ │ Token #25904) │ │ Pipeline │ │
│ └─────────┘ └──────────────────┘ │ (Decimal math) │ │
│ └────────┬───────────┘ │
│ │ │
│ SHA-256 hash of│inputs + │
│ outputs │ │
│ ▼ │
│ ┌──────────────────────────────────────────────────────────┐ │
│ │ Attestation Record (JSON) │ │
│ │ ┌─────────────────────────────────────────────────────┐ │ │
│ │ │ workflow_id, workflow_hash, input_hash, │ │ │
│ │ │ deterministic_output_hash, agent_id, timestamp, │ │ │
│ │ │ client_ref (pseudonymous) │ │ │
│ │ └─────────────────────────────────────────────────────┘ │ │
│ └──────────────────────────┬───────────────────────────────┘ │
│ │ │
│ ┌───────────────┼───────────────┐ │
│ ▼ ▼ ▼ │
│ ┌───────────────┐ ┌──────────────┐ ┌──────────────────┐ │
│ │ Base L2 │ │ x402 │ │ Verifier │ │
│ │ Contract │ │ Payment │ │ Re-runs pipeline│ │
│ │ (on-chain) │ │ Settlement │ │ Compares hashes │ │
│ └───────────────┘ └──────────────┘ └──────────────────┘ │
│ │
└──────────────────────────────────────────────────────────────────┘
| Layer | Standard | Purpose |
|---|---|---|
| Identity | ERC-8004 | Agent token (#25904 on Base) — proves who executed |
| Payment | x402 | HTTP 402 micropayments — settles agent-to-agent fees |
| Proof | Attestation Contract | On-chain hash record — proves what was executed |
# Run the demo (generates analysis + attestation)
python3 scripts/demo/verified-execution-demo.py
# Output only JSON (for piping)
python3 scripts/demo/verified-execution-demo.py --json-only
# Verify a previously generated attestation
python3 scripts/demo/verified-execution-demo.py --verify scripts/demo/attestation-output.jsonNo dependencies beyond Python 3.8+ standard library.
1. Agent runs pipeline → output_hash = SHA-256(salt + canonical_output)
2. Agent records on Base → contract.attest(workflowId, inputHash, outputHash, ...)
3. Verifier gets attestation → contract.getAttestation(id) → outputHash
4. Verifier re-runs pipeline → recomputed_hash = SHA-256(salt + canonical_output)
5. Verifier compares → contract.verify(id, recomputed_hash) → true/false
- Financial data is never stored on-chain — only salted hashes
- Client identity is pseudonymous (
client_ref= hash, not name/EIN) - Salt is stored off-chain, shared only with authorized verifiers
- Salted hashing prevents rainbow-table attacks on financial amounts
attestation-contract.sol — a minimal contract for Base L2 that:
- Requires callers to hold an ERC-8004 agent token
- Stores
Attestationstructs (workflow ID, input/output hashes, agent ID, timestamp) - Emits
ExecutionAttestedevents for indexing - Provides
verify()for hash comparison - Supports workflow registration and attestation counting
| Function | Access | Purpose |
|---|---|---|
registerWorkflow() |
Agent holders | Register a new pipeline definition |
attest() |
Agent holders | Record an execution |
verify() |
Anyone | Compare output hash to attestation |
getAttestation() |
Anyone | Read full attestation details |
The agent must hold an ERC-8004 token to submit attestations. This creates a verifiable link between the on-chain identity and the execution record:
- Agent Token: #25904 on Base mainnet
- Token Contract: Checked via
IERC721.balanceOf()in the attestation contract - Purpose: Proves the attestation was submitted by a registered autonomous agent, not an arbitrary address
After attestation, the agent settles payment via x402:
- Agent completes execution and records attestation
- Agent requests payment from client's treasury via HTTP 402
- Client wallet signs EIP-3009
transferWithAuthorization - USDC transfer settles on Base
- Payment receipt links to attestation ID
This creates an auditable chain: task → execution → attestation → payment.
| File | Description |
|---|---|
verified-execution-demo.py |
Self-contained Python demo |
attestation-contract.sol |
Solidity contract for Base L2 |
attestation-output.json |
Generated attestation (after running demo) |
README.md |
This file |