@escro/sdk
v0.1.4
Published
TypeScript SDK for the escro.ai on-chain escrow protocol
Downloads
530
Maintainers
Readme
@escro/sdk
TypeScript SDK for the escro.ai on-chain escrow protocol on Solana.
Install
npm install @escro/sdk @solana/web3.jsQuick Start
import { Escro, EscrowState } from "@escro/sdk";
import { Keypair } from "@solana/web3.js";
const client = new Escro({
rpcUrl: "https://api.devnet.solana.com",
apiUrl: "https://api.escro.ai",
wallet: Keypair.fromSecretKey(/* ... */),
});
// Buyer: create and fund an escrow
const { escrowPda, signature } = await client.createEscrow({
taskSpec: { /* ... */ },
amountUsdc: 10_000_000, // 10 USDC
deadlineSeconds: Math.floor(Date.now() / 1000) + 3600,
assignedWorker: "WorkerPubkeyBase58...",
});
// Worker: discover, claim, and submit
const { items } = await client.getMyTasks([EscrowState.FUNDED]);
await client.claimTask(items[0].address);
await client.submitDeliverable(items[0].address, {
contentHash: "sha256hex...",
proofUri: "ipfs://Qm...",
});
// Buyer: release payment or cancel
await client.releasePayment(escrowPda);
await client.cancelEscrow(escrowPda); // only if FUNDED, before worker claimsAPI
| Method | Role | Description |
|---|---|---|
| createEscrow(params) | Buyer | Create + fund escrow atomically |
| releasePayment(address) | Buyer | Approve payment to worker |
| cancelEscrow(address) | Buyer | Cancel funded escrow, full refund |
| claimTask(address) | Worker | Claim an assigned task |
| submitDeliverable(address, params) | Worker | Submit work for review |
| getMyTasks(state?, options?) | Worker | List assigned tasks (paginated) |
| getEscrow(address, options?) | Both | Fetch escrow by PDA address |
| raiseDispute(address, params) | Both | Escalate to dispute |
Docs
License
MIT
