Bridge Kit lets you customize your setup to collect a developer fee on transfers. You can set this fee globally for the kit or on each bridge call. Setting the fee on each bridge call overrides the global fee. You can set a flat or dynamic fee based on the parameters.
This example code configures your bridge call to collect a fee of 1.5 USDC for that specific bridge transfer:
// Transfer 1 USDC
const result = await kit.bridge({
from: { adapter, chain: "Ethereum" },
to: { adapter, chain: "Base" },
amount: "1",
// Collect a fee of 1.5 USDC on this transfer and override the global fee, if set
config: {
customFee: {
value: "1.5",
recipientAddress: "YOUR_WALLET_ADDRESS",
},
},
});
The following example demonstrates how to configure a global fee policy that collects a fee of 1 USDC when the source chain is Ethereum, and 1.5 USDC for all other source chains:
import { Blockchain } from "@circle-fin/bridge-kit";
const kit = new BridgeKit();
kit.setCustomFeePolicy({
calculateFee: (params) => {
// Charge a flat fee of 1 USDC if the source chain is Ethereum and 1.5 USDC on other chains
return params.source.chain.chain == Blockchain.Ethereum ? "1" : "1.5";
},
resolveFeeRecipientAddress: (feePayoutChain, params) => {
// Change the recipient address if the source chain is Ethereum
return params.source.chain.chain == Blockchain.Ethereum
? "YOUR_WALLET_ADDRESS"
: "YOUR_OTHER_WALLET_ADDRESS";
},
});