
Ethereum and Smart Contracts: A Program That Runs by Itself
إيثيريوم والعقد الذكي: برنامج يعمل بنفسه
Bitcoin keeps a ledger of who owns what. Ethereum also keeps programs. This lesson explains what a smart contract is, using the vending machine, and what it can and cannot do.
يحفظ البيتكوين دفترًا بمن يملك ماذا. وتحفظ إيثريوم البرامج أيضًا. يشرح هذا الدرس بمثال آلة البيع الذاتي ما العقد الذكي وماذا يستطيع وماذا لا يستطيع.
Lesson Content
محتوى الدرس
Read the lesson in English or Persian.
اقرأ الدرس بالفارسية أو الإنجليزية.
You put a coin in a vending machine and press B4. Nobody checks your request and nobody can talk the machine into giving you two snacks. If the rules are met, it delivers. If not, it does nothing.
That small machine is the best picture of a smart contract.
01. What a smart contract is
Ethereum's own documentation says a smart contract is simply a program that runs on the Ethereum blockchain. It is a collection of code, called functions, and data, called state, that lives at a specific address on the chain.
The vending machine comparison is also from there, and the page credits it to the computer scientist Nick Szabo: perhaps the best metaphor for a smart contract.
02. Why it is "smart"
It is not intelligent. It is automatic. The name means the rules are written as code and run exactly as written, whoever calls them.
- 1Someone sends a payment and a request
- 2The contract's code checks the rules
- 3If the rules are met, the state is updated
- 4The network records the result for everyone
03. What it looks like in practice
Imagine a simple contract: "If the sender pays the price, give them one ticket, and record that the ticket is theirs." There is no cashier. The network checks the payment and the program updates the record.
The same idea can hold a shared saving pot, a swap between two kinds of money, or a vote.
04. Where it lives
A contract is deployed to the blockchain, and from then on it sits at an address like an account. Anyone can call its functions. Because many computers run it, the result does not depend on one company staying honest or online.
05. Once deployed, it is hard to change
Ethereum's documentation says that once a contract is deployed, no user controls it, and by default it cannot be deleted. That is the strength and also the risk. A rule that cannot be changed gives trust. A mistake that cannot be changed stays.
That is why careful projects choose their power settings openly. In the case of TMN, for example, the token contract's owner was renounced, which means a central switch for changing the rules is deliberately gone.
06. What a contract cannot do
A contract only knows what is on the chain. It cannot read a newspaper or check the weather by itself; information from outside has to be brought in. And it cannot fix a bad idea: code that does exactly what it says can still do something unwise.
07. The cost of running
Every action takes computation, and users pay a fee, known on Ethereum as gas. Simple operations cost little; complex ones cost more.
08. Why this matters
Without smart contracts, there would be no tokens built on Ethereum, which is where the next lesson goes.
What to take from this
A smart contract is a program stored on a blockchain: code plus data at an address.
The vending machine is the classic picture: rules met, result delivered, no cashier.
Once deployed, no user controls it, and by default it cannot be deleted.
It only knows what is on the chain.
"Smart" means automatic, not intelligent.
تضع عملة في آلة بيع ذاتي وتضغط B4. لا أحد يراجع طلبك ولا أحد يستطيع إقناع الآلة بأن تعطيك وجبتين خفيفتين. إن تحققت الشروط تسلّم. وإن لم تتحقق لا تفعل شيئًا.
هذه الآلة الصغيرة أفضل صورة للعقد الذكي.
01. ما العقد الذكي
تقول وثائق إيثريوم نفسها إن العقد الذكي ببساطة برنامج يعمل على بلوكتشين إيثريوم. هو مجموعة من الشيفرة، تسمى دوال، وبيانات، تسمى الحالة، موجودة على السلسلة في عنوان محدد.
والمقارنة بآلة البيع من هناك أيضًا، وتنسبها الصفحة إلى عالم الحاسوب نيك سابو: لعلها أفضل استعارة للعقد الذكي.
02. لماذا هو «ذكي»
ليس عبقريًا؛ إنه تلقائي. الاسم يعني أن القواعد كُتبت في شكل شيفرة وتنفَّذ تمامًا كما كُتبت، أيًّا كان من يستدعيها.
- 1يرسل شخص دفعة وطلبًا
- 2تفحص شيفرة العقد القواعد
- 3إن تحققت القواعد تُحدَّث الحالة
- 4تسجل الشبكة النتيجة للجميع
03. كيف يبدو في الواقع
تخيّل عقدًا بسيطًا: «إذا دفع المرسل الثمن فأعطه تذكرة وسجّل أن التذكرة له.» لا يوجد أمين صندوق. الشبكة تتحقق من الدفعة والبرنامج يحدّث السجل.
والفكرة نفسها تستطيع أن تحفظ حصالة مشتركة، أو مبادلة نوعين من المال، أو تصويتًا.
04. أين يعيش
يُنشر العقد على البلوكتشين ثم يستقر كحساب في عنوان. ويستطيع أي شخص استدعاء دوالّه. ولأن حواسيب كثيرة تنفّذه فالنتيجة لا تتوقف على أمانة شركة أو بقائها متصلة.
05. بعد النشر يصعب تغييره
تقول وثائق إيثريوم إنه حين يُنشر العقد لا يتحكم فيه أي مستخدم وهو بحسب الافتراضي غير قابل للحذف. وهذا قوة وخطر معًا. القاعدة التي لا تتغير تجلب الثقة. والخطأ الذي لا يتغير يبقى.
ولهذا تختار المشاريع الدقيقة إعدادات السلطة علنًا. ففي TMN مثلًا «تُرك» ملك عقد الرمز، أي أن مفتاحًا مركزيًا لتغيير القواعد أُزيل عمدًا.
06. ما لا يستطيعه العقد
العقد يعرف فقط ما على السلسلة. لا يستطيع بنفسه قراءة جريدة أو فحص الطقس؛ المعلومات الخارجية يجب أن تُجلب إلى السلسلة. ولا يستطيع إصلاح فكرة سيئة: فالشيفرة التي تفعل بالضبط ما كُتب لها قد تفعل شيئًا غير حكيم.
07. تكلفة التنفيذ
كل عملية تحتاج حسابًا ويدفع المستخدمون رسمًا يسمى في إيثريوم «الغاز» (gas). العمليات البسيطة تكلفتها قليلة والمعقدة أكثر.
08. لماذا هو مهم
بلا عقد ذكي لما أمكن إنشاء رمز على إيثريوم؛ وإليه يذهب الدرس التالي.
ماذا نستنتج
العقد الذكي برنامج مخزَّن على البلوكتشين: شيفرة مع بيانات في عنوان.
آلة البيع الصورة الكلاسيكية: الشرط يتحقق، النتيجة تُسلَّم، بلا أمين صندوق.
بعد النشر لا يتحكم فيه أي مستخدم وهو بحسب الافتراضي غير قابل للحذف.
يعرف فقط ما على السلسلة.
«ذكي» تعني تلقائي، لا عبقري.
Two lessons that connect
درسان مرتبطان
Lesson 27 explains who keeps the chain honest. Lesson 29 shows what smart contracts made possible: tokens.
يشرح الدرس 27 من يُبقي السلسلة صادقة. ويبيّن الدرس 29 ما الذي أتاحته العقود الذكية: الرموز.
Key Concepts
المفاهيم الأساسية
- Smart contract
- Function and state
- Address
- Deployment
- Gas
- Immutability
- On-chain data
- العقد الذكي
- الدالة والحالة
- العنوان
- النشر
- الغاز
- عدم القابلية للتغيير
- البيانات على السلسلة
Learning Objectives
أهداف التعلّم
- Define a smart contract in one sentence.
- Use the vending machine to explain it.
- Say why a deployed contract is hard to change.
- Name a limit of what a contract can know.
- Explain what gas pays for.
- عرّف العقد الذكي في جملة واحدة.
- اشرحه بآلة البيع.
- قل لماذا يصعب تغيير عقد منشور.
- سمِّ حدًّا واحدًا فيما يعرفه العقد.
- اشرح ثمن ماذا هو الغاز.
Quiz
اختبار قصير
Check what stayed with you. The answer is under each question.
انظر ماذا علق في ذهنك. الإجابة تحت كل سؤال.
Question 1
السؤال 1
What is a smart contract?
ما العقد الذكي؟
A. A program that runs on a blockchain
أ. برنامج يعمل على بلوكتشين
B. A paper agreement signed by a lawyer
ب. اتفاق ورقي موقّع عند محامٍ
C. A type of bank account
ج. نوع من الحسابات المصرفية
Correct answer: A
الإجابة الصحيحة: أ
Question 2
السؤال 2
Which everyday machine is the classic metaphor?
أي جهاز يومي هو الاستعارة الكلاسيكية؟
A. A vending machine
أ. آلة البيع الذاتي
B. A washing machine
ب. الغسالة
C. A printer
ج. الطابعة
Correct answer: A
الإجابة الصحيحة: أ
Question 3
السؤال 3
By default, what happens to a deployed contract?
ماذا يحدث للعقد المنشور بحسب الافتراضي؟
A. No user controls it and it cannot be deleted
أ. لا يتحكم فيه أي مستخدم ولا يُحذف
B. Its author can edit it freely
ب. يعدّله كاتبه بحرية
C. It expires after a year
ج. تنتهي صلاحيته بعد سنة
Correct answer: A
الإجابة الصحيحة: أ
Question 4
السؤال 4
What does 'smart' in smart contract mean?
ماذا تعني «ذكي» في العقد الذكي؟
A. Automatic: rules run as written
أ. تلقائي: القواعد تنفَّذ كما كُتبت
B. Artificially intelligent
ب. يملك ذكاءً اصطناعيًا
C. Always profitable
ج. مربح دائمًا
Correct answer: A
الإجابة الصحيحة: أ
Question 5
السؤال 5
What can a contract not do by itself?
ما الذي لا يستطيع العقد فعله بنفسه؟
A. Read outside information such as the weather
أ. قراءة معلومات خارجية كالطقس
B. Hold data
ب. حفظ بيانات
C. Have an address
ج. امتلاك عنوان
Correct answer: A
الإجابة الصحيحة: أ
Sources
المصادر
The statement about TMN's renounced owner follows the token page on this site. The page we cite does not give a coining date for the term, so none is stated. General explanation, not a security audit of any contract.
العبارة عن ترك ملك TMN مصدرها صفحة الرمز في هذا الموقع نفسه. ولم تعطِ صفحة المرجع تاريخًا لابتكار هذا المصطلح فلم يُذكر تاريخ. شرح عام وليس تدقيقًا أمنيًا لأي عقد.
نتابع معًاFollow along
New lessons are announced first on Ditoman's channels.
تُعرَض الدروس الجديدة أولًا على قنوات ديتومان.