import type { PlatformClient } from "./client"; import type { Erc8004DeployRequest, PresignIpfsUrlResponse, WorkflowData } from "./types"; /** * API for ERC-8004 agent identity operations on the OpenServ platform. * * ERC-8004 is an on-chain agent identity standard. This API enables: * - Deploying workspace agents to the blockchain as ERC-8004 tokens * - Managing web3 wallets associated with workspaces * - Presigning IPFS URLs for uploading agent registration files * - Querying callable triggers for on-chain service registration * - Signing feedback auth for reputation interactions * * @example * ```typescript * const client = new PlatformClient({ apiKey: 'your-key' }); * * // Generate a web3 wallet for the workspace * const wallet = await client.workflows.generateWallet({ id: 123 }); * * // Get a presigned IPFS URL for uploading the agent card * const { url } = await client.erc8004.presignIpfsUrl({ workflowId: 123 }); * * // Deploy to ERC-8004 * await client.erc8004.deploy({ * workflowId: 123, * erc8004AgentId: '8453:42', * stringifiedAgentCard: JSON.stringify(registrationFile), * walletAddress: '0x...', * network: 'base', * chainId: 8453, * }); * ``` */ export declare class Erc8004API { private client; constructor(client: PlatformClient); /** * Deploy a workspace agent to the ERC-8004 identity registry. * * This records the deployment details in the platform database. The actual * on-chain registration should be performed separately using the agent0 SDK. * Call this method both before and after blockchain registration to keep * the platform in sync. * * If the deploy fails (e.g. insufficient ETH for gas), the error is * enriched with the workspace wallet address and instructions for funding * it so you can retry. * * @param params - Deployment parameters * @param params.workflowId - The workflow (workspace) ID to deploy * @param params.erc8004AgentId - Agent ID in format "chainId:tokenId" * @param params.stringifiedAgentCard - JSON-stringified registration file * @param params.latestDeploymentTransactionHash - Transaction hash from on-chain registration * @param params.latestDeploymentTimestamp - Timestamp of the deployment * @param params.walletAddress - Wallet address that performed the deployment * @param params.network - Network name (e.g., "base") * @param params.chainId - Chain ID (e.g., 8453 for Base mainnet) * @param params.rpcUrl - RPC URL for the chain * @param params.swap - If true, swap USDC in the wallet to ETH for gas before deploying (not yet implemented) * @returns The updated workflow data * * @example * ```typescript * // Before blockchain registration (save initial state) * await client.erc8004.deploy({ * workflowId: 123, * erc8004AgentId: '', * stringifiedAgentCard: JSON.stringify(registrationFile), * walletAddress: '0x...', * network: 'base', * chainId: 8453, * rpcUrl: 'https://mainnet.base.org', * }); * * // ... perform on-chain registration ... * * // After blockchain registration (save final state with tx hash) * await client.erc8004.deploy({ * workflowId: 123, * erc8004AgentId: '8453:42', * stringifiedAgentCard: JSON.stringify(updatedRegistrationFile), * latestDeploymentTransactionHash: '0xabc...', * latestDeploymentTimestamp: new Date(), * walletAddress: '0x...', * network: 'base', * chainId: 8453, * rpcUrl: 'https://mainnet.base.org', * }); * ``` */ deploy(params: Erc8004DeployRequest & { workflowId: number; }): Promise; /** * Enrich a deploy error with the workspace wallet address and funding * instructions. Called automatically when deploy() fails. */ private enrichDeployError; /** * Register (or re-deploy) a workspace agent on-chain as an ERC-8004 identity. * * This is a high-level method that orchestrates the entire deployment: * 1. Reads workspace wallet and callable triggers * 2. Builds the ERC-8004 agent card JSON * 3. Uploads the agent card to IPFS via a presigned Pinata URL * 4. Registers on-chain (first deploy) or updates the URI (re-deploy) * 5. Saves the deployment state to the platform * * @param params.workflowId - The workflow (workspace) ID * @param params.privateKey - Funded private key for on-chain transactions (must have ETH for gas) * @param params.chainId - Chain ID (default: 8453 for Base mainnet) * @param params.rpcUrl - RPC URL (default: "https://mainnet.base.org") * @param params.name - Agent name override (defaults: single trigger → trigger name, else workspace name) * @param params.description - Agent description override (defaults: single trigger → trigger description, else workspace goal + service list) * @param params.image - Agent image URL (optional) * @returns Deployment result with agentId, IPFS CID, transaction hash, and URLs * * @example * ```typescript * const result = await client.erc8004.registerOnChain({ * workflowId: 123, * privateKey: '0x...', * name: 'My AI Agent', * description: 'An agent that does amazing things', * }); * console.log(result.agentId); // "8453:42" * console.log(result.txHash); // "0xabc..." * console.log(result.ipfsCid); // "bafkrei..." * console.log(result.blockExplorerUrl); // "https://basescan.org/tx/0xabc..." * console.log(result.scanUrl); // "https://www.8004scan.io/agents/base/42" * ``` */ registerOnChain(params: { workflowId: number; privateKey: string; chainId?: number; rpcUrl?: string; name?: string; description?: string; image?: string; }): Promise; /** * Upload a JSON string to IPFS using a presigned Pinata URL. */ private uploadToIpfs; /** * Extract the agent token ID from a registration transaction receipt. * Looks for the Registered event first, then falls back to Transfer event. */ private extractAgentIdFromReceipt; /** * Get a presigned IPFS URL for uploading an agent registration file. * * The returned URL is a signed Pinata upload URL that expires in 60 seconds. * Use it to upload the agent's registration file (agent card) to IPFS before * on-chain registration. * * @param params - Parameters * @param params.workflowId - The workflow (workspace) ID * @returns Object containing the presigned IPFS upload URL * * @example * ```typescript * const { url } = await client.erc8004.presignIpfsUrl({ workflowId: 123 }); * // Use the URL to upload agent card to IPFS within 60 seconds * ``` */ presignIpfsUrl(params: { workflowId: number; }): Promise; } /** * Result of a successful on-chain ERC-8004 registration. */ export interface RegisterOnChainResult { /** ERC-8004 agent ID in format "chainId:tokenId" (e.g., "8453:42") */ agentId: string; /** IPFS CID of the uploaded agent card */ ipfsCid: string; /** Transaction hash of the final on-chain transaction */ txHash: string; /** URL to view the agent card on IPFS */ agentCardUrl: string; /** URL to view the transaction on the block explorer */ blockExplorerUrl: string; /** URL to view the agent on 8004scan.io (e.g., "https://www.8004scan.io/agents/base/42") */ scanUrl: string; } //# sourceMappingURL=erc8004-api.d.ts.map