Unit 3: Introduction to Truffle and smart contracts development - Practice Quiz

CSC307 — Blockchain Architecture And Design-I 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 What is Truffle primarily used for in blockchain development?

overview of Truffle framework Easy
A. A development framework for Ethereum smart contracts
B. A hardware device for storing keys
C. A consensus algorithm for mining
D. A cryptocurrency wallet application

2 Which programming language is Truffle itself built on and run with?

overview of Truffle framework Easy
A. Go
B. Node.js (JavaScript)
C. Python
D. Rust

3 Which command is commonly used to install Truffle globally?

overview of Truffle framework Easy
A. apt-get install truffle
B. pip install truffle
C. npm install -g truffle
D. cargo add truffle

4 In a Truffle project, which configuration file stores network and compiler settings?

overview of Truffle framework Easy
A. truffle-config.js
B. package.json
C. settings.xml
D. config.yaml

5 Which Truffle command initializes a new, empty project structure?

overview of Truffle framework Easy
A. truffle create
B. truffle init
C. truffle start
D. truffle new

6 Which programming language is most commonly used to write Ethereum smart contracts?

creating a simple smart contract Easy
A. Ruby
B. Java
C. Solidity
D. C#

7 What is the typical file extension for a Solidity smart contract?

creating a simple smart contract Easy
A. .js
B. .sol
C. .contract
D. .eth

8 Which keyword is used to declare a smart contract in Solidity?

creating a simple smart contract Easy
A. struct
B. contract
C. class
D. module

9 Which statement declares the Solidity compiler version in a contract?

creating a simple smart contract Easy
A. import solidity 0.8.0;
B. pragma solidity ^0.8.0;
C. version solidity 0.8.0;
D. use solidity ^0.8.0;

10 In which folder of a Truffle project are smart contract source files placed?

creating a simple smart contract Easy
A. build
B. test
C. contracts
D. migrations

11 Which Truffle command compiles the smart contracts in a project?

compiling and deploying smart contracts Easy
A. truffle compile
B. truffle run
C. truffle build
D. truffle make

12 Which Truffle command deploys contracts to a configured network?

compiling and deploying smart contracts Easy
A. truffle deploy
B. truffle push
C. truffle send
D. truffle migrate

13 What is produced when a Solidity contract is compiled?

compiling and deploying smart contracts Easy
A. A private key
B. A mining block
C. A PDF report
D. Bytecode and an ABI

14 In which folder are the migration scripts stored in a Truffle project?

compiling and deploying smart contracts Easy
A. contracts
B. scripts
C. migrations
D. deploy

15 What does ABI stand for in the context of smart contracts?

compiling and deploying smart contracts Easy
A. Automated Blockchain Index
B. Asynchronous Block Identifier
C. Application Binary Interface
D. Advanced Byte Instruction

16 What is the main benefit of using an application template (box) in Truffle?

using application templates Easy
A. It provides a ready-made starting project structure
B. It mines cryptocurrency automatically
C. It replaces the need for a blockchain
D. It encrypts private keys

17 What are reusable Truffle project templates commonly called?

using application templates Easy
A. Truffle Kits
B. Truffle Blocks
C. Truffle Packs
D. Truffle Boxes

18 Which command is used to download a Truffle Box template into a project?

overview of popular blockchain application templates Easy
A. truffle unbox
B. truffle get
C. truffle download
D. truffle clone

19 Which blockchain platform is known for being permissioned and enterprise-focused?

discussion on popular templates (e.g., Ethereum, Hyperledger) Easy
A. Hyperledger Fabric
B. Dogecoin
C. Bitcoin
D. Ethereum Mainnet

20 Which platform is a public blockchain that popularized smart contracts using Solidity?

discussion on popular templates (e.g., Ethereum, Hyperledger) Easy
A. Quorum
B. Ethereum
C. Corda
D. Hyperledger Fabric

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?

