pub struct SelfAgent { /* private fields */ }Expand description
Agent-side SDK for Self Agent ID.
The agent’s on-chain identity is its Ethereum address, zero-padded to bytes32. For off-chain authentication, the agent signs each request with its private key.
Implementations§
Source§impl SelfAgent
impl SelfAgent
Sourcepub fn new(config: SelfAgentConfig) -> Result<Self, Error>
pub fn new(config: SelfAgentConfig) -> Result<Self, Error>
Create a new agent instance.
Sourcepub async fn is_registered(&self) -> Result<bool, Error>
pub async fn is_registered(&self) -> Result<bool, Error>
Check if this agent is registered and verified on-chain.
Sourcepub async fn get_info(&self) -> Result<AgentInfo, Error>
pub async fn get_info(&self) -> Result<AgentInfo, Error>
Get full agent info from the registry.
Sourcepub async fn sign_request(
&self,
method: &str,
url: &str,
body: Option<&str>,
) -> Result<HashMap<String, String>, Error>
pub async fn sign_request( &self, method: &str, url: &str, body: Option<&str>, ) -> Result<HashMap<String, String>, Error>
Generate authentication headers for a request.
Signature covers: keccak256(timestamp + METHOD + canonicalPathAndQuery + bodyHash)
Sourcepub async fn sign_request_with_timestamp(
&self,
method: &str,
url: &str,
body: Option<&str>,
timestamp: &str,
) -> Result<HashMap<String, String>, Error>
pub async fn sign_request_with_timestamp( &self, method: &str, url: &str, body: Option<&str>, timestamp: &str, ) -> Result<HashMap<String, String>, Error>
Sign a request with a specific timestamp (useful for testing).
Sourcepub async fn fetch(
&self,
url: &str,
method: Option<Method>,
body: Option<String>,
) -> Result<Response, Error>
pub async fn fetch( &self, url: &str, method: Option<Method>, body: Option<String>, ) -> Result<Response, Error>
Wrapper around reqwest that automatically adds agent signature headers.
Sourcepub async fn get_agent_card(
&self,
) -> Result<Option<Erc8004AgentDocument>, Error>
pub async fn get_agent_card( &self, ) -> Result<Option<Erc8004AgentDocument>, Error>
Read the agent card from on-chain metadata (if set). Supports both the new ERC-8004 format and legacy A2A v0.1 cards.
Sourcepub async fn set_agent_card(
&self,
name: String,
description: Option<String>,
url: Option<String>,
skills: Option<Vec<AgentSkill>>,
) -> Result<B256, Error>
pub async fn set_agent_card( &self, name: String, description: Option<String>, url: Option<String>, skills: Option<Vec<AgentSkill>>, ) -> Result<B256, Error>
Build and write an A2A Agent Card to on-chain metadata. Returns the transaction hash.
Sourcepub async fn to_agent_card_data_uri(&self) -> Result<String, Error>
pub async fn to_agent_card_data_uri(&self) -> Result<String, Error>
Returns a data: URI containing the base64-encoded Agent Card JSON.
Sourcepub async fn get_credentials(&self) -> Result<Option<AgentCredentials>, Error>
pub async fn get_credentials(&self) -> Result<Option<AgentCredentials>, Error>
Read ZK-attested credentials for this agent from on-chain.
Sourcepub async fn get_verification_strength(&self) -> Result<u8, Error>
pub async fn get_verification_strength(&self) -> Result<u8, Error>
Read the verification strength score from the provider contract.
Sourcepub async fn request_registration(
req: RegistrationRequest,
api_base: Option<&str>,
) -> Result<RegistrationSession, RegistrationError>
pub async fn request_registration( req: RegistrationRequest, api_base: Option<&str>, ) -> Result<RegistrationSession, RegistrationError>
Initiate agent registration via the REST API.
Returns a RegistrationSession with a QR code URL and deep link
that the human operator must scan with the Self app.
Sourcepub async fn get_agent_info_rest(
agent_id: u64,
network: NetworkName,
api_base: Option<&str>,
) -> Result<Value, RegistrationError>
pub async fn get_agent_info_rest( agent_id: u64, network: NetworkName, api_base: Option<&str>, ) -> Result<Value, RegistrationError>
Query agent info via the REST API (no private key needed).
Sourcepub async fn get_agents_for_human(
address: &str,
network: NetworkName,
api_base: Option<&str>,
) -> Result<Value, RegistrationError>
pub async fn get_agents_for_human( address: &str, network: NetworkName, api_base: Option<&str>, ) -> Result<Value, RegistrationError>
Query all agents registered to a human address via the REST API.
Sourcepub async fn request_deregistration(
&self,
api_base: Option<&str>,
) -> Result<DeregistrationSession, RegistrationError>
pub async fn request_deregistration( &self, api_base: Option<&str>, ) -> Result<DeregistrationSession, RegistrationError>
Initiate deregistration for this agent via the REST API.
Returns a DeregistrationSession with a QR code URL that the
human operator must scan with the Self app to confirm removal.
Auto Trait Implementations§
impl Freeze for SelfAgent
impl !RefUnwindSafe for SelfAgent
impl Send for SelfAgent
impl Sync for SelfAgent
impl Unpin for SelfAgent
impl UnsafeUnpin for SelfAgent
impl !UnwindSafe for SelfAgent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more