Documentation Index
Fetch the complete documentation index at: https://docs.arc.network/llms.txt
Use this file to discover all available pages before exploring further.
App Kit can estimate gas fees and provider fees before making a bridge transfer,
and only proceed if the costs are acceptable.
Prerequisites
Before you begin, ensure that you’ve:
These are required so any example below runs with a valid kit and adapter.
Estimate costs
This example estimates costs for a bridge transfer of 1.00 USDC from Ethereum
Sepolia to Arc Testnet:
import { AppKit, type BridgeParams } from "@circle-fin/app-kit";
import { createViemAdapterFromPrivateKey } from "@circle-fin/adapter-viem-v2";
const kit = new AppKit();
const adapter = createViemAdapterFromPrivateKey({
privateKey: process.env.EVM_PRIVATE_KEY as string,
});
const params: BridgeParams = {
from: { adapter, chain: "Ethereum_Sepolia" },
to: { adapter, chain: "Arc_Testnet" },
amount: "1.00",
};
// Estimate costs
const estimate = await kit.estimateBridge(params);
console.log(
`Estimating ${params.amount} USDC from ${params.from.chain} to ${params.to.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 charge
if (providerFee == null || parseFloat(providerFee) < 0.1) {
// Execute the bridge transfer
const result = await kit.bridge(params);
console.log("Bridge transfer completed:", result);
} else {
// Provider fee is 0.10 USDC or higher - abort the bridge transfer
console.log("Provider fee is above threshold:", providerFee, "USDC");
}