Integrate Multi-Chain Agents

Open Monitor

1) Quick Setup

Create organization admin credentials client-side. Private key never leaves your browser.

2) Install SDK

Use the local SDK source directly from this repo:

src/lib/agent-sdk/index.ts

Usage:

import { ChromiaGuard } from "@/lib/agent-sdk";

const guard = new ChromiaGuard({
  apiUrl: "https://chromia-verified-ai-chat.netlify.app",
  orgName: process.env.CHROMIA_ORG_NAME!,
  agentPubkey: process.env.CHROMIA_AGENT_PUBKEY!,
});

const verdict = await guard.judge(
  "Transfer $2500 to supplier account",
  "Monthly invoice settlement"
);

if (!verdict.allowed) {
  throw new Error(`Blocked (${verdict.verdict}): ${verdict.reason}`);
}

// Execute chain transaction here, then report it:
await guard.reportTransaction({
  chainId: "bsc",
  txHash: "0x...",
  walletAddress: "0x...",
  eventType: "transfer",
  direction: "outbound",
  amountUsdCents: 250000,
  hadPriorJudgment: true,
  linkedJudgmentId: verdict.judgmentId,
});

3) Chain Examples

Wrap your chain actions with `judge()` and report completed txs via `reportTransaction()`.

import { JsonRpcProvider, Wallet } from "ethers";
import { ChromiaGuard } from "@/lib/agent-sdk";

const provider = new JsonRpcProvider(process.env.BSC_RPC_URL!);
const wallet = new Wallet(process.env.BSC_AGENT_PRIVATE_KEY!, provider);
const guard = new ChromiaGuard({
  apiUrl: process.env.CHROMIA_API_URL!,
  orgName: process.env.CHROMIA_ORG_NAME!,
  agentPubkey: process.env.CHROMIA_AGENT_PUBKEY!,
});

export async function runBscPayment(to: string, amountBnb: string) {
  const action = `Transfer ${amountBnb} BNB to ${to}`;
  const verdict = await guard.judge(action, "BSC treasury payout");
  if (!verdict.allowed) throw new Error(verdict.reason);

  const tx = await wallet.sendTransaction({
    to,
    value: BigInt(Math.floor(Number(amountBnb) * 1e18)),
  });
  await tx.wait();

  await guard.reportTransaction({
    chainId: "bsc",
    txHash: tx.hash,
    walletAddress: wallet.address,
    eventType: "transfer",
    direction: "outbound",
    tokenSymbol: "BNB",
    amountRaw: amountBnb,
    hadPriorJudgment: true,
    linkedJudgmentId: verdict.judgmentId,
  });
}

4) Test It Live

Run a real safety judgment against `/api/judge`.

5) Monitor & Risk Dashboard

Open the monitor to inspect alerts, approvals, policy violations, and cross-chain events.

Open `/risk-engine`