DEV Community

Cover image for Solidity Crash Course - Part 1: Basics and Pre Requisite
Muhammad Ayaz
Muhammad Ayaz

Posted on

Solidity Crash Course - Part 1: Basics and Pre Requisite

Solidity Crash Course - Part 1: Basics

🚀 Welcome to Part 1 of the Solidity Crash Course! This guide covers the fundamentals of Solidity, Blockchain, Transactions, Gas, and the Ethereum Virtual Machine (EVM).

📌 What is Blockchain?

A blockchain is a decentralized, immutable ledger that records transactions securely. It consists of blocks, each containing a list of transactions, linked together to form a chain.

🔹 Key Features of Blockchain:

  • Decentralization → No central authority controls it.
  • Immutability → Transactions cannot be altered once recorded.
  • Transparency → Anyone can verify transactions.
  • Security → Cryptographic techniques ensure data integrity.

💳 Transactions in Blockchain

A transaction is a transfer of value or data on the blockchain. In Ethereum, transactions can be:

  • Ether Transfers → Sending ETH between accounts.
  • Contract Interactions → Calling functions in smart contracts.

✨ Example: Basic Transaction Structure

{
  "from": "0xSenderAddress",
  "to": "0xReceiverAddress",
  "value": "1000000000000000000", // 1 ETH in Wei
  "gas": "21000",
  "gasPrice": "5000000000"
}
Enter fullscreen mode Exit fullscreen mode

🔍 Transaction Components:

  • From & To → Sender and recipient addresses.
  • Value → Amount of Ether sent.
  • Gas & Gas Price → Cost of execution.

⛽ Understanding Gas in Ethereum

Ethereum requires gas to execute transactions and smart contracts. Gas is a measure of computational effort.

🔥 Why Gas is Important:

  • Prevents spam → Users must pay to use the network.
  • Compensates miners → Incentivizes validation of transactions.
  • Manages network load → More complex operations require more gas.

🏷️ Example: Estimating Gas

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract GasExample {
    uint256 public value;

    function setValue(uint256 _value) public {
        value = _value; // Simple operation → Low gas cost
    }
}
Enter fullscreen mode Exit fullscreen mode

🖥️ Ethereum Virtual Machine (EVM) Basics

The Ethereum Virtual Machine (EVM) is the runtime environment for executing smart contracts. It ensures security and decentralization.

🛠 Key Features of EVM:

  • Isolation → Contracts run independently from each other.
  • State Management → Keeps track of all accounts and balances.
  • Smart Contract Execution → Runs Solidity bytecode efficiently.

🎯 Summary

✅ Blockchain is a decentralized ledger for recording transactions.
✅ Transactions involve sending ETH or calling smart contracts.
✅ Gas is used to pay for computation and secure the network.
✅ EVM enables smart contract execution in a secure environment.

🔥 Next Steps

In Part #2, we’ll cover Smart Contracts. Stay tuned! 🚀


💬 Found this helpful? Drop a comment and share your first transaction experience!

Top comments (0)