Rise In Logo

Build on BNB Chain - Course 1 | BNB Chain Fundamentals

EVM Model - Part 2

EVM Model - Part 2

Hi! In this video, I’ll continue explaining the Ethereum Virtual Machine (EVM). We’ll explore how the EVM works, what message call transactions are, and how gas and fees function within the system.

šŸ”§ How the Ethereum Virtual Machine (EVM) Works

The EVM is the runtime environment that powers smart contracts on the BNB Smart Chain. It ensures all transactions are correctly executed and recorded in a secure and isolated software-based environment.

Let’s break down its key components using a simple diagram:

  • Machine State: A dynamic representation of the blockchain’s current state, including:
  • Smart contracts and their storage
  • Program counter
  • Stack
  • Memory

EVM Core Components:

  • Program Counter: Points to the next instruction to be executed.
  • Gas Available: Specifies the maximum gas limit for a transaction. If exceeded, the transaction fails.
  • Stack: A memory structure used to execute smart contract logic.
  • Memory: Temporarily stores data during contract execution.
  • Storage: Stores persistent data associated with smart contracts.
  • Code Space: Stores the compiled bytecode of the smart contract.

šŸ“Œ Key Insight: The EVM is designed to execute smart contracts securely in a "sandboxed" environment using bytecode compiled from high-level languages like Solidity.

šŸ” Message Call Transactions

A message call (also known as a contract call) is a transaction that allows one smart contract to interact with another.

  • Initiated when one contract calls another or itself.
  • Parameters are pushed to the stack.
  • The receiving contract (callee) accesses these inputs to execute its code.
  • Can also modify the stack with outputs or intermediate results.

šŸ“Œ Stack Principle: The EVM stack follows a LIFO (Last In, First Out) principle—newest values are removed first.

Why It Matters:

  • Enables the creation of complex, interconnected decentralized applications (dApps).
  • Ensures smooth execution of smart contracts across a blockchain ecosystem.

⛽ Gas and Fees

In the EVM, every operation (represented as an opcode) consumes gas.

What is Gas?

  • A unit of computation cost in the EVM.
  • Prevents abuse and ensures efficient resource usage.
  • Encourages developers to write optimized code.

When is Gas Used?

  • Retrieving/writing data from/to storage
  • Sending transactions
  • Executing contract logic

Gas Fee Structure:

  • Gas Limit: Max gas user is willing to consume.
  • Gas Price: Fee paid per gas unit.
  • Total Cost = Gas Used Ɨ Gas Price (paid in BNB)

šŸ“Œ Gas in Action:

  • If gas runs out mid-execution, the transaction fails, but the gas is still consumed.
  • Higher gas fees prioritize your transaction on the network.

šŸ” How All Components Work Together

  1. User initiates a transaction.
  2. Parameters are placed on the stack.
  3. EVM reads and processes opcodes using gas.
  4. Memory and storage are updated with new data.
  5. The transaction is completed and recorded on the blockchain.
  6. Gas fees are paid to compensate the network validators.

Final Thoughts

This was a technical deep dive, and it’s completely okay if not everything clicks right away. You don’t need to memorize all these details to write smart contracts—but understanding how things work under the hood helps you become a more effective blockchain developer.

I encourage you to explore more, look into each component, and experiment.

Test

Comments

You need to enroll in the course to be able to comment!

Stay in the know

Never miss updates on new programs and opportunities.

Rise In Logo

Rise together in web3!

Disclaimer: The information /programs / events provided on https://patika.dev and https://risein.com are strictly for upskilling and networking purposes related to the technical infrastructure of blockchain platforms. We do not provide financial or investment advice and do not make any representations regarding the value, profitability, or future price of any blockchain or cryptocurrency. Users are encouraged to conduct their own research and consult with licensed financial professionals before engaging in any investment activities. https://patika.dev and https://risein.com disclaim any responsibility for financial decisions made by users based on information provided here.