GitHunt
H4

h4x3rotab/erc-8004-ex-phala

ERC-8004 in action!

ERC-8004 TEE Agent

Trustless agents with Intel TDX on Base Sepolia. 0.0001 ETH registration fee.

Features

  • ๐Ÿ” TEE-derived keys (Intel TDX via Phala dstack)
  • ๐ŸŒ ERC-8004 compliant agent cards
  • ๐Ÿ“œ TEE attestation (mock signatures for testing)
  • ๐Ÿ”— On-chain registration (0.0001 ETH)
  • ๐Ÿค– A2A protocol (POST /tasks, GET /tasks/{id})
  • ๐Ÿ–๏ธ AIO Sandbox integration

Quick Start

git clone https://github.com/HashWarlock/erc-8004-ex-phala.git
cd erc-8004-ex-phala
cp .env.example .env
# Edit .env with your config
docker compose up -d

Manual Setup

git clone https://github.com/HashWarlock/erc-8004-ex-phala.git
cd erc-8004-ex-phala
pip install -e .
cp .env.example .env
# Edit .env with your config
python deployment/local_agent_server.py

Open http://localhost:8000

See QUICKSTART.md for details

Project Structure

erc-8004-ex-phala/
โ”œโ”€โ”€ contracts/             # Solidity contracts
โ”‚   โ”œโ”€โ”€ IdentityRegistry.sol (deployed: 0x8506e13d47faa2DC8c5a0dD49182e74A6131a0e3)
โ”‚   โ””โ”€โ”€ TEERegistry.sol
โ”œโ”€โ”€ src/agent/            # Core agent logic
โ”‚   โ”œโ”€โ”€ tee_auth.py      # TEE key derivation
โ”‚   โ”œโ”€โ”€ tee_verifier.py  # TEE registration
โ”‚   โ””โ”€โ”€ registry.py      # On-chain registry client
โ”œโ”€โ”€ src/templates/        # Agent templates
โ”‚   โ””โ”€โ”€ server_agent.py  # AIO Sandbox agent
โ”œโ”€โ”€ deployment/           # Server
โ”‚   โ””โ”€โ”€ local_agent_server.py
โ””โ”€โ”€ static/              # Web UI
    โ”œโ”€โ”€ dashboard.html   # Registration flow
    โ””โ”€โ”€ funding.html     # QR code funding

Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Wallet    โ”‚ Fund with Base Sepolia ETH
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Register   โ”‚ Identity Registry (on-chain)
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ TEE Verify  โ”‚ Attestation + Code Measurement
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚    Ready    โ”‚ A2A endpoints active
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

API Endpoints

  • GET / - Funding page
  • GET /dashboard - Registration flow
  • GET /api/status - Agent status (checks on-chain)
  • GET /api/wallet - Wallet address & balance
  • POST /api/register - Register agent (0.0001 ETH)
  • POST /api/tee/register - Register TEE key
  • GET /.well-known/agent-card.json - ERC-8004 agent card
  • POST /tasks - Create A2A task
  • GET /tasks/{id} - Query task status

Deployed Contracts

Base Sepolia:

  • IdentityRegistry: 0x8506e13d47faa2DC8c5a0dD49182e74A6131a0e3 (0.0001 ETH fee)
  • TEERegistry: 0x03eCA4d903Adc96440328C2E3a18B71EB0AFa60D
  • Verifier: 0x481ce1a6EEC3016d1E61725B1527D73Df1c393a5

Configuration

See .env.example:

AGENT_DOMAIN=localhost:8000
AGENT_SALT=unique-salt
IDENTITY_REGISTRY_ADDRESS=0x8506e13d47faa2DC8c5a0dD49182e74A6131a0e3
TEE_REGISTRY_ADDRESS=0x03eCA4d903Adc96440328C2E3a18B71EB0AFa60D

Documentation

How It Works

  1. Generate Wallet - TEE derives keys from domain+salt
  2. Fund - Add 0.0001 ETH to agent address
  3. Register - Call Identity Registry newAgent()
  4. Verify TEE - Submit attestation to TEE Registry
  5. Go Live - A2A endpoints ready

Trust Model: Hardware-backed cryptographic proof via Intel TDX attestation

Tech Stack

  • TEE: Intel TDX (Phala dstack)
  • Chain: Base Sepolia
  • Backend: Python/FastAPI
  • Contracts: Solidity ^0.8.20
  • Frontend: HTML/Tailwind

Development

# Run server
python deployment/local_agent_server.py

# Test
pytest tests/

# Deploy contracts
./scripts/deploy_contracts.sh

ERC-8004 Compliance

โœ… Agent Cards
โœ… Identity Registry
โœ… TEE Registry
โœ… A2A Protocol
โœ… Attestation Verification

License

MIT

h4x3rotab/erc-8004-ex-phala | GitHunt