Fee Router Smart Contract Integration
On-chain fee distribution via a custom smart contract.
Introduction
This is an optional, enterprise-only feature. Most customers use the standard points marketplace for attribution rewards. The fee router is for enterprise customers who need on-chain fee distribution via a custom smart contract.
If you are not sure whether you need this, you almost certainly do not. Contact support@replycorp.io to discuss enterprise options.
Table of Contents
Overview
The fee router contract receives fees and distributes them to attributed influencers on-chain. When a conversion is recorded via the API, ReplyCorp:
Calculates attribution (who influenced the sale)
Updates your deployed fee router contract with the attribution breakdown
Returns the
feeDistributiondata in the API response
You then interact with the contract to approve token spending, start distribution, process batches, and finalize.
Prerequisites
Enterprise plan with fee router enabled (contact support@replycorp.io)
Funded distribution wallet: The wallet calling
startDistribution()must have sufficient ERC-20 token balance. The contract pulls tokens from this wallet. You can fund it in real time by routing conversion proceeds to it, or pre-fund it and keep it topped up.Consistent token denomination: All financial data (
totalVolume,commission, and optionallynetProfit) posted to the API must be denominated in the same ERC-20 token used for rewards. If distributing USDC, all amounts must be in USDC units.Smart contract deployment capability: You must be able to deploy contracts and interact with them programmatically.
Contract parameters entered in admin panel: Chain, token address, revenue share percentage. ReplyCorp fee percentage is set by ReplyCorp when creating your account.
Conversion API Fields
When using the fee router, your conversion API requests must include these additional fields alongside the standard twitterId and eventType:
totalVolume
number
Yes
Gross revenue from the conversion
commission
number
Yes
Amount to distribute to influencers. Under the default COMMISSION model, the ReplyCorp fee (15%) is deducted from this.
netProfit
number
No
Net profit (totalVolume minus costs). Defaults to totalVolume. Only used under the legacy NET_PROFIT model.
If any fee router field is provided, at least totalVolume and commission must be provided together.
Attribution percentages are calculated from totalVolume (who influenced the sale). Commission amounts are distributed from commission (the portion you allocate to influencers).
If fee router fields are not provided, the API falls back to using amount for backward compatibility.
Fee Distribution Response
When a campaign has a fee router contract configured, the conversion API response includes a feeDistribution object:
feeDistribution.totalCommission
Total commission amount to distribute to influencers
feeDistribution.replyCorpFee
Fee amount for ReplyCorp
feeDistribution.totalToSendToContract
Total amount to send to contract. Under COMMISSION model this equals commission (fee deducted from it). Under NET_PROFIT model this is commission + fee.
feeDistribution.attributionHash
Hash of attribution data for verification (matches contract's attributionHash)
The feeDistribution field is only included when:
The campaign has a fee router contract configured (
feeRouterContractAddressis set)All attributed participants have wallet addresses (no null wallets)
The conversion includes
totalVolumeandcommissionfields
Smart Contract Deployment
Time estimate: 2-4 hours
Enter contract parameters in the admin panel (chain, token address, revenue share %)
Receive contract code from ReplyCorp
Deploy the contract to your specified chain with the parameters you entered
Configure your system to interact with the deployed contract address
See FeeRouter Contract Documentation for the full contract reference.
Real-Time Distribution Flow
The contract validates the hash, pulls tokens on startDistribution, transfers the ReplyCorp fee immediately, then distributes commission to referrers in batches. Failed transfers are skipped and accumulated as dust.
Deferred / Periodic Distribution
If you want to batch payments on a schedule (weekly, monthly) instead of distributing in real time:
Deploy the fee router contract (same as above)
Call the conversion API -- ReplyCorp automatically updates the contract with attribution data
Store conversion IDs and
feeDistributiondata from API responsesLater, batch-process multiple conversions by calling the contract distribution functions
The contract stores attribution data permanently -- you can distribute at any time.
Independent Fee Routing
If you use a different payment system or smart contract architecture, you can store the attribution data from the API and distribute fees yourself.
Key data to store from each conversion response:
conversion.id-- unique identifierattribution.attributions[]-- array of all attributed referrers with percentages, wallet addresses, and amountsconversion.conversionValue-- the conversion amount
Handle missing wallet addresses (walletAddress: null) by escrowing funds, matching wallets on your side, or waiting for webhook updates when participants connect wallets.
CEX Integration Example
Scenario: User buys $100 of tokens on your exchange.
totalVolume= $100.00 (the purchase amount)Platform fees (2% transaction fee): $2.00
commission= $0.40 (20% of your $2.00 net profit, allocated for referral rewards)ReplyCorp fee (COMMISSION model): $0.06 (15% of commission, deducted from it)
Call the conversion API with
totalVolume: 100andcommission: 0.40ReplyCorp responds: send $0.40 total to the fee router contract. Referrers receive $0.34, ReplyCorp receives $0.06.
Call
startDistribution(),processBatch(), andfinalizeDistribution()on the contract.
Fee Models
COMMISSION
Yes (new campaigns)
15% of commission
Deducted from commission. Customer deposits commission amount; fee is taken from it.
NET_PROFIT
No (legacy)
5% of netProfit
Additive. Customer deposits commission + fee.
Fee model and percentage are configurable per campaign via admin panel or Telegram bot.
Last Updated: April 2026
Last updated

