Skip to content

samledger67-dotcom/verified-execution

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Verified Execution Demo

Demonstrates PrecisionLedger's deterministic execution → on-chain attestation cycle for the HeyElsa Agentic Fellowship.

What This Does

An autonomous financial agent:

  1. Receives a task (P&L variance analysis)
  2. Runs a deterministic pipeline (Decimal-based, reproducible)
  3. Hashes inputs + outputs (SHA-256, salted)
  4. Produces an attestation record suitable for on-chain recording
  5. Any verifier can re-run the pipeline and confirm the hash matches

Architecture

┌──────────────────────────────────────────────────────────────────┐
│                     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 │      │
│  └───────────────┘  └──────────────┘  └──────────────────┘      │
│                                                                  │
└──────────────────────────────────────────────────────────────────┘

Three-Layer Stack

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

How to Run

# 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.json

No dependencies beyond Python 3.8+ standard library.

Verification Flow

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

Privacy

  • 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

Solidity Contract

attestation-contract.sol — a minimal contract for Base L2 that:

  • Requires callers to hold an ERC-8004 agent token
  • Stores Attestation structs (workflow ID, input/output hashes, agent ID, timestamp)
  • Emits ExecutionAttested events for indexing
  • Provides verify() for hash comparison
  • Supports workflow registration and attestation counting

Key Functions

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

ERC-8004 Integration

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

x402 Integration

After attestation, the agent settles payment via x402:

  1. Agent completes execution and records attestation
  2. Agent requests payment from client's treasury via HTTP 402
  3. Client wallet signs EIP-3009 transferWithAuthorization
  4. USDC transfer settles on Base
  5. Payment receipt links to attestation ID

This creates an auditable chain: task → execution → attestation → payment.

Files

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

About

Deterministic financial pipelines with on-chain attestation via ERC-8004 on Base

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors