Connection, keys, deployment
Connect to a checked Sui node, load the agent's key, and describe the Essey objects a client talks to.
At a glance#
| Function | Returns | Throws |
|---|---|---|
connect(cfg) | EsseyChain | NETWORK_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) | Ed25519Keypair | KEY_FILE_REFUSED |
createAgentKeyFile(path, network) | the new address | KEY_FILE_REFUSED if the file exists |
deploymentOf(raw) | EsseyDeployment | INVALID_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.
export type EsseyNetwork = "localnet" | "testnet" | "mainnet";NetworkConfig#
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.
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#
export async function connect(cfg: NetworkConfig): Promise<EsseyChain>resolveNetwork#
export function resolveNetwork(cfg: NetworkConfig): { rpcUrl: string; graphqlUrl: string | null }assertChainId#
export function assertChainId(network: EsseyNetwork, chainId: string): voidTESTNET#
export const TESTNET = {
grpcUrl: "https://fullnode.testnet.sui.io:443",
graphqlUrl: "https://graphql.testnet.sui.io/graphql",
chainId: "69WiPg3DAQiwdxfncX6wYQ2siKwAe6L9BZthQea3JNMD",
} as const;MAINNET_CHAIN_ID#
export const MAINNET_CHAIN_ID = "4btiuiMPvEENsttpZC7CZ53DruC3MAgfznDbASZ7DR6S";LOCALNET_RPC_URL#
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.
export function loadAgentKey(path: string, network: EsseyNetwork): Ed25519KeypaircreateAgentKeyFile#
A fresh key file, mode 600; refuses to overwrite one that exists. Returns the new address.
export function createAgentKeyFile(path: string, network: EsseyNetwork): stringFrom 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).
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#
export const deploymentOf = (raw: Record<string, unknown>): EsseyDeployment => …From ids.ts#
Exported by index.ts.
SUI#
export const SUI = "0x2::sui::SUI";CLOCK#
export const CLOCK = "0x6";