Bridge Kit can estimate gas fees and provider fees before a transfer. Estimating
costs is optional but recommended.This example estimates costs for a transfer of 10 USDC from HyperEVM Testnet to
Arc Testnet:
TypeScript
Report incorrect code
Copy
import type { BridgeParams } from "@circle-fin/bridge-kit";const params: BridgeParams = { from: { adapter, chain: "HyperEVM_Testnet" }, to: { adapter, chain: "Arc_Testnet" }, amount: "10.00",};// Estimate costsconst estimate = await kit.estimate(params);console.log( `Estimating ${estimate.amount} ${estimate.token} from ${estimate.source.chain} to ${estimate.destination.chain}`,);console.log("Estimated fees:", estimate.fees);const providerFee = estimate.fees.find( (fee) => fee.type === "provider",)?.amount;// Only proceed if the provider fee is less than 0.10 USDC// Also proceed if the `providerFee` variable is null/undefined since there is no provider fee to chargeif (providerFee == null || parseFloat(providerFee) < 0.1) { // Execute the crosschain transfer const result = await kit.bridge(params); console.log("Bridge completed:", result);} else { // Provider fee is 0.10 USDC or higher - abort transfer console.log("Provider fee is above threshold:", providerFee, "USDC");}