import { PactaClient, ConditionPreset } from "@pacta/sdk"
import crypto from "crypto"
const pacta = new PactaClient({ network: "testnet" })
// Hash the off-chain job description document
const termsHash = "0x" + crypto
.createHash("sha3-256")
.update(JSON.stringify({
title: "Build a landing page",
deliverable: "Figma file + deployed Next.js site",
deadline: "2026-04-01",
payment: "500 SUI",
}))
.digest("hex")
// Create the agreement
await pacta.createAgreement(clientSigner, {
partyA: clientSigner.address, // client
partyB: freelancerAddress, // freelancer
arbiter: platformWalletAddress, // your platform resolves disputes
releaseConditions: ConditionPreset.FullConsent, // both deposit + both approve
termsHash,
expiryMs: BigInt(Date.now() + 30 * 24 * 60 * 60 * 1000), // 30 days
unlockTimeMs: 0n,
})
// Client deposits payment into the agreement
await pacta.depositCoin(clientSigner, {
agreementId: agreementId,
coinObjectId: clientCoinObjectId, // the SUI coin object to lock
coinType: "0x2::sui::SUI",
})