Skip to main content

ensip25/
lib.rs

1//! # ENSIP-25: AI Agent Registry ENS Name Verification
2//!
3//! A type-safe Rust SDK for [ENSIP-25](https://docs.ens.domains/ensip/25) —
4//! verify the bidirectional link between ENS names and AI agent identities
5//! registered in on-chain registries such as
6//! [ERC-8004](https://eips.ethereum.org/EIPS/eip-8004).
7//!
8//! ## How it works
9//!
10//! ENSIP-25 defines a parameterized ENS text record key:
11//!
12//! ```text
13//! agent-registration[<registry>][<agentId>]
14//! ```
15//!
16//! Where `<registry>` is the [ERC-7930](https://eips.ethereum.org/EIPS/eip-7930)
17//! interoperable address of the on-chain registry and `<agentId>` is the
18//! agent's unique identifier. If the ENS name owner sets this text record to
19//! any non-empty value, the association is considered verified.
20//!
21//! ## Feature flags
22//!
23//! | Feature | Default | Description |
24//! |---------|---------|-------------|
25//! | `provider` | off | Enables on-chain verification via alloy provider |
26//! | `erc8004` | off | Adds ERC-8004 integration (implies `provider`) |
27//! | `serde` | off | Derives `Serialize` / `Deserialize` on core types |
28//!
29//! ## Quick Start — Offline key construction
30//!
31//! ```rust
32//! use ensip25::record_key::evm_record_key;
33//!
34//! let registry: alloy_primitives::Address =
35//!     "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432".parse().unwrap();
36//!
37//! let key = evm_record_key(1, registry, 42).unwrap();
38//! assert_eq!(
39//!     key,
40//!     "agent-registration[0x000100000101148004a169fb4a3325136eb29fa0ceb6d2e539a432][42]"
41//! );
42//! ```
43//!
44//! ## Quick Start — On-chain verification (`provider` feature)
45//!
46//! ```rust,ignore
47//! use alloy::providers::ProviderBuilder;
48//! use ensip25::verify::verify;
49//!
50//! let provider = ProviderBuilder::new()
51//!     .connect_http("https://eth.llamarpc.com".parse()?);
52//!
53//! let registry = "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432".parse()?;
54//! let status = verify(&provider, "vitalik.eth", 1, registry, 42).await?;
55//! println!("verified: {}", status.is_verified());
56//! ```
57//!
58//! ## Quick Start — ERC-8004 integration (`erc8004` feature)
59//!
60//! ```rust,ignore
61//! use alloy::providers::ProviderBuilder;
62//! use ensip25::verify::verify_agent;
63//!
64//! let provider = ProviderBuilder::new()
65//!     .connect_http("https://eth.llamarpc.com".parse()?);
66//!
67//! let status = verify_agent(
68//!     &provider,
69//!     erc8004::Network::EthereumMainnet,
70//!     42,
71//!     "vitalik.eth",
72//! ).await?;
73//! ```
74
75pub mod erc7930;
76pub mod error;
77pub mod record_key;
78#[cfg(feature = "provider")]
79pub mod verify;
80
81#[cfg(feature = "erc8004")]
82pub use erc8004;
83pub use error::{Ensip25Error, Result};
84#[cfg(test)]
85use tokio as _;