Gas and Fees

The CosVM network introduces a fee structure that requires users to pay fees when submitting transactions. These fees are an essential part of the network's functioning and are implemented differently compared to other blockchain platforms like Ethereum and Cosmos. Understanding how CosVM handles fees, particularly in an Ethereum-like fee calculation manner, is crucial given its compatibility with the Cosmos SDK.

Prerequisite Readings

Ethereum Gas

  • Gas Calculation Basics: Gas calculation is fundamental in determining the fees associated with transactions on the CosVM network. Gas refers to the computational cost required to execute operations or smart contracts within the network. Each operation consumes a specific amount of gas, and the total fee for a transaction is calculated based on the gas used and the gas price.

  • Fee Provision for Transactions: Users must provide fees alongside their transactions on CosVM. These fees cover the computational resources utilized during transaction execution. Unlike traditional transaction fees, CosVM adopts a gas-based fee system where the gas price determines the cost per unit of gas consumed.

  • Ethereum-Type Fee Calculation and EIP1559: The CosVM blockchain implements an Ethereum-type fee calculation method, particularly leveraging EIP1559. This fee model aims to create a more predictable fee structure and efficient use of block space by introducing a base fee that adjusts dynamically based on network demand. Users can set a "tip" to prioritize their transactions in the fee market.

  • Smart Contract Interaction Fees on CosVM: Interacting with smart contracts on CosVM incurs fees. These fees, when paid for interacting with smart contracts, can generate revenue for the individuals or entities deploying these smart contracts. It's worth noting that this revenue aspect provides an incentive for smart contract deployment on the CosVM platform



Transactions require fees to prevent network abuse. If transactions were free, malicious actors could flood the network with fraudulent transactions, causing congestion and disruptions. The concept of "gas" addresses this by charging a small amount of gas for each computational step during transaction execution, preventing malicious actors from halting the network.

What is Gas?:

Gas measures the computational intensity of transactions, with complex transactions requiring more gas than simpler ones. It's akin to electricity or fuel, representing the cost of network usage.

Gas Calculations:

Gas calculation varies based on transaction details, and estimating gas usage can be complex. For Cosmos SDK transactions, simulation helps calculate gas. In the Ethereum Virtual Machine (EVM), each bytecode operation incurs a specific gas cost.

Gas vs. Fees:

While gas represents computational work, fees are the tokens spent for transaction execution. Fees are calculated as the product of gas used and gas price, similar to an energy bill based on consumption and rate.

Handling Fees on Cosmos:

On Cosmos, users set GasLimit and either Fees or GasPrice. Transactions failing to meet GasLimit result in execution failures without fee refunds. Validators can enforce minimum gas prices.

Handling Fees on Ethereum:

Ethereum evolved its fee implementation. EIP-1559 introduced BaseFee and PriorityFee, replacing GasPrice. The BaseFee is burned, while the PriorityFee rewards block proposers.


How are Gas and Fees Handled on cosVM?

Handling Gas and Fees on cosVM:

cosVM integrates EVM compatibility into the Cosmos SDK, using fee logic from Cosmos SDK, Ethereum, and custom cosVM. It implements a fee market module to calculate dynamic fees based on EIP-1559. Unused gas is refunded, and developers receive a portion of transaction fees through the Revenue Module.

Gas Mechanics on Cosmos and cosVM:

Cosmos tracks gas consumption through GasMeter and BlockGasMeter. cosVM matches EVM gas consumption, resets gas meters, and ensures accurate gas refunds.

Gas Estimation and Cross-Chain Fees:

cosVM provides APIs for gas estimation, aligning with Ethereum's eth_estimateGas. Cross-chain transactions can utilize tips to cover fees on different networks.

Handling Gas and Fees via cosVM CLI:

cosVM CLI flags allow users to define fees, gas limits, and gas prices for transactions, with options for automatic estimation. Users should consider adjusting gas values based on network traffic to avoid transaction failures due to insufficient gas.

Last updated