---
description: >-
  This insightful text explores the dynamic relationship between the caller and
  callee contracts in Ethereum. It explains how gas is allocated when one
  contract calls another.
---

# Gas Allocation and Contract Interactions

When a contract calls another contract (referred to as the _**caller**_) using special opcodes like `CALL`, `STATICCALL` or `DELEGATECALL`, the called contract (referred to as the _**callee**_) receives a certain amount of gas as if it were called directly via a transaction.\
\
However, if the amount of gas provided to the _**callee**_ is not enough to cover the total gas cost of its operations, the callee's operations are reverted, and an **"out of gas"** exception occurs. In most cases, when developers use normal function calls in Solidity, this exception automatically causes the _**caller**_ to revert as well. However, the Ethereum Virtual Machine (EVM) and Solidity allow the _**caller**_ to continue execution if desired, utilizing whatever gas is left, including what was not spent by the _**callee**_.\
\
The _**callee**_ also has the option to independently decide to revert its operations, returning the unused gas, or to throw an exception, consuming all the gas provided. This decision can be based on specific errors, in which case the _**callee**_ can specify an error message, or on invalid operations like division by zero.

These mechanisms have important consequences for the behavior and interaction of contracts in Ethereum. They determine how gas is allocated, how failures and exceptions are handled, and provide flexibility for developers to control the flow of execution and gas usage within their contracts.

\
