Fee Structure
Inco fees are paid in the native blockchain currency (ETH on Ethereum, etc.) and are required for operations that involve processing encrypted inputs from external sources.Getting the Current Fee Amount
Use theinco.getFee() function to get the current fee amount:
Paying Fees
Fees can be paid in two ways: either by users including them inmsg.value, or by having the contract pay from its own ETH balance.
Option 1: User Pays via msg.value
Fees must be paid viamsg.value when calling functions that require them. The transaction will revert if insufficient fees are provided.
Option 2: Contract Pays from Balance
Contracts can hold ETH in their balance to pay fees automatically, eliminating the need for users to include fees inmsg.value.
- Better user experience - no need to calculate or send exact fees
- Simpler function signatures - no
payablemodifier required - Automatic fee management by contract owner
- Contract owner must ensure sufficient ETH balance
- Monitor contract balance and top up as needed
- Consider implementing balance thresholds and alerts
Operations That Require Fees
Encrypted Input Creation and Random Generation
The following operations create new encrypted handles from external ciphertexts or generate random values and require fees:| Operation | Fee Required | Description |
|---|---|---|
e.newEuint256(bytes memory input) | 1 fee per call | Create a new euint256 from an encrypted input |
e.newEbool(bytes memory input) | 1 fee per call | Create a new ebool from an encrypted input |
e.newEaddress(bytes memory input) | 1 fee per call | Create a new eaddress from an encrypted input |
e.rand() | 1 fee per call | Generate a random euint256 value |
e.randBounded(uint256) | 1 fee per call | Generate a bounded random euint256 value |
e.randBounded(euint256) | 1 fee per call | Generate a bounded random euint256 value |
Operations That Don’t Require Fees
All other Inco operations are free and don’t require any fee payment:Math Operations
e.add,e.sub,e.mul,e.div,e.reme.and,e.or,e.xor,e.shr,e.shl,e.rotr,e.rotl
Comparison Operations
e.eq,e.ne,e.ge,e.gt,e.le,e.lte.min,e.max,e.not
Multiplexer Operations
e.select
Trivial Encryption (no external input)
e.asEuint256(uint256)- Convert known uint256 to euint256e.asEbool(bool)- Convert known bool to ebool
Access Control
e.allow,e.allowThis,e.isAllowed
Fee Best Practices
For User-Paid Fees
Always Check Fees Before Operations
Calculate Ciphertext Count Accurately
Count eachnewEuint256, newEbool or newEaddress call in your function to ensure you charge the correct total fee.
For Contract-Paid Fees
Monitor Contract Balance
Implement Balance Management
General Best Practices
Handle Fee Changes
Fees may change over time. Always useinco.getFee() rather than hardcoding fee amounts.
Test Fee Requirements
When testing contracts, ensure sufficient funds for both approaches:Common Fee-Related Errors
User-Paid Fee Errors
- “Fee Not Paid”: Transaction reverted due to insufficient
msg.value - Overpaying: While allowed, unnecessary ETH is consumed as gas
- Fee changes: Contract fails if fees increase between deployment and usage
Contract-Paid Fee Errors
- “Insufficient contract balance”: Contract doesn’t have enough ETH to pay fees
- “Below minimum reserve”: Withdrawal attempts that would leave insufficient funds
- “Contract balance depleted”: Functions fail when contract runs out of ETH during high usage
Important: Encrypted input operations (
newEuint256, newEbool, newEaddress) require
fees because they involve off-chain decryption and processing within Inco’s
Trusted Execution Environment (TEE). All other operations are performed
symbolically on-chain and are therefore free.