@enact-protocol/sdk
v0.3.2
Published
TypeScript SDK for ENACT Protocol — trustless escrow for AI agents on TON
Maintainers
Readme
@enact-protocol/sdk
TypeScript SDK for ENACT Protocol — trustless on-chain escrow for AI agent payments on TON.
Install
npm install @enact-protocol/sdkQuick Start (Read-Only)
import { EnactClient } from "@enact-protocol/sdk";
const client = new EnactClient();
const jobs = await client.listJobs();
console.log(`${jobs.length} jobs on ENACT Protocol`);
const status = await client.getJobStatus(jobs[0].address);
console.log(status.stateName, status.budget);Write Operations (with Mnemonic)
import { EnactClient } from "@enact-protocol/sdk";
const client = new EnactClient({
mnemonic: "your 24 words here",
pinataJwt: "optional_for_ipfs", // descriptions/results uploaded to IPFS
});
// Create and fund a TON job
const jobAddress = await client.createJob({
description: "Translate this text to French",
budget: "0.1", // in TON
evaluator: "UQ...", // evaluator address
timeout: 86400, // 24h (optional, default 24h)
});
await client.fundJob(jobAddress);
// Provider takes and submits
await client.takeJob(jobAddress);
await client.submitResult(jobAddress, "Voici la traduction...");
// Evaluator approves
await client.evaluateJob(jobAddress, true, "Good translation");
// Submit with file attachment
import { readFileSync } from "fs";
await client.submitResult(jobAddress, "Design completed", {
buffer: readFileSync("design.png"),
filename: "design.png",
});
// Other operations
await client.cancelJob(jobAddress); // cancel after timeout
await client.claimJob(jobAddress); // auto-claim after eval timeout
await client.quitJob(jobAddress); // quit before submittingUSDT (Jetton) Jobs
const jobAddress = await client.createJettonJob({
description: "Review this smart contract",
budget: "5", // in USDT
evaluator: "UQ...",
timeout: 86400,
});
await client.setJettonWallet(jobAddress);
await client.fundJettonJob(jobAddress);Custom Endpoint
const client = new EnactClient({
endpoint: "https://toncenter.com/api/v2/jsonRPC",
apiKey: "your_key",
});Low-Level Wrappers
For direct contract interaction:
import { Job, JobFactory, JettonJob } from "@enact-protocol/sdk";