Bridge Kit

Estimate Costs Before Transferring

Bridge Kit can provide an estimate of gas and provider fees before executing a transfer. Estimating costs is optional but recommended.

This example code estimates costs for a transfer of 10 USDC from Base to Ethereum:

Typescript
import type { BridgeParams } from "@circle-fin/bridge-kit";

const params: BridgeParams = {
  from: { adapter, chain: "Base" },
  to: { adapter, chain: "Ethereum" },
  amount: "10",
};

// Estimate costs
const estimate = await kit.estimate(params);
console.log("Estimated fees:", estimate);

const providerFee = estimate.fees.find((f) => f.type === "provider")?.amount;

// Only proceed if the provider fee is less than 0.1 USDC
// Also proceed if the `providerFee` variable is null/undefined since there is no provider fee to charge
if (providerFee == null || parseFloat(providerFee) < 0.1) {
  // Execute the crosschain transfer
  const result = await kit.bridge(params);
  console.log("Bridge completed:", result);
  // Error if the cost is over 5 USDC
} else {
  console.log("Provider fee is above threshold:", providerFee, "USDC");
}
Did this page help you?
© 2023-2025 Circle Technology Services, LLC. All rights reserved.