# Gas calculation and Transaction execution on E Money Network

1. Nodes execute the previous block and run the EndBlock hook. As part of this hook, the FeeMarket (EIP-1559) module tracks the total TransientGasWanted from the transactions on this block. This will be used for the next block’s BaseFee.
2. Nodes receive transactions for a subsequent block and gossip these transactions to peers. These can be sorted and prioritised by the included fee price (using EIP-1559 fee priority mechanics for EVM transactions -[ code snippet](https://github.com/evmos/ethermint/blob/57ed355c985d9f3116aba6aabfa2ee0f3f38e966/app/ante/eth.go#L137)), to be included in the next block
3. Nodes run BeginBlock for the subsequent block. The FeeMarket module calculates the BaseFee ([code snippet](https://github.com/evmos/ethermint/blob/89fdd1984826ea524cb9b8feb089a99b6cfe8ace/x/feemarket/keeper/abci.go#L14)) to be applied for this block using the total GasWanted from the previous block. The Distribution module[ distributes](https://docs.cosmos.network/main/modules/distribution#begin-block) the previous block’s fee rewards to validators and delegators
4. For each valid transaction that will be included in this block, nodes perform the following:<br>

   An AnteHandler process corresponding to the transaction type is initiated. This process:

   * Performs basic transaction validation.
   * Verifies the fees provided are greater than the global and local minimum validator values and greater than the BaseFee calculated (For Ethereum transactions).
   * Preemptively consumes gas for the EVM transaction.
   * Deducts the transaction fees from the user and transfers them to the fee\_collector module.
   * Increments the TransientGasWanted in the current block, to be used to calculate the next block’s BaseFee.<br>

   Then, for standard Cosmos Transactions, nodes:

   * Execute the transaction and update the state Consume gas for the transaction<br>

   For Ethereum Transactions, nodes:

   * Execute the transaction and update the state Calculate the gas used and compare it to the gas supplied, then refund a designated portion of the surplus.
   * Send a fraction of the fees used as revenue to contract developers as part of the Revenue Module, if the transaction interacts with a registered smart contract<br>
5. Nodes run EndBlock for this block and store the block’s GasWanted.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.emoney.network/tendermint-and-evmos/gas-and-fees/gas-calculation-and-transaction-execution-on-e-money-network.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
