🌱
Dev Compendium
  • Ethereum
    • Solidity
      • EVM
      • Architecture
      • Execution Context
      • Transactions
      • Gas
      • Calldata, Memory & Storage
      • Gas Optimisation
      • Function Declarations
      • receive() & fallback()
      • CALL vs. DELEGATE CALL
    • Yul
      • Introduction
      • Types
      • Basic Operations
      • Storage
      • Memory
        • Arrays
        • Structs
        • Tuples, revert, keccak256
        • Logs and Events
        • Gotchas
        • abi.encode
      • Calldata
        • External Calls
        • Dynamic Length Inputs
        • Transferring Value
        • Receiving Contract Calls
      • Contracts in Yul
      • Other Yul Functions
    • Foundry
    • Security
      • Common Vulnerabilities
      • Best Practices
      • Development Workflow
      • Contract Migration
    • Auditing Tools
      • Slither
      • Mythril
      • Fuzzing
    • Upgradable Contracts
      • Upgrade Patterns
      • ERC-1967 Implementation
      • Deployment
    • MEV
    • Tooling
      • Chainlink
      • IPFS
      • Radicle
    • Frontend
      • Contract Hooks
      • Wallet Connection
        • wagmi.sh
        • Rainbow Kit
      • thirdweb
    • Protocol Research
      • Uniswap v2
      • Uniswap v3
      • Curve
      • GMX
  • Starkware
    • Fundamentals
    • Account Abstraction
    • Universal Deployer
    • Cairo 1.0
    • starknet.js
    • Security Model
  • Zero Knowledge
    • Group Theory
    • ECDSA
  • Rust
    • Basic Operations
    • Set up
    • Primitives
    • Control Flow
    • Mutability & Shadowing
    • Adding Behavior
    • Lifetimes
    • Std Library
  • SUI
    • Architecture
    • Consensus Mechanism
    • Local Node Setup
    • Sui Client CLI
    • Move Contracts
      • Move
      • Move.toml
      • Move.lock
      • Accessing Time in Sui Move
      • Set up Development Framework
      • Debug & Publish
      • Package Upgrades
      • Sui Move Library
      • Difference from Core Move
    • Object Programming
      • Object Basics
      • Using Objects
      • Immutable Objects
      • Object Wrapping
      • Dynamic Fields
      • Collections
      • Unit Testing
      • Deployment with CLI
  • NEAR
    • Architecture
    • Contract Standards
      • Fungible Token (NEP-141)
      • Non-Fungible Token (NEP-171)
      • Storage Management (NEP-145)
      • Events (NEP-297)
      • Meta-Transactions
    • Rust Contracts
      • Development Workflow
      • Smart Contract Layout
      • Storage Management
      • Events & Meta-transactions
      • Method Types
      • Upgrading Contracts
      • Unit Testing
    • NEAR Libraries
    • Environment Variables
    • Serialisation
    • Security Concepts
    • Collections
    • JS SDK
Powered by GitBook
On this page
  1. Ethereum
  2. Solidity

Execution Context

PreviousArchitectureNextTransactions

Last updated 1 year ago

When the EVM executes a smart contract, a is created for it. The context consists of the following.

  • The Code

    • The contract bytecode which is immutable, it is stored on-chain and referenced using a contract address.

  • The Stack

    • The call stack, an empty stack is initialised for each EVM contract execution.

  • The Memory

    • The contract memory, a clean memory is initialised for each EVM contract execution.

  • The Storage

    • The contract storage which is persisted across executions, it is stored on-chain and is referenced via a contract address and its storage slot.

  • The Call Data

    • The input data for a transaction.

  • The Return Data

    • The data returned from a contract function call.

CALL vs. DELEGATECALL

CALL executes a function in the context of the contract it was defined, while DELEGATECALL inherits the execution context, meaning that the function will behave as it was defined in the contract that’s using DELEGATECALL

For DELEGATECALL we have the following input variables;

CALL has exactly the same input variables with one additional value.

References:

gas: amount of gas to send to the sub to execute. The gas that is not used by the sub context is returned to this one.

address: the account which to execute.

argsOffset: byte offset in the in bytes, the of the sub .

argsSize: byte size to copy (size of the ).

retOffset: byte offset in the in bytes, where to store the of the sub .

retSize: byte size to copy (size of the ).

value: in to send to the account. (CALL only)

context
context
context
memory
calldata
context
calldata
memory
return data
context
return data
value
wei
https://www.evm.codes/about