Foundry  – Multiple Choice Quiz (90 Questions)

Foundry – Multiple Choice Quiz (90 Questions)

Hey! I put together a quick multiple-choice quiz to test your knowledge of Foundry, that awesome toolkit for building Ethereum smart contracts. It covers key features, commands, and some best practices. Ready to give it a shot? Let’s go!


Section 1: Foundry Basics MCQ

  1. What is Foundry in the context of blockchain development?
    A) A decentralized storage solution
    B) A toolkit for Ethereum smart contract development ✅
    C) A consensus algorithm
    D) A cryptocurrency exchange
  2. Which programming language is primarily used with Foundry?
    A) Python
    B) Rust
    C) Solidity ✅
    D) JavaScript
  3. What command initializes a new Foundry project?
    A) forge init
    B) foundry start
    C) forge new
    D) foundry create
  4. Which command compiles smart contracts in Foundry?
    A) forge compile
    B) forge build
    C) foundry compile
    D) forge make
  5. What is the purpose of the forge test command?
    A) Deploy contracts to the mainnet
    B) Run unit tests on smart contracts ✅
    C) Generate documentation
    D) Initialize a new project
  6. Which command is used to deploy contracts using Foundry?
    A) forge deploy
    B) forge create
    C) foundry deploy
    D) forge push
  7. What is Anvil in the Foundry ecosystem?
    A) A testing framework
    B) A local Ethereum node for testing ✅
    C) A deployment tool
    D) A smart contract linter
  8. Which command starts a local Anvil node?
    A) anvil start
    B) forge anvil
    C) anvil
    D) forge node
  9. What is the purpose of the cast tool in Foundry?
    A) Compile smart contracts
    B) Interact with deployed contracts via CLI ✅
    C) Deploy contracts to testnets
    D) Run tests
  10. Which command sends a transaction to a contract using cast?
    A) cast send
    B) cast call
    C) cast deploy
    D) cast execute

Section 2: Advanced foundry Concepts MCQ

  1. How does Foundry handle environment variables securely?
    A) Stores them in plaintext
    B) Uses .env files with caution
    C) Recommends using encrypted keystores ✅
    D) Does not support environment variables
  2. What is the default testing framework used by Foundry?
    A) Mocha
    B) Chai
    C) Built-in Solidity testing ✅
    D) Jest
  3. Which command formats the Solidity code in a Foundry project?
    A) forge fmt
    B) forge format
    C) foundry fmt
    D) forge clean
  4. What is the purpose of the forge clean command?
    A) Deletes the entire project
    B) Removes build artifacts ✅
    C) Formats the code
    D) Runs tests
  5. How can you run a specific test function using Foundry?
    A) forge test --match testFunctionName
    B) forge test -f testFunctionName
    C) forge run testFunctionName
    D) forge execute testFunctionName
  6. Which file contains the project configuration in Foundry?
    A) foundry.toml
    B) config.json
    C) settings.yaml
    D) forge.config
  7. What is the purpose of the forge coverage command?
    A) Deploy contracts
    B) Check code coverage of tests ✅
    C) Format code
    D) Initialize a new project
  8. How does Foundry handle dependencies?
    A) Manually
    B) Uses forge install to add them ✅
    C) Through npm
    D) Does not support dependencies
  9. Which command updates all dependencies in a Foundry project?
    A) forge update
    B) forge upgrade
    C) foundry update
    D) forge refresh
  10. What is the purpose of the forge verify-contract command?
    A) Verifies contract logic
    B) Verifies contract on Etherscan ✅
    C) Runs security analysis
    D) Deploys contract to testnet

Section 3: Foundry Practical Applications MCQ

  1. Which command is used to interactively send transactions using cast?
    A) cast interact
    B) cast send
    C) cast transact
    D) cast execute
  2. How can you call a view function of a deployed contract using cast?
    A) cast call
    B) cast view
    C) cast execute
    D) cast read
  3. What is the purpose of the forge script command?
    A) Run deployment scripts ✅
    B) Compile contracts
    C) Run tests
    D) Format code
  4. Which flag is used with forge script to broadcast transactions?
    A) --send
    B) --broadcast
    C) --deploy
    D) --execute
  5. How can you generate a new wallet using cast?
    A) cast wallet new
    B) cast generate wallet
    C) cast create wallet
    D) cast wallet create
  6. What is the purpose of the cast abi-encode command?
    A) Decode ABI
    B) Encode function call data ✅
    C) Compile ABI
    D) Deploy contract
  7. Which command decodes transaction input data?
    A) cast decode
    B) cast abi-decode
    C) cast parse
    D) cast input-decode
  8. How can you fetch the current block number using cast?
    A) cast block-number
    B) cast get block
    C) cast current-block
    D) cast block
  9. Which command retrieves the balance of an address?
    A) cast balance
    B) cast get balance
    C) cast address balance
    D) cast fetch balance
  10. What is the purpose of the cast tx command?
    A) Send a transaction
    B) View transaction details ✅
    C) Deploy a contract
    D) Compile a transaction

