TypeScript SDK

The official @projectsilo/sdk package provides a typed client for the Project Silo REST API with full ESM and CJS support.

Install

shellbash
npm install @projectsilo/sdk

Create a client

index.tsts
import { createClient } from "@projectsilo/sdk";

const silo = createClient({
  apiKey: process.env.PROJECT_SILO_API_KEY!,
  // baseUrl: "https://api.projectsilo.app", // default
});

Deposit accounts

deposit-accounts.tsts
// Create a deposit account for a user
const account = await silo.depositAccounts.create({
  externalUserId: "user_123",
  destination: {
    chainId: 137,
    address: "0x1111111111111111111111111111111111111111",
    tokenAddress: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
  },
});
console.log(account.depositAddresses);

// List all deposit accounts
const accounts = await silo.depositAccounts.list({ limit: 50 });

// Get a specific account
const acct = await silo.depositAccounts.get("user_123");

// Update destination
await silo.depositAccounts.updateDestination({
  externalUserId: "user_123",
  destination: { chainId: 8453, address: "0x2222...", tokenAddress: "0x3333..." },
});

Fee preview

fees.tsts
const quote = await silo.fees.preview({
  sourceChainId: 8453,
  sourceAsset: "USDC",
  amount: "100.00",
  destinationChainId: 137,
  destinationAsset: "USDC.e",
  routeCostUsd: 0.03,
});
console.log(quote.netCreditUsd, quote.effectiveBps);

Webhooks

webhooks.tsts
// Create an endpoint
const { endpoint, secret } = await silo.webhooks.createEndpoint({
  name: "Production",
  url: "https://example.com/project-silo/webhook",
  eventTypes: ["deposit.credited", "deposit.failed"],
});

// Verify webhook signatures (HMAC-SHA256 over "{timestamp}.{rawBody}")
import { verifyWebhookSignature } from "@projectsilo/sdk";

const isValid = await verifyWebhookSignature(
  requestBody,     // raw body (string or Uint8Array)
  signatureHeader, // x-project-silo-signature header (v1=<hex>)
  timestampHeader, // x-project-silo-timestamp header (unix seconds)
  secret,          // endpoint signing secret
  // optional: { toleranceSeconds: 300 } — max clock skew before rejecting
);

Error handling

errors.tsts
import { ProjectSiloError } from "@projectsilo/sdk";

try {
  await silo.depositAccounts.get("nonexistent");
} catch (err) {
  if (err instanceof ProjectSiloError) {
    console.log(err.status);  // 404
    console.log(err.code);    // "not_found"
    console.log(err.message); // "Project Silo API 404: ..."
  }
}