TBUSD Logo

Escrow API Documentation

Programmatic access to TBUSD Escrow for business integrations

Base URL: https://tbusd-escrow-api.jkm1317.workers.dev

Overview

The TBUSD Escrow API allows businesses to programmatically create and manage escrows. Perfect for marketplaces, freelance platforms, or any application that needs secure payment holding.

Note: This API provides read access and transaction building. Users must sign transactions with their own wallet - we never hold private keys.

Authentication

The API is currently open and does not require authentication. Rate limits apply: 100 requests per minute per IP.

Escrow Types

ID Name Description
0 Mutual Both parties must agree to release or refund
1 BuyerProtected Buyer controls release and refund
2 SellerProtected Seller controls release and refund
3 TimeRelease Auto-releases after deadline; buyer can refund before

Endpoints

GET /api/v1/info

Get API information and contract addresses

Response

{
  "name": "TBUSD Escrow API",
  "version": "1.0.0",
  "network": "Base Mainnet",
  "chainId": 8453,
  "contracts": {
    "factory": "0x73BEf257850A977D84E6e02b62dedBbb5757dbc2",
    "tbusd": "0x0d02E2E2a7ADaF2372ca0C69845c8b159A24a595"
  }
}
GET /api/v1/stats

Get factory statistics

Response

{
  "totalEscrows": 42,
  "factory": "0x73BEf257850A977D84E6e02b62dedBbb5757dbc2",
  "tbusd": "0x0d02E2E2a7ADaF2372ca0C69845c8b159A24a595",
  "network": "Base Mainnet"
}
GET /api/v1/escrow/{address}

Get details for a specific escrow

Parameters

Name Type Description
address string Escrow contract address Required

Response

{
  "address": "0x1234...5678",
  "depositor": "0xBuyer...",
  "recipient": "0xSeller...",
  "amount": "1000000000",
  "amountFormatted": "1000.00",
  "escrowType": "BuyerProtected",
  "escrowTypeId": 1,
  "status": "Funded",
  "statusId": 2,
  "description": "Domain purchase - example.com",
  "deadline": null,
  "acceptance": {
    "buyer": true,
    "seller": true
  }
}
GET /api/v1/escrows?wallet={address}

List all escrows for a wallet

Parameters

Name Type Description
wallet string Wallet address to query Required

Response

{
  "wallet": "0x1234...5678",
  "asDepositor": 3,
  "asRecipient": 2,
  "total": 5,
  "escrows": [
    { ... escrow details ... }
  ]
}
POST /api/v1/escrow/build

Build a transaction to create a new escrow

Request Body

Field Type Description
depositor string Buyer wallet address Required
recipient string Seller wallet address Required
amount string Amount in TBUSD (e.g., "100.00") Required
escrowType number Type ID (0-3) Required
deadline number Unix timestamp for TimeRelease Optional
description string Human-readable description Optional

Example Request

curl -X POST https://tbusd-escrow-api.jkm1317.workers.dev/api/v1/escrow/build \
  -H "Content-Type: application/json" \
  -d '{
    "depositor": "0xBuyerAddress...",
    "recipient": "0xSellerAddress...",
    "amount": "500.00",
    "escrowType": 1,
    "description": "Website purchase"
  }'

Response

{
  "to": "0x73BEf257850A977D84E6e02b62dedBbb5757dbc2",
  "value": "0x0",
  "chainId": 8453,
  "params": {
    "depositor": "0xBuyerAddress...",
    "recipient": "0xSellerAddress...",
    "amount": "500000000",
    "escrowType": 1,
    "deadline": 0,
    "description": "Website purchase"
  },
  "note": "Sign this transaction with your wallet to create the escrow"
}

Integration Example

Here's a complete example using JavaScript and ethers.js:

import { ethers } from 'ethers';

const API_BASE = 'https://tbusd-escrow-api.jkm1317.workers.dev';

// 1. Build the transaction via API
const response = await fetch(`${API_BASE}/api/v1/escrow/build`, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    depositor: buyerWallet,
    recipient: sellerWallet,
    amount: '500.00',
    escrowType: 1, // BuyerProtected
    description: 'Order #12345'
  })
});
const txData = await response.json();

// 2. User signs and sends transaction
const provider = new ethers.BrowserProvider(window.ethereum);
const signer = await provider.getSigner();
const factory = new ethers.Contract(txData.to, FACTORY_ABI, signer);

const tx = await factory.createEscrow(
  txData.params.depositor,
  txData.params.recipient,
  txData.params.amount,
  txData.params.escrowType,
  txData.params.deadline,
  txData.params.description
);

const receipt = await tx.wait();
console.log('Escrow created:', receipt);

// 3. Poll for status updates
const escrowAddress = '0x...'; // from receipt events
const details = await fetch(`${API_BASE}/api/v1/escrow/${escrowAddress}`);
console.log(await details.json());

Status Codes

Code Description
200 Success
400 Bad request - check parameters
404 Escrow not found
429 Rate limit exceeded
500 Internal server error

Support

For API support or integration help, contact us at [email protected]