Section 4: Foundry Testing and Debugging MCQ

  1. What is the purpose of cheat codes in Foundry tests?
    A) Bypass Solidity type checks
    B) Add fake wallet addresses
    C) Manipulate the EVM for advanced testing ✅
    D) Encrypt contract output
  2. Which cheat code sets the next call’s msg.sender?
    A) vm.setSender
    B) vm.prank ✅
    C) vm.mock
    D) vm.msgSender
  3. What does the cheat code vm.warp(uint256) do?
    A) Sends a transaction
    B) Skips contract deployment
    C) Sets block.timestamp ✅
    D) Increases gas limit
  4. Which cheat code changes the current block number?
    A) vm.roll(uint256) ✅
    B) vm.step(uint256)
    C) vm.block(uint256)
    D) vm.setBlockNumber(uint256)
  5. What does the cheat code vm.expectRevert() do?
    A) Compiles contracts
    B) Expects a test to fail with revert ✅
    C) Deploys a contract
    D) Changes ownership
  6. How do you label addresses in traces for better readability?
    A) vm.rename()
    B) vm.label(address, string) ✅
    C) vm.debugLabel()
    D) vm.alias()
  7. Which Foundry command can show gas reports for all functions?
    A) forge gas
    B) forge test –gas-report ✅
    C) forge estimate
    D) forge analyze
  8. How do you run tests with verbose output?
    A) forge test -v ✅
    B) forge test –print
    C) forge verbose
    D) forge run -v
  9. What is the use of forge snapshot?
    A) Snapshot EVM state
    B) Generate test case summaries
    C) Compare gas usage over time ✅
    D) Print ABI
  10. How can you deploy contracts using scripts in a dry-run mode?
    A) forge script –simulate ✅
    B) forge script –debug
    C) forge deploy –dry
    D) forge script –mock

Section 5: Deployment and Scripts

  1. How do you write Solidity deployment scripts for Foundry?
    A) Use JavaScript
    B) Use .sh scripts
    C) Use Solidity and inherit from Script ✅
    D) Use YAML format
  2. What must you override in a deployment script?
    A) run() ✅
    B) test()
    C) execute()
    D) deploy()
  3. Which modifier is used to broadcast transactions in scripts?
    A) sendable
    B) broadcast ✅
    C) deployable
    D) payable
  4. How do you pass arguments to scripts?
    A) forge script –args
    B) forge script –sig “” –args ✅
    C) forge test –params
    D) cast send –params
  5. What format is used for storing and managing private keys securely?
    A) .env
    B) keystore JSON ✅
    C) .txt file
    D) ABI file
  6. How do you load environment variables in Foundry?
    A) export in CLI
    B) Set inside foundry.toml
    C) Use dotenv crate
    D) Add to .env file ✅
  7. What does the forge verify-contract command do?
    A) Generates unit tests
    B) Publishes contract to mainnet
    C) Verifies on Etherscan ✅
    D) Deploys on all chains
  8. How do you specify the network for script execution?
    A) –network ✅
    B) –chain
    C) –chain-id
    D) –target-network
  9. Which key is required for Etherscan verification?
    A) INFURA_KEY
    B) ETHERSCAN_API_KEY ✅
    C) WEB3_PROVIDER
    D) PRIVATE_KEY
  10. Where can you define multiple RPC endpoints?
    A) ~/.rpc.toml
    B) foundry.toml ✅
    C) .rpc.config
    D) network.json

Section 6: Cast Deep-Dive

  1. What does cast call require?
    A) ABI, Address, Method ✅
    B) Private key
    C) Block number
    D) Chain ID
  2. How do you estimate gas for a transaction using cast?
    A) cast gas-estimate
    B) cast estimate
    C) cast estimate-call ✅
    D) cast compute-gas
  3. Which cast command shows block details?
    A) cast block ✅
    B) cast chain
    C) cast tx
    D) cast fetch
  4. What does cast abi-decode do?
    A) Decode return values ✅
    B) Encode calldata
    C) Format ABI
    D) Send transaction
  5. Which flag helps simulate without sending in cast?
    A) –simulate
    B) –dry-run ✅
    C) –preview
    D) –test
  6. Which cast command shows current gas price?
    A) cast gas
    B) cast gas-price ✅
    C) cast fetch-gas
    D) cast fee
  7. What is the command to sign a message?
    A) cast sign-message ✅
    B) cast hash
    C) cast sign
    D) cast encrypt
  8. Which command shows current chain ID?
    A) cast chain-id ✅
    B) cast id
    C) cast network
    D) cast current-chain
  9. Which cast command fetches a contract’s storage value?
    A) cast storage
    B) cast read-storage
    C) cast storage-at ✅
    D) cast state
  10. What is the command to hash a value using keccak256?
    A) cast keccak ✅
    B) cast hash
    C) cast encode
    D) cast solidity-hash

