SDK Integration

Sign and verify agent requests with the Self Agent ID SDKs

Self Agent ID provides three SDKs with identical feature parity:

Language
Package
Install

TypeScript

@selfxyz/agent-sdk

npm install @selfxyz/agent-sdk

Python

selfxyz-agent-sdk

pip install selfxyz-agent-sdk

Rust

self-agent-sdk

cargo add self-agent-sdk

Agent-Side: Signing Requests

Use SelfAgent to sign outbound API requests. The SDK attaches three headers to every request:

  • x-self-agent-address — the agent's Ethereum address

  • x-self-agent-signature — ECDSA signature of keccak256(timestamp + METHOD + path + bodyHash)

  • x-self-agent-timestamp — Unix timestamp (seconds)

import { SelfAgent } from "@selfxyz/agent-sdk";

const agent = new SelfAgent({
  privateKey: process.env.AGENT_PRIVATE_KEY!,
  registryAddress: "0xaC3DF9ABf80d0F5c020C06B04Cced27763355944",
  rpcUrl: "https://forno.celo.org",
});

// Signed fetch — headers are attached automatically
const res = await agent.fetch("https://api.example.com/protected", {
  method: "POST",
  body: JSON.stringify({ action: "hello" }),
});

Service-Side: Verifying Requests

Use SelfAgentVerifier to verify incoming agent requests. The verifier recovers the signer address from the ECDSA signature, derives the agent key, and checks isVerifiedAgent() on-chain.

Builder Pattern

Direct Verification

Security Defaults

SelfAgentVerifier defaults are strict:

Setting
Default
Description

requireSelfProvider

true

Only accept proofs from Self Protocol's provider

maxAgentsPerHuman

1

One agent per human (sybil resistance)

Replay protection

Enabled

Signature nonce + timestamp freshness

Timestamp window

300 seconds

Reject requests older than 5 minutes

circle-exclamation

Agent Status & Info

Proof Expiry

Agent proofs have a validity window. The SDK exposes expiry information and handles stale proofs:

circle-exclamation

A2A Agent Cards

Build and store standardized agent identity cards:

Cards follow the A2A format and are queryable via:

  • GET /api/cards/{chainId}/{agentId}

  • GET /.well-known/a2a/{agentId}?chain={chainId}

  • POST /api/a2a — A2A JSON-RPC endpoint for agent-to-agent communication

Last updated