Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.
You're offline
Unit 3 MCQsIntroduction to Truffle and smart contracts development
Question 1 of 60 · overview of Truffle framework · Easy
What is Truffle primarily used for in blockchain development?
Not quite. Try another option.
Answer: A development framework for Ethereum smart contracts
Truffle is a popular development framework that helps developers compile, test, and deploy smart contracts on Ethereum and other EVM-compatible blockchains.
Question 2 of 60 · overview of Truffle framework · Easy
Which programming language is Truffle itself built on and run with?
Not quite. Try another option.
Answer: Node.js (JavaScript)
Truffle is a Node.js-based tool and is typically installed using the npm package manager.
Question 3 of 60 · overview of Truffle framework · Easy
Which command is commonly used to install Truffle globally?
Not quite. Try another option.
Answer: npm install -g truffle
Because Truffle is distributed as an npm package, it is installed globally using npm install -g truffle.
Question 4 of 60 · overview of Truffle framework · Easy
In a Truffle project, which configuration file stores network and compiler settings?
Not quite. Try another option.
Answer: truffle-config.js
The truffle-config.js file defines networks, compiler versions, and other project settings used by Truffle.
Question 5 of 60 · overview of Truffle framework · Easy
Which Truffle command initializes a new, empty project structure?
Not quite. Try another option.
Answer: truffle init
truffle init creates the standard folder structure, including contracts, migrations, and the configuration file.
Question 6 of 60 · creating a simple smart contract · Easy
Which programming language is most commonly used to write Ethereum smart contracts?
Not quite. Try another option.
Answer: Solidity
Solidity is the most widely used high-level language for writing smart contracts on Ethereum.
Question 7 of 60 · creating a simple smart contract · Easy
What is the typical file extension for a Solidity smart contract?
Not quite. Try another option.
Answer: .sol
Solidity source files use the .sol extension and are placed in the contracts folder of a Truffle project.
Question 8 of 60 · creating a simple smart contract · Easy
Which keyword is used to declare a smart contract in Solidity?
Not quite. Try another option.
Answer: contract
A smart contract in Solidity is defined using the contract keyword, for example contract MyContract { }.
Question 9 of 60 · creating a simple smart contract · Easy
Which statement declares the Solidity compiler version in a contract?
Not quite. Try another option.
Answer: pragma solidity ^0.8.0;
The pragma solidity directive specifies which compiler versions are compatible with the contract.
Question 10 of 60 · creating a simple smart contract · Easy
In which folder of a Truffle project are smart contract source files placed?
Not quite. Try another option.
Answer: contracts
Solidity source files are stored in the contracts directory, which Truffle reads during compilation.
Question 11 of 60 · compiling and deploying smart contracts · Easy
Which Truffle command compiles the smart contracts in a project?
Not quite. Try another option.
Answer: truffle compile
truffle compile compiles the Solidity source files and generates artifacts in the build folder.
Question 12 of 60 · compiling and deploying smart contracts · Easy
Which Truffle command deploys contracts to a configured network?
Not quite. Try another option.
Answer: truffle migrate
truffle migrate runs the migration scripts that deploy compiled contracts to the chosen network.
Question 13 of 60 · compiling and deploying smart contracts · Easy
What is produced when a Solidity contract is compiled?
Not quite. Try another option.
Answer: Bytecode and an ABI
Compilation generates EVM bytecode for deployment and an ABI (Application Binary Interface) describing how to interact with the contract.
Question 14 of 60 · compiling and deploying smart contracts · Easy
In which folder are the migration scripts stored in a Truffle project?
Not quite. Try another option.
Answer: migrations
Deployment logic is written in JavaScript files placed in the migrations folder.
Question 15 of 60 · compiling and deploying smart contracts · Easy
What does ABI stand for in the context of smart contracts?
Not quite. Try another option.
Answer: Application Binary Interface
The ABI (Application Binary Interface) defines how external applications encode calls to and decode data from a contract.
Question 16 of 60 · using application templates · Easy
What is the main benefit of using an application template (box) in Truffle?
Not quite. Try another option.
Answer: It provides a ready-made starting project structure
Templates (Truffle Boxes) give developers prebuilt boilerplate code and configuration to start projects faster.
Question 17 of 60 · using application templates · Easy
What are reusable Truffle project templates commonly called?
Not quite. Try another option.
Answer: Truffle Boxes
Truffle Boxes are packaged templates containing contracts, front-end code, and configuration to bootstrap development.
Question 18 of 60 · overview of popular blockchain application templates · Easy
Which command is used to download a Truffle Box template into a project?
Not quite. Try another option.
Answer: truffle unbox
truffle unbox <box-name> downloads and sets up a template project in the current directory.
Question 19 of 60 · discussion on popular templates (e.g., Ethereum, Hyperledger) · Easy
Which blockchain platform is known for being permissioned and enterprise-focused?
Not quite. Try another option.
Answer: Hyperledger Fabric
Hyperledger Fabric is a permissioned, enterprise-oriented platform where participants are known and authorized.
Question 20 of 60 · discussion on popular templates (e.g., Ethereum, Hyperledger) · Easy
Which platform is a public blockchain that popularized smart contracts using Solidity?
Not quite. Try another option.
Answer: Ethereum
Ethereum is a public, permissionless blockchain that introduced widely used smart contracts written in Solidity.
Question 21 of 60 · overview of Truffle framework · Medium
A developer wants a single toolset that handles smart contract compilation, automated testing, and scriptable deployment for Ethereum. Which role does the Truffle framework primarily serve?
Not quite. Try another option.
Answer: A development environment, testing framework, and asset pipeline for EVM-based blockchains
Truffle is a development framework for EVM-based chains that bundles compilation, testing, deployment (migrations), and asset management. It is not a consensus protocol, a wallet, or a language.
Question 22 of 60 · overview of Truffle framework · Medium
In a Truffle project, which configuration file is used to define networks, compiler versions, and deployment settings?
Not quite. Try another option.
Answer: truffle-config.js
truffle-config.js (sometimes truffle.js) holds network definitions, compiler version, and other project settings. package.json manages npm dependencies, not Truffle networks.
Question 23 of 60 · overview of Truffle framework · Medium
A team wants a local in-memory blockchain to test contracts quickly without spending real ETH. Which tool in the Truffle ecosystem is designed for this?
Not quite. Try another option.
Answer: Ganache
Ganache provides a personal, local blockchain for development and testing with pre-funded accounts. Infura is a remote node provider, Remix is a web IDE, and MetaMask is a wallet.
Question 24 of 60 · overview of Truffle framework · Medium
Which Truffle command would a developer use to scaffold a new project using a predefined Truffle Box template?
Not quite. Try another option.
Answer: truffle unbox <box-name>
truffle unbox downloads and sets up a Truffle Box (a boilerplate template). truffle init creates an empty bare project without a specific box.
Question 25 of 60 · creating a simple smart contract · Medium
In which directory of a standard Truffle project should Solidity source files (.sol) be placed?
Not quite. Try another option.
Answer: contracts/
Solidity contract sources live in contracts/. The migrations/ folder holds deployment scripts, build/ holds compiled artifacts, and test/ holds tests.
Question 26 of 60 · creating a simple smart contract · Medium
A simple contract begins with pragma solidity ^0.8.0;. What does the caret (^) in the version pragma indicate?
Not quite. Try another option.
Answer: Compatible with 0.8.x up to but not including 0.9.0
The caret allows the stated minor version range (0.8.0 up to <0.9.0). It is not an exact pin and does not extend into the next minor release.
Question 27 of 60 · creating a simple smart contract · Medium
Consider a state variable declared as uint256 public count; in a Solidity contract. What does the public keyword automatically provide?
Not quite. Try another option.
Answer: An auto-generated getter function for reading count
A public state variable gets a compiler-generated getter of the same name. Solidity does not auto-generate setters, and on-chain data is not encrypted.
Question 28 of 60 · creating a simple smart contract · Medium
A developer writes a function intended to receive Ether directly. Which function modifier must be included for the function to accept ETH?
Not quite. Try another option.
Answer: payable
A function must be marked payable to receive Ether. view and pure cannot accept funds, and external only sets visibility, not payment capability.
Question 29 of 60 · compiling and deploying smart contracts · Medium
After running truffle compile, where does Truffle place the resulting contract artifacts (ABI and bytecode)?
Not quite. Try another option.
Answer: build/contracts/ as JSON files
Compilation outputs JSON artifacts (containing ABI and bytecode) into build/contracts/. The source .sol files stay in contracts/.
Question 30 of 60 · compiling and deploying smart contracts · Medium
Which command deploys contracts to a configured network by running the scripts in the migrations/ folder?
Not quite. Try another option.
Answer: truffle migrate
truffle migrate executes migration scripts to deploy contracts. (truffle deploy is an alias, but --now is not a valid flag here, and the other forms are invalid.)
Question 31 of 60 · compiling and deploying smart contracts · Medium
A migration script contains deployer.deploy(MyContract, 100);. What does the value 100 represent?
Not quite. Try another option.
Answer: An argument passed to MyContract's constructor
Extra arguments to deployer.deploy after the contract name are forwarded to the contract's constructor. Gas and network settings are configured separately.
Question 32 of 60 · compiling and deploying smart contracts · Medium
A developer runs truffle migrate a second time without changes and notices contracts are not redeployed. Which flag forces all migrations to run again from the beginning?
Not quite. Try another option.
Answer: --reset
Truffle tracks completed migrations and skips them on reruns. truffle migrate --reset runs every migration again from scratch.
Question 33 of 60 · compiling and deploying smart contracts · Medium
Why does deploying a smart contract to a public Ethereum network require gas, while compiling it locally does not?
Not quite. Try another option.
Answer: Deployment is a state-changing transaction recorded on-chain, whereas compilation is a local operation
Compilation runs locally and produces bytecode offline. Deployment broadcasts a transaction that writes code to the blockchain, which consumes gas paid to validators.
Question 34 of 60 · using application templates · Medium
What is the primary advantage of starting a dApp from a Truffle Box rather than an empty project?
Not quite. Try another option.
Answer: It provides preconfigured contracts, tests, and front-end scaffolding to speed up setup
Boxes bundle boilerplate code, configuration, and sometimes front-end integration to accelerate development. They do not auto-deploy, eliminate coding, or guarantee security.
Question 35 of 60 · using application templates · Medium
A developer unboxes the react Truffle Box. Which combination of concerns does this template typically address out of the box?
Not quite. Try another option.
Answer: Smart contracts plus a React front-end wired to interact with them
The React box scaffolds both the contract layer and a React UI connected via web3/Drizzle. It is not about consensus, SQL, or contract-free mobile apps.
Question 36 of 60 · using application templates · Medium
When choosing an application template for a new project, which factor is MOST important to evaluate first?
Not quite. Try another option.
Answer: Whether the template's tech stack and target chain match the project requirements
A template is only useful if its stack, framework, and target blockchain fit your needs. File count and README length are poor selection criteria.
Question 37 of 60 · overview of popular blockchain application templates · Medium
An enterprise consortium needs a permissioned blockchain where participant identities are known and controlled. Which platform's templates are most appropriate?
Not quite. Try another option.
Answer: Hyperledger Fabric
Hyperledger Fabric is designed for permissioned networks with known, authenticated members—ideal for consortiums. Public Ethereum, Bitcoin, and Dogecoin are permissionless.
Question 38 of 60 · overview of popular blockchain application templates · Medium
Which characteristic distinguishes an ERC-20 token template from an ERC-721 token template?
Not quite. Try another option.
Answer: ERC-20 defines fungible tokens, while ERC-721 defines non-fungible tokens
ERC-20 standardizes interchangeable (fungible) tokens; ERC-721 standardizes unique (non-fungible) tokens. Both are Ethereum standards and both support transfers.
Question 39 of 60 · discussion on popular templates (e.g., Ethereum, Hyperledger) · Medium
A key difference between Ethereum and Hyperledger Fabric templates is their approach to data visibility. Which statement is correct?
Not quite. Try another option.
Answer: Ethereum (public) exposes transactions to all nodes, while Fabric supports private channels for restricted sharing
Public Ethereum data is visible to all network participants, whereas Fabric's channels and private data collections limit visibility to authorized members.
Question 40 of 60 · discussion on popular templates (e.g., Ethereum, Hyperledger) · Medium
On which platform are smart contracts commonly called "chaincode" and written in general-purpose languages like Go or Java?
Not quite. Try another option.
Answer: Hyperledger Fabric
Hyperledger Fabric calls its smart contracts "chaincode" and supports Go, Java, and Node.js. Ethereum uses Solidity for contracts on the EVM.
Question 41 of 60 · overview of Truffle framework · Hard
In a Truffle project, a developer sets networks in truffle-config.js with network_id: "*" for the development network. What is the precise consequence of using the wildcard versus a fixed numeric id?
Not quite. Try another option.
Answer: Truffle will match any network id reported by the connected client, which is convenient for ephemeral chains but prevents detection of accidental deployment to the wrong network
"*" tells Truffle to accept whatever network id the provider returns. It is safe for throwaway dev chains but removes the safety check that a fixed id gives against deploying to an unintended network.
Question 42 of 60 · overview of Truffle framework · Hard
A team wants deterministic, repeatable deployments where migration state is persisted on-chain. Which Truffle mechanism records which migrations have already run?
Not quite. Try another option.
Answer: The Migrations.sol contract storing the last completed migration index on-chain
Truffle deploys a Migrations contract whose last_completed_migration value tracks progress, so re-running truffle migrate only executes pending scripts unless --reset is passed.
Question 43 of 60 · creating a simple smart contract · Hard
Given a Solidity contract with uint8 public counter; incremented in a loop, at what value does an unchecked increment wrap in Solidity versus earlier versions?
Not quite. Try another option.
Answer: In it reverts on overflow past unless wrapped in unchecked, while pre- silently wraps to
Solidity 0.8.0 introduced built-in overflow checks that revert. A uint8 holds –; incrementing past it reverts unless placed in an unchecked block, whereas older compilers wrapped around silently.
Question 44 of 60 · creating a simple smart contract · Hard
A contract declares constructor() payable {} and a non-payable function deposit(). A user sends 1 ETH with a call to deposit(). What happens?
Not quite. Try another option.
Answer: The transaction reverts because value was sent to a non-payable function
Only payable functions can receive Ether. Sending value to a non-payable function triggers an automatic revert; the payable constructor only applies at deployment, not later calls.
Question 45 of 60 · compiling and deploying smart contracts · Hard
During truffle compile, the artifact JSON contains both bytecode and deployedBytecode. What is the key difference between them?
Not quite. Try another option.
Answer: bytecode includes constructor/creation code that runs once and returns deployedBytecode, which is what lives permanently at the contract address
Creation (bytecode) runs the constructor during deployment and returns the runtime code (deployedBytecode), which is the code stored at the address and executed on subsequent calls.
Question 46 of 60 · compiling and deploying smart contracts · Hard
A deployment fails with "exceeds block gas limit". Which action is most likely to resolve it without changing contract logic?
Not quite. Try another option.
Answer: Enabling the optimizer and reducing deployment bytecode size, or splitting the contract via libraries/proxies
The error means deployment gas exceeds the block limit. Raising gas price does not help; reducing bytecode via the optimizer or splitting logic into libraries/proxies lowers deployment gas.
Question 47 of 60 · compiling and deploying smart contracts · Hard
In a migration script, deployer.deploy(A); deployer.deploy(B, A.address); sometimes fails with A.address undefined. What is the correct pattern?
Not quite. Try another option.
Answer: Chain with .then() or use deployer.deploy(A).then(() => deployer.deploy(B, A.address)); so B deploys after A is mined
A.address is only populated after A is deployed. The deployer queue is sequential, but referencing A.address synchronously can race; chaining ensures A's address is available before deploying B.
Question 48 of 60 · compiling and deploying smart contracts · Hard
A contract compiles cleanly but truffle migrate reverts in the constructor only on a public testnet, not on Ganache. Which cause is most plausible?
Not quite. Try another option.
Answer: An external call or block assumption (e.g., precompile, timestamp, or chainid) behaves differently on the live network
Ganache is an idealized environment. Constructor logic depending on external contracts, oracle calls, chain id, or timestamps can succeed locally but revert on a real network where those differ.
Question 49 of 60 · using application templates · Hard
A developer runs truffle unbox <box>. What does unboxing an application template primarily provide beyond raw contract files?
Not quite. Try another option.
Answer: A preconfigured project scaffold including migrations, tests, front-end integration, and dependencies wired together
Truffle Boxes bundle contracts, migrations, tests, config, and often a front-end plus libraries, letting developers start from a working, integrated template rather than wiring everything manually.
Question 50 of 60 · using application templates · Hard
When a Truffle Box ships with a truffle-box.json file, what is its main role during truffle unbox?
Not quite. Try another option.
Answer: It defines post-unpack commands, ignored files, and hooks that configure the project after extraction
truffle-box.json specifies ignore rules, commands to display, and post-unpack hooks (like npm install), controlling how the template is prepared after being fetched.
Question 51 of 60 · using application templates · Hard
A team forks a React Truffle Box but their front-end cannot find the deployed contract address after redeploying. What is the most likely fix?
Not quite. Try another option.
Answer: Ensure the build artifacts in client/src/contracts are refreshed so the networks mapping reflects the new deployment
The front-end reads the contract address from the artifact's networks section. After redeploying (especially with --reset), stale artifacts must be rebuilt/copied so the UI resolves the new address.
Question 52 of 60 · overview of popular blockchain application templates · Hard
Which statement best contrasts a DApp starter template targeting Ethereum with a chaincode template targeting Hyperledger Fabric?
Not quite. Try another option.
Answer: The Ethereum template assumes a public, gas-metered EVM and token/web3 integration, while the Fabric template assumes a permissioned network with channels, MSP identities, and endorsement policies
Ethereum templates center on EVM, gas, and web3/token patterns. Fabric templates target permissioned deployments with membership (MSP), channels, and endorsement policies—fundamentally different architectures.
Question 53 of 60 · overview of popular blockchain application templates · Hard
A template advertises "upgradeable contracts." Which architectural pattern is almost certainly in use?
Not quite. Try another option.
Answer: A proxy contract delegating via delegatecall to a logic contract whose address can be swapped
Upgradeability on the EVM is achieved with a proxy that holds state and uses delegatecall to an interchangeable implementation contract, since deployed code itself is immutable.
Question 54 of 60 · overview of popular blockchain application templates · Hard
A token template implements ERC-20 but exposes a mint() callable by anyone. What is the primary security flaw?
Not quite. Try another option.
Answer: Missing access control allows unlimited supply inflation by any caller
ERC-20 does not mandate or forbid minting, but an unrestricted mint() lets anyone create tokens, destroying scarcity. It must be guarded (e.g., onlyOwner or role-based access).
Question 55 of 60 · discussion on popular templates (e.g., Ethereum, Hyperledger) · Hard
In Hyperledger Fabric, a chaincode template reads a key, modifies it, and writes it back. Under high concurrency, two transactions in the same block touch the same key. What determines the outcome?
Not quite. Try another option.
Answer: MVCC read-set validation causes one transaction to be invalidated due to a version conflict during the validation phase
Fabric's execute-order-validate model records read versions. At validation, if a key's version changed since the transaction read it, that transaction is marked invalid (MVCC_READ_CONFLICT) and not applied.
Question 56 of 60 · discussion on popular templates (e.g., Ethereum, Hyperledger) · Hard
An Ethereum template uses tx.origin for authorization. Why is this considered an edge-case vulnerability compared to msg.sender?
Not quite. Try another option.
Answer: A malicious intermediate contract can trick a user into a call where tx.origin is still the user, enabling phishing-style authorization bypass
tx.origin is the original EOA for the whole call chain. If a user calls a malicious contract that then calls the victim, tx.origin still equals the user, so authorization checks pass—hence msg.sender is preferred.
Question 57 of 60 · discussion on popular templates (e.g., Ethereum, Hyperledger) · Hard
Which difference most directly explains why a Fabric chaincode cannot rely on Math.random() or system time the way off-chain code might?
Not quite. Try another option.
Answer: Chaincode must be deterministic across endorsing peers; non-deterministic values would produce differing read/write sets and fail endorsement validation
Multiple peers independently execute chaincode and must produce identical results to satisfy the endorsement policy. Non-deterministic sources yield mismatched outputs, breaking consensus on the transaction.
Question 58 of 60 · compiling and deploying smart contracts · Hard
Two contracts in a project pin different pragma ranges: ^0.8.0 and >=0.7.0 <0.9.0. The config sets compilers.solc.version: "0.8.19". What is the result?
Not quite. Try another option.
Answer: Both compile, since 0.8.19 satisfies both ranges
A single configured compiler must satisfy every file's pragma. falls within ^0.8.0 and >=0.7.0 <0.9.0, so both compile with one compiler version.
Question 59 of 60 · overview of Truffle framework · Hard
In the Truffle console, calling a view function returns a value immediately, but calling a state-changing function returns a transaction object instead of the new state. Why?
Not quite. Try another option.
Answer: State-changing calls are mined as transactions whose return values are not accessible off-chain, so you must read state afterward or inspect emitted events
A view is a call (no mining), returning data directly. A mutating function is a transaction; its Solidity return value isn't available to the sender, so events or follow-up reads are used to observe effects.
Question 60 of 60 · creating a simple smart contract · Hard
A contract stores a dynamic string[] public names;. A developer worries about gas when iterating over it in a function to find a match. What is the fundamental risk?
Not quite. Try another option.
Answer: An unbounded loop can exceed the block gas limit as the array grows, making the function permanently uncallable (a DoS vector)
Looping over an unbounded array costs gas proportional to its size. Once it grows large enough, the loop exceeds the block gas limit and the function reverts for everyone—a classic gas-limit DoS.
That's unit 3
Answer a few questions and your score shows up here.
Nearly through. Did unit 3 of CSC307 save you a night before the exam?
LPU Notes is free. A student pays for the servers.
Did unit 3 of CSC307 save you a night before the exam?
Then you can help keep it free for the next batch. Ads cover part of the server bill;
the rest comes out of a student's own pocket: the domain, the storage, and keeping
the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason.
to try again.