overview of Truffle framework Medium
A. A development environment, testing framework, and asset pipeline for EVM-based blockchains
B. A smart contract language that competes with Solidity
C. A peer-to-peer network protocol that replaces Ethereum consensus
D. A browser wallet used only for signing user transactions

22 In a Truffle project, which configuration file is used to define networks, compiler versions, and deployment settings?

overview of Truffle framework Medium
A. package.json
B. migrations.sol
C. genesis.json
D. 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?

overview of Truffle framework Medium
A. Ganache
B. Infura
C. Remix
D. MetaMask

24 Which Truffle command would a developer use to scaffold a new project using a predefined Truffle Box template?

overview of Truffle framework Medium
A. truffle init <box-name>
B. truffle install <box-name>
C. truffle unbox <box-name>
D. truffle create box

25 In which directory of a standard Truffle project should Solidity source files (.sol) be placed?

creating a simple smart contract Medium
A. test/
B. build/
C. contracts/
D. migrations/

26 A simple contract begins with pragma solidity ^0.8.0;. What does the caret (^) in the version pragma indicate?

creating a simple smart contract Medium
A. Any version from 0.8.0 onward including 1.0.0
B. Compatible with 0.8.x up to but not including 0.9.0
C. Any version below 0.8.0 is required
D. Only exactly version 0.8.0 may compile it

27 Consider a state variable declared as uint256 public count; in a Solidity contract. What does the public keyword automatically provide?

creating a simple smart contract Medium
A. Encryption of the value stored on-chain
B. A setter function to modify count externally
C. A guarantee that only the owner can read it
D. An auto-generated getter function for reading count

28 A developer writes a function intended to receive Ether directly. Which function modifier must be included for the function to accept ETH?

creating a simple smart contract Medium
A. external
B. view
C. payable
D. pure

29 After running truffle compile, where does Truffle place the resulting contract artifacts (ABI and bytecode)?

compiling and deploying smart contracts Medium
A. test/ as .js files
B. contracts/ alongside the .sol files
C. build/contracts/ as JSON files
D. migrations/ as .sol files

30 Which command deploys contracts to a configured network by running the scripts in the migrations/ folder?

compiling and deploying smart contracts Medium
A. truffle migrate
B. truffle compile --deploy
C. truffle deploy --now
D. truffle run migrate

31 A migration script contains deployer.deploy(MyContract, 100);. What does the value 100 represent?

compiling and deploying smart contracts Medium
A. An argument passed to MyContract's constructor
B. The number of copies to deploy
C. The network ID to deploy to
D. The gas limit for the deployment

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?

compiling and deploying smart contracts Medium
A. --rerun
B. --reset
C. --clean
D. --force-all

33 Why does deploying a smart contract to a public Ethereum network require gas, while compiling it locally does not?

compiling and deploying smart contracts Medium
A. Compilation uses more computing power than deployment
B. Compilation happens on miners' machines and deployment happens locally
C. Deployment is a state-changing transaction recorded on-chain, whereas compilation is a local operation
D. Gas is only charged for reading data, not writing it

34 What is the primary advantage of starting a dApp from a Truffle Box rather than an empty project?

using application templates Medium
A. It guarantees the contracts are free of security bugs
B. It removes the need to write any Solidity code
C. It automatically deploys the dApp to the Ethereum mainnet
D. It provides preconfigured contracts, tests, and front-end scaffolding to speed up setup

35 A developer unboxes the react Truffle Box. Which combination of concerns does this template typically address out of the box?

using application templates Medium
A. A standalone mobile app with no contracts
B. Only consensus algorithm configuration
C. Database schema migrations for SQL
D. Smart contracts plus a React front-end wired to interact with them

36 When choosing an application template for a new project, which factor is MOST important to evaluate first?

using application templates Medium
A. Whether the template has the shortest README
B. Whether the template was created most recently regardless of purpose
C. Whether the template's tech stack and target chain match the project requirements
D. Whether the template uses the fewest files