Section 7: Advanced Topics

  1. Which of the following correctly uses vm.expectEmit() in Foundry?
    A) To expect an event to revert
    B) To verify that an event is emitted ✅
    C) To deploy a new contract
    D) To simulate an internal call
  2. What does vm.record() enable in testing?
    A) Logging storage slots
    B) Recording storage reads and writes ✅
    C) Simulating RPC latency
    D) Creating mocks for interfaces
  3. Which cheat code gets the current block’s base fee?
    A) block.basefee
    B) vm.basefee()
    C) block.basefee ✅
    D) tx.basefee
  4. How do you spoof msg.sender and msg.value for the next call?
    A) vm.setCaller
    B) vm.prank
    C) vm.deal
    D) vm.startPrank ✅
  5. How do you stop a prank after using vm.startPrank()?
    A) vm.resetPrank() ✅
    B) vm.stop()
    C) vm.endPrank()
    D) prank.stop()
  6. What is the main advantage of using forge bind?
    A) It binds contracts to network
    B) Generates type-safe contract bindings in Rust ✅
    C) Encodes ABI
    D) Compiles external crates
  7. What tool is used to deploy Foundry smart contracts from scripts?
    A) forge run
    B) forge execute
    C) forge script ✅
    D) forge deploy
  8. Which file is used to store environment secrets for Foundry?
    A) secrets.toml
    B) foundry.toml
    C) .env ✅
    D) keys.txt
  9. How can you make a call with cast using raw calldata?
    A) cast encode-call
    B) cast abi
    C) cast send –data ✅
    D) cast run
  10. What is the benefit of forge snapshot?
    A) Store blockchain snapshots
    B) Run time-machine tests
    C) Track gas usage changes over time ✅
    D) Speed up script execution

Section 8: Fuzzing and Invariants

  1. What is fuzz testing?
    A) Testing with max gas
    B) Randomized input testing ✅
    C) Testing one function
    D) Code obfuscation
  2. How does Foundry identify fuzz tests?
    A) testFuzz_ prefix ✅
    B) testRandom_
    C) randomTest_
    D) fuzzTest_
  3. Which attribute increases the number of fuzz test runs?
    A) #fuzz(count=100)
    B) #forge-test(count=100)
    C) #forge-configured-runs
    D) –fuzz-runs 100 ✅
  4. What is the function of invariant testing?
    A) Create mock contracts
    B) Ensure state always stays valid ✅
    C) Replace deployment
    D) Prevent memory leaks
  5. Which testing framework does invariant testing in Foundry use?
    A) Hardhat
    B) Echidna
    C) Forge StdInvariant ✅
    D) Slither
  6. What’s the role of vm.assume() in fuzzing?
    A) Skip deployment
    B) Reject inputs not meeting conditions ✅
    C) Debug stack
    D) Compare storage values
  7. Which Foundry tool is suitable for invariant fuzzing?
    A) forge test
    B) forge invariant ✅
    C) forge simulate
    D) cast invariant
  8. How do you limit fuzzing to certain input ranges?
    A) if() statements
    B) require()
    C) vm.assume() ✅
    D) vm.limit()
  9. In invariant testing, what does targetContract() do?
    A) Deploys a new contract
    B) Selects which contract to fuzz ✅
    C) Creates a boundary
    D) Defines events to emit
  10. What does the invariant function prefix require?
    A) test_
    B) inv_
    C) invariant_ ✅
    D) forge_

Section 9: Ecosystem Integration & Misc

  1. What is the Foundryup tool used for?
    A) Managing accounts
    B) Auto-updating Foundry CLI ✅
    C) Launching testnet
    D) Connecting wallets
  2. What does the forge build command generate?
    A) JavaScript bundles
    B) Compiled artifacts and ABI ✅
    C) Transaction logs
    D) Chain snapshots
  3. What does foundry.toml contain?
    A) Network configs and private keys
    B) Test assertions
    C) Project configuration ✅
    D) Solidity function docs
  4. How can you upgrade Foundry manually?
    A) forge upgrade
    B) foundryup ✅
    C) foundry-cli update
    D) forge patch
  5. What tool helps find security issues in Foundry contracts?
    A) Hardhat Verify
    B) MythX
    C) Slither ✅
    D) Etherscan Guard
  6. What does the Foundry profile system allow?
    A) Custom RPC config
    B) Create isolated build configs ✅
    C) Sign transactions
    D) Store multiple .env files
  7. How do you use a specific profile with forge?
    A) forge –profile prod ✅
    B) forge –env prod
    C) forge –config profile
    D) forge prod.toml
  8. What language is used for Forge deployment scripts?
    A) Vyper
    B) Rust
    C) Solidity ✅
    D) JavaScript
  9. What is the default output directory for build artifacts?
    A) /artifacts
    B) out/ ✅
    C) dist/
    D) target/
  10. What command resets the cache and rebuilds everything?
    A) forge reset
    B) forge clean && forge build ✅
    C) forge build –force
    D) forge purge

✅ indicates the correct answer.

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply

    Your email address will not be published. Required fields are marked *