getAgent
Recover an Agent instance for an ENS name you already provisioned.
Signature
import type { GetAgentOptions, Agent } from "@agensai/sdk";
declare function getAgent(
ensName: string,
options: GetAgentOptions,
): Promise<Agent>;Example
import { getAgent } from "@agensai/sdk";
const agent = await getAgent("my-agent.agensai.eth", {
apiKey: process.env.AGENSAI_API_KEY!,
ownerPrivateKey: process.env.AGENSAI_OWNER_PRIVATE_KEY! as `0x${string}`,
});
await agent.execute({ to: "bob.eth", amount: "1 USDC" });Parameters
| Field | Type | Description |
|---|---|---|
ensName | string | Full ENS name. Must already exist under your namespace. |
options.apiKey | string | Your AGENSAI API key. |
options.ownerPrivateKey | `0x${string}` | Owner key authorized for this agent. |
options.chainId | number? | Override chain. Defaults to the agent's deployment chain. |
Errors
- Throws if the ENS name does not exist.
- Throws if the owner key is not authorized for this agent.
- Throws if the agent's policies have been revoked and you attempt to act on it.