erc8004 0.2.5

ERC-8004 Trustless Agents Rust SDK.
Documentation

erc8004

CI crates.io docs.rs License Rust

Type-safe Rust SDK for the ERC-8004 Trustless Agents standard — on-chain identity, reputation, and validation registries for AI agents.

ERC-8004 enables discovery, reputation, and validation of AI agents across organizational boundaries without pre-existing trust. This SDK provides ergonomic, alloy-native bindings for all three registries, with 18 pre-configured network deployments (CREATE2 deterministic addresses) and full off-chain type support (registration files, service endpoints, feedback).

See Security before using in production.

Quick Start

Query an Agent (Read-Only)

use alloy::{primitives::U256, providers::ProviderBuilder};
use erc8004::{Erc8004, Network};

let provider = ProviderBuilder::new()
    .connect_http("https://eth.llamarpc.com".parse()?);

let client = Erc8004::new(provider)
    .with_network(Network::EthereumMainnet);

// Identity Registry — ERC-721 agent identity
let identity = client.identity()?;
let owner  = identity.owner_of(U256::from(1)).await?;
let uri    = identity.token_uri(U256::from(1)).await?;
let wallet = identity.get_agent_wallet(U256::from(1)).await?;

Register an Agent (Write)

use alloy::{network::EthereumWallet, providers::ProviderBuilder, signers::local::PrivateKeySigner};
use erc8004::{Erc8004, Network};

let signer: PrivateKeySigner = std::env::var("PRIVATE_KEY")?.parse()?;
let wallet = EthereumWallet::from(signer);

let provider = ProviderBuilder::new()
    .wallet(wallet)
    .connect_http("https://sepolia.base.org".parse()?);

let client = Erc8004::new(provider)
    .with_network(Network::BaseSepolia);

let agent_id = client.identity()?
    .register_with_uri("https://my-agent.example.com/erc8004.json")
    .await?;

Build a Registration File (Offline)

use erc8004::types::{RegistrationFile, ServiceEndpoint};

let mut reg = RegistrationFile::new(
    "WeatherBot",
    "An AI agent that provides real-time weather forecasts.",
);

reg.services.push(ServiceEndpoint {
    name: "A2A".to_owned(),
    endpoint: "https://weather-bot.example.com/.well-known/agent.json".to_owned(),
    version: Some("0.2".to_owned()),
    skills: None,
    domains: None,
});

reg.x402_support = true;
let json = reg.to_json()?;

Architecture

Module Description
Erc8004 Top-level client — generic over P: Provider, builder pattern for network / address configuration
Identity Identity Registry (ERC-721) — register agents, manage URIs, wallets, metadata, EIP-712 signatures
Reputation Reputation Registry — submit / revoke feedback, read aggregated summaries, list clients
Validation Validation Registry — request / respond to validation, query status and summaries
Network 18 pre-configured deployments (10 mainnet + 8 testnet) with CREATE2 deterministic addresses
types Off-chain JSON types — RegistrationFile, ServiceEndpoint, Feedback, ReputationSummary
contracts Inline Solidity bindings (sol! macro) — alloy-recommended, preserves full type information

Supported Networks

Contracts are deployed via CREATE2, so all mainnets share the same addresses and all testnets share the same addresses.

Network Type Chain ID
Ethereum mainnet 1
Base mainnet 8453
Polygon mainnet 137
Arbitrum One mainnet 42161
Celo mainnet 42220
Gnosis mainnet 100
Scroll mainnet 534352
Taiko (Alethia) mainnet 167000
Monad mainnet 143
BNB Smart Chain mainnet 56
Ethereum Sepolia testnet 11155111
Base Sepolia testnet 84532
Polygon Amoy testnet 80002
Arbitrum Sepolia testnet 421614
Celo Alfajores testnet 44787
Scroll Sepolia testnet 534351
Monad Testnet testnet 10143
BNB Smart Chain Testnet testnet 97

Design

  • Zero async_trait — pure RPITIT, no trait-object overhead
  • Inline Solidity bindingssol! macro preserves struct names, enums, and visibility; no JSON ABI files
  • Provider-generic — works with any alloy transport (HTTP, WebSocket, IPC) and any signer configuration
  • Strict lintingpedantic + nursery + correctness (deny), see clippy.toml
  • Lightweight instances — each Identity / Reputation / Validation call creates a zero-alloc contract handle

Examples

Example Description
query_agent Read agent identity from Ethereum mainnet
register_agent Register a new agent on Base Sepolia testnet
reputation_summary Query aggregated reputation and feedback entries
registration_file Build and serialize an off-chain registration file
multi_network Query the same registry across multiple chains
cargo run --example query_agent
cargo run --example registration_file

Security

See SECURITY.md for disclaimers, supported versions, and vulnerability reporting.

Acknowledgments

License

Licensed under either of:

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project shall be dual-licensed as above, without any additional terms or conditions.