SDK/Reference

Owner and service clients

PREVIEW

The two HTTP clients for the Essey service. EsseyService signs in with the agent's own key and covers the agent's routes; EsseyOwner signs in with the owner's wallet key and covers what an owner does without the site. Neither sends a key: each signs a challenge, then transactions. Both throw SERVICE_REFUSED when the service answers without ok: true, naming the route, the status and the error. See Approve from a wallet key.

Signatures below are copied from the source; descriptions are the source's own doc comments.

From essey-owner.ts#

Exported by index.ts.

OwnerLenderForm#

The lender form as POST /v1/mandate/preview and the create action take it (services/selfserve/mandate.ts LenderForm).

TypeScript
export type OwnerLenderForm = {
  name: string;
  preset: string;
  aiMode?: boolean;
  totalBudget: string;
  minLoan: string;
  maxLoan: string;
  minRateBps: number;
  maxLtvBps: number;
  termsDays: number[];
  expiresAtMs: number;
};

OwnedAgent#

TypeScript
export type OwnedAgent = {
  id: string;
  name: string;
  side: SetupSide;
  preset: string;
  address: string;
  treasuryId: string | null;
  ownerCapId: string | null;
  agentCapId: string | null;
  cash?: { treasuryId: string; ownerCapId: string; agentCapId: string } | null;
  capExpiresAtMs: number | null;
  status: "setup" | "ready" | "revoked";
  revoked: boolean;
};

OwnerTxBody#

TypeScript
export type OwnerTxBody = { form?: Record<string, unknown>; amount?: string; loanId?: string };

Peek#

TypeScript
export type Peek = { address: string; side: SetupSide; expiresAtMs: number };

EsseyOwner#

The owner's side of the Essey service from a plain wallet key, with no site and no passkey: sign in, claim a self-run agent's setup code, sign the server's owner transactions. The service pays their gas; the key never leaves.

TypeScript
export class EsseyOwner {

constructor

TypeScript
  constructor(
    readonly baseUrl: string,
    private readonly signer: Signer,
    private readonly fetchFn: typeof fetch = (...a) => fetch(...a),
  )

signIn

TypeScript
  async signIn(): Promise<{ proof: string; expiresAtMs: number }>

peek

TypeScript
  async peek(code: string): Promise<Peek>

claim

Spends the code only if it names agent, the address the agent showed you; a code is one claim, by anyone.

TypeScript
  async claim(c: { code: string; agent: string; name: string; preset: string }): Promise<OwnedAgent>

preview

TypeScript
  async preview(form: OwnerLenderForm): Promise<{ sentence: string; chain: Record<string, unknown> }>

agents

TypeScript
  agents(): Promise<OwnedAgent[]>

agent

TypeScript
  agent(id: string): Promise<Record<string, unknown> & { agent: OwnedAgent }>

sign

POST /v1/agents/:id/tx, sign those exact bytes, execute: create with amount funds the treasury in the same tx.

TypeScript
  async sign(
    id: string,
    action: string,
    body: OwnerTxBody = {},
  ): Promise<{ digest: string; agent: OwnedAgent }>

fundGas

SUI for the agent's own gas as one new coin, paid by this wallet: coins mode needs one coin of AGENT_GAS_BUDGET.

TypeScript
  async fundGas(
    chain: Pick<EsseyChain, "client">,
    agent: string,
    mist: bigint,
  ): Promise<{ ok: boolean; digest: string }>

From essey-service.ts#

Exported by index.ts.

SetupSide#

TypeScript
export type SetupSide = "lender" | "borrower";

SetupView#

TypeScript
export type SetupView = {
  state: "waiting" | "expired" | "claimed" | "ready" | "revoked";
  side: SetupSide;
  expiresAtMs: number;
  owner: string | null;
  agentId: string | null;
  account: { treasuryId: string; agentCapId: string; cash?: { treasuryId: string; capId: string } } | null;
  capExpiresAtMs: number | null;
};

IssuedCredential#

credential.ts's reply, as JSON: every field is a decimal string over the wire.

TypeScript
export type IssuedCredential = {
  ax: string;
  ay: string;
  signature: { R8x: string; R8y: string; S: string };
  expiryMs: string;
  epoch: string;
  commitment: string;
};

SelfRunConfig#

TypeScript
export type SelfRunConfig = { sponsor: string; gasBudgetMax: string; perDay: number; perMinute: number };

EsseyService#

The optional Essey service as a self-run agent sees it (services/api/selfserve-api.ts /v1/agent/*). It signs in with the agent's own key, which only proves that key; it never receives an owner key and never sends the agent's.

TypeScript
export class EsseyService {

constructor

TypeScript
  constructor(
    readonly baseUrl: string,
    private readonly signer: Signer,
    private readonly fetchFn: typeof fetch = (...a) => fetch(...a),
  ) {}

  private call(method: string, path: string, body?: unknown): Promise<Reply>

signIn

TypeScript
  async signIn(): Promise<void>

selfRunConfig

TypeScript
  async selfRunConfig(): Promise<SelfRunConfig>

startSetup

TypeScript
  async startSetup(side: SetupSide): Promise<{ code: string; expiresAtMs: number }>

setup

TypeScript
  async setup(): Promise<SetupView | null>

legacySalePass

The old issuer-signed pass route. The server no longer serves it: membership.move has only from_proof. Use credential() plus provedPassFor for anything that reaches the chain.

TypeScript
  async legacySalePass(): Promise<{
    holder: string;
    keyVersion: string;
    expiresMs: string;
    signature: string;
  }>

credential

The issuer's half of a dregg credential: an EdDSA signature over Poseidon(commitment, expiry, epoch). The proof is built on the client from this plus the holder's own nullSecret, which the issuer never sees (C5), so proveMembership turns this into the ProvedPass that from_proof takes.

TypeScript
  async credential(commitment: bigint): Promise<IssuedCredential>

The agent signs; the service pays gas from its address balance (A6) or says why not.

TypeScript
  async sponsored(client: SuiGrpcClient, tx: Transaction, cfg: SelfRunConfig): Promise<string>

From chain.ts#

Exported by index.ts.

AGENT_GAS_BUDGET#

Every agent transaction's budget; in coins mode one SUI coin must hold at least this much.

TypeScript
export const AGENT_GAS_BUDGET = 50_000_000;