SDK/Reference

Connection, keys, deployment

PREVIEW

Connect to a checked Sui node, load the agent's key, and describe the Essey objects a client talks to.

At a glance#

FunctionReturnsThrows
connect(cfg)EsseyChainNETWORK_REFUSED: a network other than localnet/testnet/mainnet, a host that is not that network's, a chain id that does not match the network, or the mainnet chain id on a localnet or testnet connection
loadAgentKey(path, network)Ed25519KeypairKEY_FILE_REFUSED
createAgentKeyFile(path, network)the new addressKEY_FILE_REFUSED if the file exists
deploymentOf(raw)EsseyDeploymentINVALID_ARGUMENT for a missing field or a bad pool

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

From network.ts#

Exported by index.ts.

EsseyNetwork#

Mainnet must be asked for by name: a localnet or testnet config still refuses a mainnet chain id. Essey has no mainnet deployment.

TypeScript
export type EsseyNetwork = "localnet" | "testnet" | "mainnet";

NetworkConfig#

TypeScript
export type NetworkConfig = { network: EsseyNetwork; rpcUrl?: string; graphqlUrl?: string };

EsseyChain#

A live, checked connection: every SDK read and every signature goes through one of these.

TypeScript
export type EsseyChain = {
  network: EsseyNetwork;
  client: SuiGrpcClient;
  chainId: string;
  events: EventReader;
  /** What touched an object, from GraphQL; null on localnet, which has no transaction filter by object. */
  touches: TouchReader | null;
  /** Re-reads the chain id; throws NETWORK_REFUSED if the node now answers for another chain. */
  live(): Promise<void>;
  /** Testnet: waits until GraphQL has indexed the digest, so the next read sees it. Localnet: returns at once. */
  indexed(digest: string): Promise<void>;
};

connect#

TypeScript
export async function connect(cfg: NetworkConfig): Promise<EsseyChain>

resolveNetwork#

TypeScript
export function resolveNetwork(cfg: NetworkConfig): { rpcUrl: string; graphqlUrl: string | null }

assertChainId#

TypeScript
export function assertChainId(network: EsseyNetwork, chainId: string): void

TESTNET#

TypeScript
export const TESTNET = {
  grpcUrl: "https://fullnode.testnet.sui.io:443",
  graphqlUrl: "https://graphql.testnet.sui.io/graphql",
  chainId: "69WiPg3DAQiwdxfncX6wYQ2siKwAe6L9BZthQea3JNMD",
} as const;

MAINNET_CHAIN_ID#

TypeScript
export const MAINNET_CHAIN_ID = "4btiuiMPvEENsttpZC7CZ53DruC3MAgfznDbASZ7DR6S";

LOCALNET_RPC_URL#

TypeScript
export const LOCALNET_RPC_URL = "http://127.0.0.1:9000";

From key.ts#

Exported by index.ts.

loadAgentKey#

The agent's own key and the only key the SDK ever loads. The file is tagged with its network, and its address line must match the key, so a file copied between networks or edited by hand is refused.

TypeScript
export function loadAgentKey(path: string, network: EsseyNetwork): Ed25519Keypair

createAgentKeyFile#

A fresh key file, mode 600; refuses to overwrite one that exists. Returns the new address.

TypeScript
export function createAgentKeyFile(path: string, network: EsseyNetwork): string

From deployment.ts#

Exported by index.ts.

EsseyDeployment#

The Essey on Sui objects a client talks to; agents/deploy.ts writes records of this shape (deployments/*.json).

TypeScript
export type EsseyDeployment = {
  chainId: string;
  pkg: string;
  loanCoin: string;
  /** The oracle reader every fill, borrow, refinance and liquidation starts with, e.g. `pyth_oracle::read`. */
  reader: string;
  /**
   * Package that publishes `reader` when that module is not inside `pkg`. The 2026-11-05 cutover publishes
   * `essey_oracle_pyth` on its own. Unset on the older integrated publishes, where `pyth_oracle` lives in `pkg`.
   */
  oraclePkg?: string | null;
  feed: string;
  market: string;
  pool: string | null;
  /** Shared `essey_access::access::Access`. The cutover package takes it on deposit, post, fill and pool borrow. */
  access?: string | null;
};

deploymentOf#

TypeScript
export const deploymentOf = (raw: Record<string, unknown>): EsseyDeployment => …

From ids.ts#

Exported by index.ts.

SUI#

TypeScript
export const SUI = "0x2::sui::SUI";

CLOCK#

TypeScript
export const CLOCK = "0x6";