Skip to content

Agent

The runtime handle returned by createAgent and getAgent. All ongoing operations on an agent flow through this object.

Properties

FieldTypeDescription
namestringFull ENS name, e.g. my-agent.agensai.eth
address`0x${string}`Smart account address
chainIdnumberActive chain
status"active" | "revoked"Current state

Methods

execute(call)

Submit a single transaction.

const txHash = await agent.execute({
  to: "treasury.acme.eth",
  amount: "10 USDC",
});

Accepts ENS names or 0x addresses. Accepts "10 USDC" strings or raw { value, data }.

batch(calls)

Submit an atomic batch. All calls succeed or all revert.

const { id } = await agent.batch([
  { to: "uniswap.eth", value: 0n, data: swapCalldata },
  { to: "treasury.acme.eth", amount: "5 USDC" },
]);

policies()

Read the active policy bundle from chain.

const active = await agent.policies();

addPolicy(policy)

Append a policy to the bundle. Onchain.

await agent.addPolicy({ type: "rate", count: 5, period: "hourly" });

revoke()

Permanently revoke every policy. The smart account survives but cannot act.

await agent.revoke();

Lifetime

An Agent instance is cheap. Construct it on demand. Don't try to share one across processes.