Package
lnes-agent-sdk-core
Version
0.1.1+
Registry
npm
Language
TypeScript

Installation

npm install lnes-agent-sdk-core

Importing the client

import { LnesM2MClient, LNES_PROGRAM_ID } from "lnes-agent-sdk-core";
VERIFY PROGRAM ID AT IMPORT TIME
console.log(LNES_PROGRAM_ID.toBase58());
// Expected: Fe8KhdiFWhKcPWH2N2Svqc3VSpK9EzN8nMh9pQ3cPCeD

API reference

estimateExergyGate() READ

Calculates whether a job clears the minimum economic threshold. Evaluates the gate formula: external_cost > settlement_cost + proof_cost + tx_cost + risk_margin.

Returns a boolean gate decision and estimated cost breakdown. Call this before any on-chain action.

openJob() WRITE

Creates or opens a settlement job using the LNES-01 program interface. Derives and funds an escrow PDA. Returns a jobId and escrowPda for use in settlement.

settleExergy() SETTLE

Submits the settlement instruction. Validates all inputs, routes USDC through LNES-01 program logic to defined vault destinations. Requires proof data, all account references, and the funded escrow.

Complete integration

import { LnesM2MClient, LNES_PROGRAM_ID } from "lnes-agent-sdk-core";
import { Connection, Keypair } from "@solana/web3.js";

const connection = new Connection("https://api.mainnet-beta.solana.com");
const agentWallet = Keypair.fromSecretKey(/* ... */);

const client = new LnesM2MClient(connection, agentWallet);

// 1. Verify program ID
console.assert(
  LNES_PROGRAM_ID.toBase58() === "Fe8KhdiFWhKcPWH2N2Svqc3VSpK9EzN8nMh9pQ3cPCeD",
  "Program ID mismatch — abort"
);

// 2. Estimate gate
const gateResult = await client.estimateExergyGate({ jobParams });
if (!gateResult.clears) {
  console.log("Job does not clear economic gate. Skip.");
  process.exit(0);
}

// 3. Open job
const { jobId, escrowPda } = await client.openJob({ jobParams });

// 4. (Execute compute work)
const { axiomHash, output } = await runComputeWork();

// 5. Settle
const settleTx = await client.settleExergy({
  jobId,
  axiomHash,
  tollUsdcMicroUnits: gateResult.toll,
  escrowPda,
  usdcMint,
  agentUsdcAccount,
  escrowUsdcAccount,
  vaultAccounts,
});

console.log("Settled:", settleTx.signature);