37 An enterprise consortium needs a permissioned blockchain where participant identities are known and controlled. Which platform's templates are most appropriate?

overview of popular blockchain application templates Medium
A. Bitcoin
B. Hyperledger Fabric
C. Dogecoin
D. Public Ethereum mainnet

38 Which characteristic distinguishes an ERC-20 token template from an ERC-721 token template?

overview of popular blockchain application templates Medium
A. ERC-20 defines fungible tokens, while ERC-721 defines non-fungible tokens
B. ERC-20 cannot be transferred, while ERC-721 can
C. ERC-20 runs on Hyperledger, while ERC-721 runs on Ethereum
D. ERC-20 is for images only, while ERC-721 is for currency

39 A key difference between Ethereum and Hyperledger Fabric templates is their approach to data visibility. Which statement is correct?

discussion on popular templates (e.g., Ethereum, Hyperledger) Medium
A. Ethereum (public) exposes transactions to all nodes, while Fabric supports private channels for restricted sharing
B. Fabric broadcasts every transaction to a global public ledger
C. Both expose all data publicly to anyone on the internet
D. Ethereum keeps all contract state fully private by default

40 On which platform are smart contracts commonly called "chaincode" and written in general-purpose languages like Go or Java?

discussion on popular templates (e.g., Ethereum, Hyperledger) Medium
A. Ethereum
B. Solana
C. Cardano
D. Hyperledger Fabric

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?

overview of Truffle framework Hard
A. Truffle will deploy to every configured network simultaneously regardless of the --network flag
B. Truffle will refuse to deploy unless the chain id equals the block gas limit divided by 1000
C. Truffle will automatically fork mainnet state into the local chain before migrating
D. 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

42 A team wants deterministic, repeatable deployments where migration state is persisted on-chain. Which Truffle mechanism records which migrations have already run?

overview of Truffle framework Hard
A. The Ganache mnemonic seed file
B. The Migrations.sol contract storing the last completed migration index on-chain
C. The .truffle-cache folder hashing each artifact
D. The 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?

creating a simple smart contract Hard
A. Both versions silently wrap to at
B. Both versions revert at due to signedness
C. In it reverts on overflow past unless wrapped in unchecked, while pre- silently wraps to
D. In it saturates at and never reverts

44 A contract declares constructor() payable {} and a non-payable function deposit(). A user sends 1 ETH with a call to deposit(). What happens?

creating a simple smart contract Hard
A. The 1 ETH is silently stored in the contract balance
B. The ETH is forwarded to the constructor again
C. The call succeeds but the ETH is burned
D. The transaction reverts because value was sent to a non-payable function

45 During truffle compile, the artifact JSON contains both bytecode and deployedBytecode. What is the key difference between them?

compiling and deploying smart contracts Hard
A. bytecode is the optimized version and deployedBytecode is the unoptimized one
B. bytecode includes constructor/creation code that runs once and returns deployedBytecode, which is what lives permanently at the contract address
C. deployedBytecode includes the ABI while bytecode does not
D. They are identical except for differing metadata hashes

46 A deployment fails with "exceeds block gas limit". Which action is most likely to resolve it without changing contract logic?

compiling and deploying smart contracts Hard
A. Enabling the optimizer and reducing deployment bytecode size, or splitting the contract via libraries/proxies
B. Lowering the Solidity version to 0.4.x
C. Increasing the gasPrice in the config
D. Adding more accounts to the Ganache mnemonic

47 In a migration script, deployer.deploy(A); deployer.deploy(B, A.address); sometimes fails with A.address undefined. What is the correct pattern?

compiling and deploying smart contracts Hard
A. Chain with .then() or use deployer.deploy(A).then(() => deployer.deploy(B, A.address)); so B deploys after A is mined
B. Pass A instead of A.address since Truffle resolves it lazily
C. Deploy B first because dependencies resolve in reverse order
D. Wrap both in a single 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?

