Unit 3: Introduction to Truffle and smart contracts development - Practice Quiz
1 What is Truffle primarily used for in blockchain development?
2 Which programming language is Truffle itself built on and run with?
3 Which command is commonly used to install Truffle globally?
apt-get install truffle
pip install truffle
npm install -g truffle
cargo add truffle
4 In a Truffle project, which configuration file stores network and compiler settings?
truffle-config.js
package.json
settings.xml
config.yaml
5 Which Truffle command initializes a new, empty project structure?
truffle create
truffle init
truffle start
truffle new
6 Which programming language is most commonly used to write Ethereum smart contracts?
7 What is the typical file extension for a Solidity smart contract?
.js
.sol
.contract
.eth
8 Which keyword is used to declare a smart contract in Solidity?
struct
contract
class
module
9 Which statement declares the Solidity compiler version in a contract?
import solidity 0.8.0;
pragma solidity ^0.8.0;
version solidity 0.8.0;
use solidity ^0.8.0;
10 In which folder of a Truffle project are smart contract source files placed?
build
test
contracts
migrations
11 Which Truffle command compiles the smart contracts in a project?
truffle compile
truffle run
truffle build
truffle make
12 Which Truffle command deploys contracts to a configured network?
truffle deploy
truffle push
truffle send
truffle migrate
13 What is produced when a Solidity contract is compiled?
14 In which folder are the migration scripts stored in a Truffle project?
contracts
scripts
migrations
deploy
15 What does ABI stand for in the context of smart contracts?
16 What is the main benefit of using an application template (box) in Truffle?
17 What are reusable Truffle project templates commonly called?
18 Which command is used to download a Truffle Box template into a project?
truffle unbox
truffle get
truffle download
truffle clone
19 Which blockchain platform is known for being permissioned and enterprise-focused?
20 Which platform is a public blockchain that popularized smart contracts using Solidity?
21 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?
22 In a Truffle project, which configuration file is used to define networks, compiler versions, and deployment settings?
package.json
migrations.sol
genesis.json
truffle-config.js
23 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?
24 Which Truffle command would a developer use to scaffold a new project using a predefined Truffle Box template?
truffle init <box-name>
truffle install <box-name>
truffle unbox <box-name>
truffle create box
25
In which directory of a standard Truffle project should Solidity source files (.sol) be placed?
test/
build/
contracts/
migrations/
26
A simple contract begins with pragma solidity ^0.8.0;. What does the caret (^) in the version pragma indicate?
27
Consider a state variable declared as uint256 public count; in a Solidity contract. What does the public keyword automatically provide?
count externally
count
28 A developer writes a function intended to receive Ether directly. Which function modifier must be included for the function to accept ETH?
external
view
payable
pure
29
After running truffle compile, where does Truffle place the resulting contract artifacts (ABI and bytecode)?
test/ as .js files
contracts/ alongside the .sol files
build/contracts/ as JSON files
migrations/ as .sol files
30
Which command deploys contracts to a configured network by running the scripts in the migrations/ folder?
truffle migrate
truffle compile --deploy
truffle deploy --now
truffle run migrate
31
A migration script contains deployer.deploy(MyContract, 100);. What does the value 100 represent?
MyContract's constructor
32
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?
--rerun
--reset
--clean
--force-all
33 Why does deploying a smart contract to a public Ethereum network require gas, while compiling it locally does not?
34 What is the primary advantage of starting a dApp from a Truffle Box rather than an empty project?
35
A developer unboxes the react Truffle Box. Which combination of concerns does this template typically address out of the box?
36 When choosing an application template for a new project, which factor is MOST important to evaluate first?
37 An enterprise consortium needs a permissioned blockchain where participant identities are known and controlled. Which platform's templates are most appropriate?
38 Which characteristic distinguishes an ERC-20 token template from an ERC-721 token template?
39 A key difference between Ethereum and Hyperledger Fabric templates is their approach to data visibility. Which statement is correct?
40 On which platform are smart contracts commonly called "chaincode" and written in general-purpose languages like Go or Java?
41
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?
--network flag
42 A team wants deterministic, repeatable deployments where migration state is persisted on-chain. Which Truffle mechanism records which migrations have already run?
Migrations.sol contract storing the last completed migration index on-chain
.truffle-cache folder hashing each artifact
package-lock.json deployment manifest
43
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?
unchecked, while pre- silently wraps to
44
A contract declares constructor() payable {} and a non-payable function deposit(). A user sends 1 ETH with a call to deposit(). What happens?
45
During truffle compile, the artifact JSON contains both bytecode and deployedBytecode. What is the key difference between them?
bytecode is the optimized version and deployedBytecode is the unoptimized one
bytecode includes constructor/creation code that runs once and returns deployedBytecode, which is what lives permanently at the contract address
deployedBytecode includes the ABI while bytecode does not
46 A deployment fails with "exceeds block gas limit". Which action is most likely to resolve it without changing contract logic?
gasPrice in the config
47
In a migration script, deployer.deploy(A); deployer.deploy(B, A.address); sometimes fails with A.address undefined. What is the correct pattern?
.then() or use deployer.deploy(A).then(() => deployer.deploy(B, A.address)); so B deploys after A is mined
A instead of A.address since Truffle resolves it lazily
Promise.all to parallelize
48
A contract compiles cleanly but truffle migrate reverts in the constructor only on a public testnet, not on Ganache. Which cause is most plausible?
block assumption (e.g., precompile, timestamp, or chainid) behaves differently on the live network
49
A developer runs truffle unbox <box>. What does unboxing an application template primarily provide beyond raw contract files?
50
When a Truffle Box ships with a truffle-box.json file, what is its main role during truffle unbox?
51 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?
client/src/contracts are refreshed so the networks mapping reflects the new deployment
52 Which statement best contrasts a DApp starter template targeting Ethereum with a chaincode template targeting Hyperledger Fabric?
53 A template advertises "upgradeable contracts." Which architectural pattern is almost certainly in use?
delegatecall to a logic contract whose address can be swapped
54
A token template implements ERC-20 but exposes a mint() callable by anyone. What is the primary security flaw?
decimals value must be 0 for mintable tokens
mint function entirely
totalSupply cannot change after deployment under ERC-20
55 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?
56
An Ethereum template uses tx.origin for authorization. Why is this considered an edge-case vulnerability compared to msg.sender?
tx.origin costs more gas and reverts randomly
tx.origin returns the contract address, not the user
tx.origin is always zero on testnets
tx.origin is still the user, enabling phishing-style authorization bypass
57
Which difference most directly explains why a Fabric chaincode cannot rely on Math.random() or system time the way off-chain code might?
58
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?
59
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?
view functions bypass the EVM entirely and run in JavaScript
null by Solidity spec
60
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?
public in Solidity
bytes32 conversion
Did this save you a night before the exam?
LPU Notes is free, and it stays free. 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.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it. What it pays for →