Swap fee
and the other ways the kit can earn for you.
NFC Crypto can add an optional operator fee to swaps that run through 0x, 1inch or Jupiter. It is off by default and capped at 2 %. The kit has no subscriptions, in-app purchases or checkout.
01How the swap fee works
You set a fee in basis points (1 bps = 0.01 %, so 30 bps = 0.3 %) and the address that receives it. The app sends these to the aggregator with each quote, and the aggregator pays the fee to your address as part of the user's swap. The swap review screen shows a Platform fee row with the percentage whenever a fee applies, so users see it before they confirm.
| Swap source | Fee parameters sent | Fee is taken from |
|---|---|---|
| 0x (EVM) | swapFeeBps, swapFeeRecipient, swapFeeToken | The token being sold |
| 1inch (EVM) | fee, referrerAddress | The token being sold |
| Jupiter (Solana) | platformFeeBps on the quote, feeAccount on the swap | The token being bought (see below) |
| Uniswap V2-style router (EVM, on chain) | None | No fee: this path does not charge one |
Source: lib/core/monetization/swap_fee_config.dart, lib/core/swap/swap_quote_service.dart, lib/core/monetization/solana_fee_account_resolver.dart.
0x and 1inch quotes need ZEROX_API_KEY or ONEINCH_API_KEY. Without them, EVM swaps use the on-chain router path, which charges no operator fee.
02Turn it on
In apps/nfc_crypto/lib/brand/brand_config.dart:
static const int evmSwapFeeBps = 30; // 0.3 % on 0x and 1inch swaps
static const String evmSwapFeeRecipient = '0xYourEvmAddress';
static const int solanaSwapFeeBps = 30; // 0.3 % on Jupiter swaps
static const String solanaSwapFeeRecipient = 'YourSolanaWalletAddress';
- Each chain family has its own rate and its own recipient.
0or an empty recipient turns that family's fee off.- Any value above 200 is lowered to 200 (2 %). A typo cannot overcharge users.
- A recipient that is not a valid address (wrong format, the zero address, a placeholder) turns the fee off for that family; the swap still works.
After the change, flutter test test/brand_config_test.dart fails on the test "the shipped config charges no fee and sets no policy". That test guards the shipped default. Update its expected values to your fee.
03Solana: create the fee token accounts
Jupiter does not pay a fee to a plain wallet address. It pays into your wallet's token account for the token being bought. The app works out that account from your solanaSwapFeeRecipient and checks on chain that it exists and belongs to you. If it does not exist, the swap runs without a fee; it never fails because of it.
So, for each token you want to collect fees in (for example USDC or USDT; for SOL it is the wrapped SOL mint), create the associated token account of your fee wallet once. Receiving a small amount of that token in your fee wallet creates it, or use the Solana CLI: spl-token create-account <TOKEN_MINT> --owner <YOUR_FEE_WALLET>. Swaps into tokens you have no account for run without a fee. Token-2022 tokens are supported.
04Check it before launch
- Build with your fee and the aggregator keys.
- Make a small swap on a main network with each source you want to earn from.
- Confirm that the Platform fee row shows your percentage, and that the fee arrived at your address in the block explorer.
The fee parameters are covered by unit tests in the kit. Payouts depend on the aggregators' live APIs and rules, which can change; check their documentation and terms for integrator fees.
05Other ways to earn with the kit
These are business options, not features in the code:
- Sell branded cards. Program, assign and ship your own cards with Card Studio. Payment and checkout are not part of the kit; use your own shop.
- Build white-label versions for clients. Each app is rebranded in one file (White label), and Card Studio takes a studio name and hosts per client.
The kit is revenue-ready: it contains the fee mechanism described above. What an operator earns depends on users, volume and costs. Nothing in this documentation is a forecast.
06Fees and the law
Charging a fee on swaps, or selling wallet cards, can be regulated where you or your users are. Tell users about the fee in your terms and store listing. Check the rules that apply to you before you turn it on.