Course outline
Module 1
Module 1: What Smart Contracts Are
What Smart Contracts Are
Knowledge check
Q1. What is a smart contract?
- A. A legally binding paper agreement signed by two parties
- B. Self-executing code stored on a blockchain that runs when predefined conditions are met ✓
- C. A type of cryptocurrency wallet used to store digital assets
- D. A contract negotiated by artificial intelligence without human input
Why: A smart contract is self-executing code deployed on a blockchain. It automatically carries out its terms when the programmed conditions are satisfied, without needing a trusted intermediary.
Q2. Which blockchain platform is most commonly associated with the original development of smart contracts?
- A. Bitcoin
- B. Ethereum ✓
- C. Litecoin
- D. Dogecoin
Why: Ethereum, proposed by Vitalik Buterin and launched in 2015, was the first major blockchain designed to support general-purpose smart contracts through its built-in virtual machine.
Q3. What is a key characteristic of smart contracts once they are deployed to a blockchain?
- A. They can be edited easily by any user at any time
- B. They are immutable, meaning their code generally cannot be changed ✓
- C. They expire automatically after 30 days
- D. They require a central server to remain active
Why: Once deployed, a smart contract's code is generally immutable. This permanence gives users confidence in the rules, though it also means bugs can be hard to fix without special upgrade patterns.
Q4. What role do intermediaries typically play that smart contracts aim to reduce?
- A. They write the programming code for applications
- B. They verify and enforce agreements between parties, such as banks or lawyers ✓
- C. They mine new blocks on the network
- D. They design user interfaces for decentralized apps
Why: Smart contracts aim to reduce reliance on intermediaries like banks, brokers, or legal escrow agents by automatically enforcing agreement terms through code.
Q5. What triggers the execution of a smart contract?
- A. A random selection by network validators
- B. The passing of a fixed calendar date only
- C. A transaction or function call that meets the contract's programmed conditions ✓
- D. A manual approval from a government regulator
Why: Smart contracts execute when a transaction or message invokes one of their functions and the programmed conditions are met. The code then runs deterministically on every node in the network.
Module 2
Module 2: How Blockchains Execute Code
How Blockchains Execute Code
Knowledge check
Q1. What is the primary role of the Ethereum Virtual Machine (EVM) in executing smart contracts?
- A. It stores the entire blockchain history on a single server
- B. It provides a sandboxed runtime that executes contract bytecode identically on every node ✓
- C. It mines new blocks and assigns block rewards to validators
- D. It encrypts transaction data before it is broadcast to the network
Why: The EVM is a decentralized runtime environment that runs compiled contract bytecode. Because every node executes the same bytecode with the same inputs, all nodes reach the same result, which is what allows the network to agree on contract state.
Q2. Why must smart contract execution be deterministic?
- A. So that contracts can run faster on high-end hardware
- B. So that every node independently computes the same final state from the same transaction ✓
- C. So that developers can predict their profit margins
- D. So that gas fees remain constant over time
Why: Nodes verify the network's state by re-executing transactions themselves. If execution were non-deterministic, honest nodes would disagree on the resulting state, and consensus would break down.
Q3. What is 'gas' in the context of blockchain code execution?
- A. A cryptographic key used to sign transactions
- B. A unit measuring the computational work required, which the sender pays for ✓
- C. A type of token that represents ownership of a smart contract
- D. The temperature of the servers running the blockchain
Why: Gas measures the computational steps and storage a transaction consumes. Senders pay gas fees, which compensates validators for the work and prevents infinite loops or spam from consuming network resources for free.
Q4. What happens if a smart contract transaction runs out of gas partway through execution?
- A. The contract finishes execution using the remaining computation from other transactions
- B. All state changes are reverted, though the gas consumed up to that point is still paid ✓
- C. The contract is automatically upgraded to use more gas
- D. The transaction is saved and resumed in the next block at no cost
Why: When gas runs out, execution halts and state changes made during that transaction are rolled back, so the contract is left unchanged. The sender still pays for the gas used, since validators performed that work.
Q5. Which statement best describes how a blockchain stores the results of contract execution?
- A. Results are stored only on a centralized database controlled by the developer
- B. Changes to contract state are recorded on the chain as part of the global state, updated through validated blocks ✓
- C. Results are deleted after each block is produced to save space
- D. Only the contract's source code is stored; execution results are discarded
Why: Contract state variables are part of the blockchain's global state. When a block is validated, the resulting state changes are committed, making them immutable and verifiable by all participants.
Module 3
Module 3: Writing Your First Contract
Writing Your First Contract
Knowledge check
Q1. What language is most commonly used to write smart contracts on the Ethereum blockchain?
- A. Python
- B. Solidity ✓
- C. JavaScript
- D. Rust
Why: Solidity is the primary, most widely used high-level language for writing smart contracts on Ethereum and other EVM-compatible blockchains.
Q2. Which keyword is used to declare a state variable that stores an unsigned integer in Solidity?
- A. int
- B. uint ✓
- C. number
- D. integer
Why: In Solidity, uint (unsigned integer) is the standard type for non-negative whole numbers, while int is used for signed integers.
Q3. What does the 'pragma solidity' directive at the top of a Solidity file specify?
- A. The name of the contract
- B. The deployment address of the contract
- C. The compiler version the code is written for ✓
- D. The gas limit for transactions
Why: The pragma solidity directive tells the compiler which version of Solidity the source code is intended to work with, helping prevent compatibility issues.
Q4. Which function is executed exactly once, when a smart contract is first deployed?
- A. fallback()
- B. main()
- C. constructor() ✓
- D. init()
Why: The constructor() function runs only once during deployment and is typically used to initialize state variables such as the contract owner.
Q5. What is the purpose of the 'public' visibility modifier on a state variable in Solidity?
- A. It makes the variable accessible only to the contract owner
- B. It allows the variable to be read from outside the contract, with an automatic getter generated ✓
- C. It encrypts the variable's value on the blockchain
- D. It allows the variable to be modified by any external account
Why: Marking a state variable as public automatically creates a getter function so external contracts and users can read its value, though it does not make the data private or encrypted.
Module 4
Module 4: Common Security Vulnerabilities
Common Security Vulnerabilities
Knowledge check
Q1. What is a reentrancy vulnerability in a smart contract?
- A. A function that can only be called by the contract owner
- B. A function that can be called again before its first execution finishes, often because external calls occur before state is updated
- C. A contract that automatically destroys itself after deployment
- D. A bug where the contract cannot receive Ether at all
Q2. Which Solidity pattern helps prevent reentrancy attacks?
- A. Using tx.origin for authentication
- B. Updating state variables before making external calls (checks-effects-interactions pattern)
- C. Storing all balances in a public array
- D. Using block.timestamp as a random number source
Q3. Why is tx.origin considered risky for access control?
- A. It always returns the zero address
- B. It identifies the original externally owned account that started the transaction, so a malicious intermediary contract can trick a user into authorizing actions
- C. It can only be read during contract deployment
- D. It consumes excessive gas on every call
Q4. What is an integer overflow in the context of smart contracts?
- A. When a contract's bytecode exceeds the maximum size limit
- B. When an arithmetic result exceeds the maximum value the type can store and wraps around to a small value
- C. When a transaction includes too many function arguments
- D. When the contract's balance exceeds the total Ether supply
Q5. Which statement best describes why block.timestamp should not be used as a source of randomness?
- A. It is always the same value for every block
- B. Miners or validators can influence it within a small range, making outcomes predictable or manipulable
- C. It is stored in a format that cannot be converted to a number
- D. It only updates once per day on the Ethereum network
Module 5
Module 5: Testing and Auditing Contracts
Testing and Auditing Contracts
Knowledge check
Q1. What is the main purpose of unit testing a smart contract?
- A. To deploy the contract to the mainnet faster
- B. To verify that individual functions behave as expected in isolation ✓
- C. To reduce the gas cost of every transaction on the network
- D. To automatically generate the contract's frontend interface
Why: Unit tests check individual functions or components against expected inputs and outputs, catching logic errors early before the contract is integrated or deployed.
Q2. Which of the following is a common vulnerability that auditors look for in smart contracts?
- A. Using comments in the source code
- B. Reentrancy, where an external call allows an attacker to re-enter a function before state is updated ✓
- C. Choosing a descriptive name for a variable
- D. Splitting code across multiple files
Why: Reentrancy is one of the most notorious smart contract vulnerabilities, famously exploited in the DAO hack. Auditors check that state changes occur before external calls, or that reentrancy guards are used.
Q3. What does a test coverage report measure?
- A. The number of users who have interacted with the contract
- B. The total amount of ether held by the contract
- C. The percentage of lines, branches, or functions executed by the test suite ✓
- D. The speed at which transactions are processed on-chain
Why: Coverage reports show which parts of the code are exercised by tests, helping developers identify untested logic that could hide bugs.
Q4. Why is testing on a local development network or testnet recommended before mainnet deployment?
- A. Transactions on testnets are free of gas costs and never fail
- B. It allows developers to find and fix bugs without risking real funds ✓
- C. Mainnet does not support contract deployment
- D. Testnets automatically audit the code for security issues
Why: Local networks and testnets let developers simulate real conditions and catch bugs safely, since deployed mainnet contracts with flaws can lose real money and are often immutable.
Q5. What is the difference between a manual audit and an automated analysis tool?
- A. Manual audits are always cheaper than automated tools
- B. Automated tools can find common patterns quickly, while manual audits use human judgment to catch logic flaws and context-specific issues ✓
- C. Automated tools replace the need for any testing at all
- D. Manual audits only check the code's formatting and style
Why: Automated tools like static analyzers efficiently detect known vulnerability patterns, but human auditors are better at spotting complex business-logic errors that tools typically miss. Both are complementary.
Module 6
Module 6: Tokens and Standards
Tokens and Standards
Knowledge check
Q1. What does the acronym ERC in Ethereum token standards stand for?
- A. Ethereum Replication Code
- B. Ethereum Request for Comments ✓
- C. Edge Runtime Contract
- D. Encrypted Ledger Certificate
Why: ERC stands for Ethereum Request for Comments. Standards like ERC-20 and ERC-721 are proposals documented and discussed publicly by the Ethereum community before being adopted.
Q2. Which standard is most commonly used for fungible tokens on Ethereum?
- A. ERC-721
- B. ERC-1155
- C. ERC-20 ✓
- D. ERC-165
Why: ERC-20 defines a common interface for fungible tokens, meaning each unit is interchangeable with any other unit, like currency. It is the most widely used token standard on Ethereum.
Q3. What is the key difference between fungible and non-fungible tokens?
- A. Fungible tokens can only be transferred once
- B. Non-fungible tokens are interchangeable with each other
- C. Each fungible token is interchangeable with any other identical token, while each non-fungible token is unique ✓
- D. Non-fungible tokens do not run on blockchains
Why: Fungible tokens, like one unit of a currency, are identical and interchangeable. Non-fungible tokens represent unique items, so each one has distinct properties and value, as with collectibles or property deeds.
Q4. Which standard is designed for non-fungible tokens (NFTs)?
- A. ERC-20
- B. ERC-721 ✓
- C. ERC-4337
- D. ERC-2612
Why: ERC-721 defines a standard interface for non-fungible tokens, where each token has a unique ID and its own ownership record. It is the foundation for many NFT collections.
Q5. What does the 'transfer' function in a standard token contract typically do?
- A. It deletes tokens from circulation
- B. It moves tokens from one address to another ✓
- C. It creates new tokens from nothing
- D. It changes the contract's source code
Why: The transfer function moves a balance of tokens from the sender's address to a recipient's address. Standards require this function so that wallets and applications can interact with any compliant token in the same way.
Module 7
Module 7: Deploying and Maintaining Contracts
Deploying and Maintaining Contracts
Knowledge check
Q1. What is the first step in deploying a smart contract to a blockchain network?
- A. Writing the contract's frontend user interface
- B. Compiling the contract source code into bytecode
- C. Sending tokens to every user of the network
- D. Deleting the contract's test files
Q2. Why are gas fees required when deploying a smart contract?
- A. To pay the developer for writing the code
- B. To compensate network validators for the computational resources used to store and process the contract
- C. To register the contract's name with a central authority
- D. To encrypt the contract's source code
Q3. Once a smart contract has been deployed to a standard blockchain, what is generally true about its code?
- A. It can be edited directly by the original developer at any time
- B. It is automatically deleted after a set period
- C. It is immutable and cannot be changed in place
- D. It is copied to every new block automatically
Q4. What is a common pattern used to allow smart contract logic to be updated after deployment?
- A. Deleting the contract and redeploying it under the same address
- B. Using a proxy contract that delegates calls to a separate implementation contract that can be swapped out
- C. Editing the bytecode stored on the blockchain
- D. Asking users to manually download a new version of the contract
Q5. Why is it considered a best practice to test a smart contract on a testnet before deploying it to mainnet?
- A. Testnet deployments are free of charge and never require any gas
- B. Testnets allow developers to catch bugs and verify behavior using worthless tokens before real assets are at risk
- C. Mainnet automatically rejects any contract that has not been tested
- D. Testnets permanently store the contract so it can be reused on mainnet