DEV Community

Mahima Thacker
Mahima Thacker

Posted on

Ever wonder what happens when you send a transaction on Ethereum? ๐Ÿ‘€

Let's break it down in simple terms๐Ÿ‘‡:

1. Setup: When you send a transaction from your wallet to a smart contract, the EVM (Ethereum Virtual Machine) gets ready. It creates a new environment to run your transaction.
The EVM loads the smart contract's code, sets up an empty stack and memory (kind of like a workspace), and prepares all the important variables.

2. Execution: Now, the EVM starts executing the transaction. It goes through each instruction (called opcodes) one by one.
As it works, it uses up the gas you provided (think of gas as the fuel that powers the transaction).
It updates the stack, memory, and storage as needed. Once it finishes, the EVM clears out the stack and memory, wiping the workspace clean.

3. Success: If everything runs smoothly, the EVM saves the changes made during the transaction to the blockchain.
Any leftover gas is returned to you.

4. Out of Gas: If the transaction runs out of gas before finishing, the EVM stops. All the changes are undone, so nothing gets saved. And you donโ€™t get back any gas.

5. Exception: If something goes wrong (like hitting a require, revert, or assert statement), the transaction is reverted. This means no changes are made to the blockchain. And no refund for unused gas from the gas limit

Image description

This is how Ethereum manages your transactions behind the scenes, ensuring everything runs smoothly or is safely undone if something goes wrong ๐Ÿ’โ€โ™€๏ธ

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

๐Ÿ‘‹ Kindness is contagious

Please leave a โค๏ธ or a friendly comment on this post if you found it helpful!

Okay