0Pricing
Web3 & DApp Development Fundamentals · درس

مقدمة إلى Solidity

تعرّفوا إلى صياغة Solidity وبنيتها والإعلان الأساسي عن العقود، بما في ذلك الكلمتان المفتاحيتان pragma وcontract.

مقدمة إلى Solidity درس مجاني في Web3 & DApp Development Fundamentals على CoddyKit. هذا هو الدرس 1 من أصل 3. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Web3 & DApp Development Fundamentals، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Web3 & DApp Development Fundamentals 3 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

Meet Solidity: Language of Smart Contracts

Welcome to Solidity! It's the primary language for writing smart contracts on blockchain platforms like Ethereum.

Think of smart contracts as self-executing agreements stored on a blockchain. Learning Solidity opens the door to building decentralized applications (DApps).

Why Solidity Matters

Solidity is a high-level, object-oriented language. It's specifically designed to implement business logic for DApps.

It enables you to create digital tokens, build decentralized finance (DeFi) protocols, and manage digital assets securely on a blockchain.

Your First Solidity File

Every Solidity smart contract lives in a file ending with the .sol extension.

  • Just like a .js file for JavaScript.
  • Or a .py file for Python.
  • The first line of a Solidity file often defines the compiler version to be used.

The Pragma Directive

The pragma directive is crucial. It tells the Solidity compiler which version to use for your contract.

For example, pragma solidity ^0.8.0; means "use any compiler version from 0.8.0 up to, but not including, 0.9.0."

This ensures your contract compiles predictably and avoids unexpected behavior from future compiler changes.

Declaring a Contract

In Solidity, the fundamental building block for your smart contract is the contract keyword.

  • It's similar to a "class" in object-oriented programming languages.
  • Your entire smart contract's logic, including variables and functions, will live inside a contract block.

Our First Basic Contract

Let's put pragma and contract together. This is the most basic, yet complete, Solidity contract you can write.

It doesn't do much yet, but it's ready to be compiled and deployed!

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

contract MyFirstContract {
  // This contract is currently empty!
}

Comments in Solidity

Comments help explain your code to others and your future self. They are ignored by the compiler.

  • Single-line comments start with //.
  • Multi-line comments are enclosed by /* and */.
  • The SPDX-License-Identifier is a special comment used to specify the contract's license.

Contract Name & Structure

Contract names usually start with an uppercase letter, following common programming conventions (e.g., MyFirstContract).

The code inside the curly braces {} defines the contract's logic. This is where you'll add state variables, functions, and events as you learn more.

Quick Check: Pragma Purpose

The pragma solidity ^0.8.0; line is essential for smart contract development. What is its primary role?

Recap: Your Solidity Journey Begins!

You've learned the very basics of Solidity!

  • We covered the .sol file extension.
  • The critical pragma directive for compiler versions.
  • The fundamental contract keyword.
  • How to add comments for code clarity.

Next, we'll dive deeper into variables and data types!

الأسئلة الشائعة

هل درس «مقدمة إلى Solidity» مجاني؟

نعم — نص درس «مقدمة إلى Solidity» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Web3 & DApp Development Fundamentals، انتقل إلى CoddyKit PRO. تتضمن دورة Web3 & DApp Development Fundamentals 3 دروس في المجموع.

ماذا ستتعلم في «مقدمة إلى Solidity»؟

تعرّفوا إلى صياغة Solidity وبنيتها والإعلان الأساسي عن العقود، بما في ذلك الكلمتان المفتاحيتان pragma وcontract. تتمرن على Web3 & DApp Development Fundamentals مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Web3 & DApp Development Fundamentals؟

لا تُشترط خبرة سابقة. Web3 & DApp Development Fundamentals على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 1 من أصل 3.

كم من الوقت يستغرق درس «مقدمة إلى Solidity»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Web3 & DApp Development Fundamentals هذا؟

نعم. كل درس في Web3 & DApp Development Fundamentals يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. مقدمة إلى Solidity
  2. المتغيرات وأنواع البيانات
  3. الدوال وبنى التحكم
← العودة إلى Web3 & DApp Development Fundamentals