Skip to main content

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

ChainChain ID
Base8453
Arbitrum42161

Signature

registerAgentOnIdentityRegistry(
smartWallet: string,
chainId: SupportedChainId
): Promise<RegisterAgentResponse>

Parameters

ParameterTypeRequiredDescription
smartWalletstringYesThe smart wallet address to register as an agent
chainIdSupportedChainIdYesChain 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

  1. Fetch tokenUri: The SDK calls the Zyfai API to get a tokenUri for the given smart wallet which is storing the agent's metadata on IPFS.
  2. Encode call data: Encodes the register(tokenUri) function call for the Identity Registry contract
  3. Send transaction: Sends the transaction from the connected wallet to the Identity Registry
  4. Wait for confirmation: Waits for the transaction to be confirmed on-chain

Errors

ErrorCause
Smart wallet address is requiredEmpty or missing smartWallet parameter
Chain X is not supported for Identity RegistryUsing a chain other than Base (8453) or Arbitrum (42161)
API did not return a tokenUriThe Zyfai API failed to generate a tokenUri
Identity Registry registration transaction failedThe 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())