The Relayer earns revenue through transaction fees collected from senders. This mechanism is inspired by the bundler fee mechanism in ERC-4337.
Fee Calculation
The Relayer sets a FEE_PER_GAS (in wei) in the .env file. This value must be less than the maxFeePerGas (currently 2 gwei) defined in the contract.
When a transaction is posted on-chain with a ZK proof of email, the contract calculates the fee as follows:
- Validation: If
validateEmailOp fails, the fee is zero. - Gas Measurement: The contract measures the gas consumed during execution.
- Base Gas: 55,000 gas is added for ERC20 token refunds.
- Use-case Additions:
- If a recipient's email is specified: +450,000 gas (for ERC20 transfers).
- Other use cases: +500,000 gas.
- Total Fee:
FEE_PER_GAS * (Total Gas calculated in steps 2-4).
Reliability
The contract catches execution errors during the transaction process rather than failing the transaction. This ensures the Relayer can collect the fee as long as the initial email validation (Step 1) passes, even if the Relayer cannot perfectly simulate all execution outcomes beforehand.