registerAgentOnIdentityRegistry
Register an agent on the Identity Registry (ERC-8004). Fetches a tokenUri from the Zyfai API for the given smart wallet, then calls register(tokenUri) on the Identity Registry contract. Requires SIWE authentication.
Supported Chains
| Chain | Chain ID |
|---|---|
| Base | 8453 |
| Arbitrum | 42161 |
Signature
registerAgentOnIdentityRegistry(
smartWallet: string,
chainId: SupportedChainId
): Promise<RegisterAgentResponse>
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| smartWallet | string | Yes | The smart wallet address to register as an agent |
| chainId | SupportedChainId | Yes | Chain ID to register on (only 8453 or 42161) |
Returns
Response with transaction hash and registration details
Return Type
interface RegisterAgentResponse {
success: boolean;
txHash: string;
chainId: number;
smartWallet: string;
}
Example
import { ZyfaiSDK, SupportedChainId } from "@anthropic/zyfai-sdk";
const sdk = new ZyfaiSDK({ apiKey: "your-api-key" });
// Connect to Base
const chainId: SupportedChainId = 8453;
const connectedEOA = await sdk.connectAccount(privateKey, chainId);
console.log(`Connected EOA: ${connectedEOA}`);
// Get smart wallet address
const walletInfo = await sdk.getSmartWalletAddress(connectedEOA, chainId);
const smartWallet = walletInfo.address;
console.log(`Smart Wallet: ${smartWallet}`);
// Register agent on Identity Registry
const result = await sdk.registerAgentOnIdentityRegistry(smartWallet, chainId);
console.log("Registration successful:");
console.log(` Tx Hash: ${result.txHash}`);
console.log(` Chain ID: ${result.chainId}`);
console.log(` Smart Wallet: ${result.smartWallet}`);
How It Works
- Fetch tokenUri: The SDK calls the Zyfai API to get a
tokenUrifor the given smart wallet which is storing the agent's metadata on IPFS. - Encode call data: Encodes the
register(tokenUri)function call for the Identity Registry contract - Send transaction: Sends the transaction from the connected wallet to the Identity Registry
- Wait for confirmation: Waits for the transaction to be confirmed on-chain
Errors
| Error | Cause |
|---|---|
Smart wallet address is required | Empty or missing smartWallet parameter |
Chain X is not supported for Identity Registry | Using a chain other than Base (8453) or Arbitrum (42161) |
API did not return a tokenUri | The Zyfai API failed to generate a tokenUri |
Identity Registry registration transaction failed | The on-chain transaction reverted |
Notes
- Only Base (8453) and Arbitrum (42161) are supported for Identity Registry registration
- The smart wallet must be deployed before registration
- User must be authenticated (automatically done via
connectAccount())