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
- 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 - Which programming language is primarily used with Foundry?
A) Python
B) Rust
C) Solidity ✅
D) JavaScript - What command initializes a new Foundry project?
A)forge init
✅
B)foundry start
C)forge new
D)foundry create
- Which command compiles smart contracts in Foundry?
A)forge compile
B)forge build
✅
C)foundry compile
D)forge make
- 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 - Which command is used to deploy contracts using Foundry?
A)forge deploy
B)forge create
✅
C)foundry deploy
D)forge push
- 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 - Which command starts a local Anvil node?
A)anvil start
B)forge anvil
C)anvil
✅
D)forge node
- 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 - 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
- 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 - What is the default testing framework used by Foundry?
A) Mocha
B) Chai
C) Built-in Solidity testing ✅
D) Jest - Which command formats the Solidity code in a Foundry project?
A)forge fmt
✅
B)forge format
C)foundry fmt
D)forge clean
- 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 - 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
- Which file contains the project configuration in Foundry?
A)foundry.toml
✅
B)config.json
C)settings.yaml
D)forge.config
- 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 - How does Foundry handle dependencies?
A) Manually
B) Usesforge install
to add them ✅
C) Throughnpm
D) Does not support dependencies - Which command updates all dependencies in a Foundry project?
A)forge update
✅
B)forge upgrade
C)foundry update
D)forge refresh
- 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
- Which command is used to interactively send transactions using
cast
?
A)cast interact
B)cast send
✅
C)cast transact
D)cast execute
- 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
- What is the purpose of the
forge script
command?
A) Run deployment scripts ✅
B) Compile contracts
C) Run tests
D) Format code - Which flag is used with
forge script
to broadcast transactions?
A)--send
B)--broadcast
✅
C)--deploy
D)--execute
- 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
- What is the purpose of the
cast abi-encode
command?
A) Decode ABI
B) Encode function call data ✅
C) Compile ABI
D) Deploy contract - Which command decodes transaction input data?
A)cast decode
B)cast abi-decode
✅
C)cast parse
D)cast input-decode
- 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
- Which command retrieves the balance of an address?
A)cast balance
✅
B)cast get balance
C)cast address balance
D)cast fetch balance
- 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
- 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 - Which cheat code sets the next call’s msg.sender?
A) vm.setSender
B) vm.prank ✅
C) vm.mock
D) vm.msgSender - 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 - Which cheat code changes the current block number?
A) vm.roll(uint256) ✅
B) vm.step(uint256)
C) vm.block(uint256)
D) vm.setBlockNumber(uint256) - 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 - How do you label addresses in traces for better readability?
A) vm.rename()
B) vm.label(address, string) ✅
C) vm.debugLabel()
D) vm.alias() - Which Foundry command can show gas reports for all functions?
A) forge gas
B) forge test –gas-report ✅
C) forge estimate
D) forge analyze - How do you run tests with verbose output?
A) forge test -v ✅
B) forge test –print
C) forge verbose
D) forge run -v - 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 - 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
- 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 - What must you override in a deployment script?
A) run() ✅
B) test()
C) execute()
D) deploy() - Which modifier is used to broadcast transactions in scripts?
A) sendable
B) broadcast ✅
C) deployable
D) payable - How do you pass arguments to scripts?
A) forge script –args
B) forge script –sig “” –args ✅
C) forge test –params
D) cast send –params - What format is used for storing and managing private keys securely?
A) .env
B) keystore JSON ✅
C) .txt file
D) ABI file - 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 ✅ - 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 - How do you specify the network for script execution?
A) –network ✅
B) –chain
C) –chain-id
D) –target-network - Which key is required for Etherscan verification?
A) INFURA_KEY
B) ETHERSCAN_API_KEY ✅
C) WEB3_PROVIDER
D) PRIVATE_KEY - Where can you define multiple RPC endpoints?
A) ~/.rpc.toml
B) foundry.toml ✅
C) .rpc.config
D) network.json
Section 6: Cast Deep-Dive
- What does cast call require?
A) ABI, Address, Method ✅
B) Private key
C) Block number
D) Chain ID - 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 - Which cast command shows block details?
A) cast block ✅
B) cast chain
C) cast tx
D) cast fetch - What does cast abi-decode do?
A) Decode return values ✅
B) Encode calldata
C) Format ABI
D) Send transaction - Which flag helps simulate without sending in cast?
A) –simulate
B) –dry-run ✅
C) –preview
D) –test - Which cast command shows current gas price?
A) cast gas
B) cast gas-price ✅
C) cast fetch-gas
D) cast fee - What is the command to sign a message?
A) cast sign-message ✅
B) cast hash
C) cast sign
D) cast encrypt - Which command shows current chain ID?
A) cast chain-id ✅
B) cast id
C) cast network
D) cast current-chain - Which cast command fetches a contract’s storage value?
A) cast storage
B) cast read-storage
C) cast storage-at ✅
D) cast state - 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
- 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 - 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 - Which cheat code gets the current block’s base fee?
A) block.basefee
B) vm.basefee()
C) block.basefee ✅
D) tx.basefee - 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 ✅ - How do you stop a prank after using vm.startPrank()?
A) vm.resetPrank() ✅
B) vm.stop()
C) vm.endPrank()
D) prank.stop() - 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 - What tool is used to deploy Foundry smart contracts from scripts?
A) forge run
B) forge execute
C) forge script ✅
D) forge deploy - Which file is used to store environment secrets for Foundry?
A) secrets.toml
B) foundry.toml
C) .env ✅
D) keys.txt - 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 - 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
- What is fuzz testing?
A) Testing with max gas
B) Randomized input testing ✅
C) Testing one function
D) Code obfuscation - How does Foundry identify fuzz tests?
A) testFuzz_ prefix ✅
B) testRandom_
C) randomTest_
D) fuzzTest_ - 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 ✅ - What is the function of invariant testing?
A) Create mock contracts
B) Ensure state always stays valid ✅
C) Replace deployment
D) Prevent memory leaks - Which testing framework does invariant testing in Foundry use?
A) Hardhat
B) Echidna
C) Forge StdInvariant ✅
D) Slither - 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 - Which Foundry tool is suitable for invariant fuzzing?
A) forge test
B) forge invariant ✅
C) forge simulate
D) cast invariant - How do you limit fuzzing to certain input ranges?
A) if() statements
B) require()
C) vm.assume() ✅
D) vm.limit() - 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 - What does the invariant function prefix require?
A) test_
B) inv_
C) invariant_ ✅
D) forge_
Section 9: Ecosystem Integration & Misc
- What is the Foundryup tool used for?
A) Managing accounts
B) Auto-updating Foundry CLI ✅
C) Launching testnet
D) Connecting wallets - What does the forge build command generate?
A) JavaScript bundles
B) Compiled artifacts and ABI ✅
C) Transaction logs
D) Chain snapshots - What does foundry.toml contain?
A) Network configs and private keys
B) Test assertions
C) Project configuration ✅
D) Solidity function docs - How can you upgrade Foundry manually?
A) forge upgrade
B) foundryup ✅
C) foundry-cli update
D) forge patch - What tool helps find security issues in Foundry contracts?
A) Hardhat Verify
B) MythX
C) Slither ✅
D) Etherscan Guard - What does the Foundry profile system allow?
A) Custom RPC config
B) Create isolated build configs ✅
C) Sign transactions
D) Store multiple .env files - 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 - What language is used for Forge deployment scripts?
A) Vyper
B) Rust
C) Solidity ✅
D) JavaScript - What is the default output directory for build artifacts?
A) /artifacts
B) out/ ✅
C) dist/
D) target/ - 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.