SDK Reference
TypeScript SDK Documentation
Use the DexBotics TypeScript SDK to interact with the on-chain program for task creation, acceptance, proofs, and settlement.
Installation
Install the SDK with npm:
npm install @dexbotics/sdk @coral-xyz/anchor @solana/web3.jsSDK
client.createTask()Create Task
Create a new task with escrow and requirements hash
TypeScript Example
typescript
import { DexboticsClient } from "@dexbotics/sdk";
const client = new DexboticsClient({
cluster: "devnet",
walletPath: "~/.config/solana/id.json"
});
const requirementsHash = new Uint8Array(32).fill(7);
const taskPublicKey = await client.createTask({
priceLamports: 2_000_000,
collateralLamports: 1_000_000,
deadlineUnix: Math.floor(Date.now()/1000) + 3600,
requirementsHash32: requirementsHash
});
console.log("Task created:", taskPublicKey);SDK
client.acceptTask()Accept Task
Robot accepts a task and locks collateral
TypeScript Example
typescript
import { PublicKey } from "@solana/web3.js";
const taskPublicKey = new PublicKey("task_address");
const robotNft = new PublicKey("robot_nft_mint");
await client.acceptTask({
taskPublicKey,
robotNft
});
console.log("Task accepted");SDK
client.submitProof()Submit Proof
Robot submits proof hash for task completion
TypeScript Example
typescript
const taskPublicKey = new PublicKey("task_address");
const proofHash = new Uint8Array(32);
await client.submitProof({
taskPublicKey,
proofHash32: proofHash
});
console.log("Proof submitted");SDK
client.attestTask()Oracle Attestation
Oracle submits attestation vote on task completion
TypeScript Example
typescript
const taskPublicKey = new PublicKey("task_address");
await client.attestTask({
taskPublicKey,
approved: true
});
console.log("Attestation submitted");SDK
client.settleTask()Settle Task
Release escrow funds based on oracle consensus
TypeScript Example
typescript
const taskPublicKey = new PublicKey("task_address");
await client.settleTask({
taskPublicKey
});
console.log("Task settled");Additional Resources
- Full SDK source code available on GitHub
- Check the
sdk/ts/examples/directory for complete examples - Anchor IDL available at
sdk/ts/src/idl.json - Test on devnet before deploying to mainnet
Getting Help
Documentation
Browse the docs section for detailed guides and architecture overview
GitHub Issues
Report bugs or request features on the GitHub repository
Devnet Testing
Use cluster: "devnet" in the client configuration for testing