compiling and deploying smart contracts Hard
A. An external call or block assumption (e.g., precompile, timestamp, or chainid) behaves differently on the live network
B. The testnet rejects contracts over 10 lines
C. The ABI is encoded in big-endian on testnets
D. Ganache uses a different Solidity compiler than the testnet

49 A developer runs truffle unbox <box>. What does unboxing an application template primarily provide beyond raw contract files?

using application templates Hard
A. A compiled binary of the EVM for local execution
B. A read-only snapshot of the Ethereum mainnet state
C. A preconfigured project scaffold including migrations, tests, front-end integration, and dependencies wired together
D. A private key with pre-funded mainnet Ether

50 When a Truffle Box ships with a truffle-box.json file, what is its main role during truffle unbox?

using application templates Hard
A. It contains the compiled ABI for every contract in the box
B. It defines post-unpack commands, ignored files, and hooks that configure the project after extraction
C. It overrides the global Solidity compiler version permanently
D. It stores the private keys used to sign migrations

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?

using application templates Hard
A. Change the React port to match the RPC port
B. Recompile with a lower optimizer runs value
C. Replace the mnemonic with a mainnet one
D. Ensure the build artifacts in 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?

overview of popular blockchain application templates Hard
A. Both require a global proof-of-work consensus to deploy
B. Both templates compile to EVM bytecode but differ only in UI frameworks
C. The Fabric template requires paying gas in Ether while Ethereum does not
D. 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

53 A template advertises "upgradeable contracts." Which architectural pattern is almost certainly in use?

overview of popular blockchain application templates Hard
A. A single immutable contract recompiled on each release
B. A proxy contract delegating via delegatecall to a logic contract whose address can be swapped
C. A fork of the chain for every version change
D. Hard-coded bytecode replacement at the same storage slot by miners

54 A token template implements ERC-20 but exposes a mint() callable by anyone. What is the primary security flaw?

overview of popular blockchain application templates Hard
A. The decimals value must be 0 for mintable tokens
B. ERC-20 forbids a mint function entirely
C. totalSupply cannot change after deployment under ERC-20
D. Missing access control allows unlimited supply inflation by any caller

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?

discussion on popular templates (e.g., Ethereum, Hyperledger) Hard
A. Both commit because Fabric uses optimistic last-write-wins without checks
B. The block is discarded entirely and both transactions re-execute
C. MVCC read-set validation causes one transaction to be invalidated due to a version conflict during the validation phase
D. Fabric locks the key with a mutex during endorsement, serializing them

56 An Ethereum template uses tx.origin for authorization. Why is this considered an edge-case vulnerability compared to msg.sender?

discussion on popular templates (e.g., Ethereum, Hyperledger) Hard
A. tx.origin costs more gas and reverts randomly
B. tx.origin returns the contract address, not the user
C. tx.origin is always zero on testnets
D. A malicious intermediate contract can trick a user into a call where 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?

discussion on popular templates (e.g., Ethereum, Hyperledger) Hard
A. Fabric peers run on different operating systems that lack random generators
B. Determinism is required solely to reduce gas costs
C. Chaincode must be deterministic across endorsing peers; non-deterministic values would produce differing read/write sets and fail endorsement validation
D. Random numbers are reserved for the ordering service only

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?

compiling and deploying smart contracts Hard
A. Only the first contract compiles and the second is skipped
B. Truffle downloads two compilers and merges the output
C. Both compile, since 0.8.19 satisfies both ranges
D. Compilation fails because only one pragma can exist per project

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?

overview of Truffle framework Hard
A. The console caches view results but discards transaction results
B. 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
C. view functions bypass the EVM entirely and run in JavaScript
D. State-changing functions always return 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?

creating a simple smart contract Hard
A. Dynamic arrays cannot be declared public in Solidity
B. Strings cannot be stored in arrays without bytes32 conversion
C. The array automatically caps at 256 elements
D. An unbounded loop can exceed the block gas limit as the array grows, making the function permanently uncallable (a DoS vector)