App Kit lets you collect a custom fee from your end users each time they spend
from a Unified Balance. Custom fees can only be configured for spend
transactions on destination blockchains, not deposits on source blockchains. To
learn how custom fees fit into the overall fee breakdown, see
How Unified Balance fees work.
If you use this feature, Arc keeps 10% of the custom fee you collect from your
end users.
Prerequisites
Before you begin, ensure that you’ve:
These are required so any example below runs with a valid kit and adapter.
Set a custom fee on a spend
This example spends 1.00 USDC from Base Sepolia and adds a 0.01 USDC custom fee
on the spend:
import { AppKit } 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 result = await kit.unifiedBalance.spend({
amount: "1.00",
from: {
adapter,
allocations: [{ amount: "1.00", chain: "Base_Sepolia" }],
},
to: {
adapter,
chain: "Arc_Testnet",
recipientAddress: "0xRecipientAddress",
},
config: {
customFee: {
value: "0.01", // 0.01 USDC collected as fee
recipientAddress: "0xYourFeeWalletAddress",
},
},
});