Challenge - 5 Problems
Fork Testing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this Hardhat fork setup code?
Consider this Hardhat config snippet for mainnet forking. What will be the output when running a script that fetches the balance of an address on the forked network?
Blockchain / Solidity
import { ethers } from "hardhat"; async function main() { const provider = ethers.provider; const balance = await provider.getBalance("0x742d35Cc6634C0532925a3b844Bc454e4438f44e"); console.log(ethers.formatEther(balance)); } main();
Attempts:
2 left
💡 Hint
Remember that mainnet fork replicates the state at a specific block.
✗ Incorrect
The Hardhat provider connected to a mainnet fork allows reading the state as it was on mainnet at the fork block. So the balance reflects the real mainnet balance at that block.
🧠 Conceptual
intermediate1:30remaining
Which statement best describes mainnet fork testing?
Choose the correct description of mainnet fork testing in blockchain development.
Attempts:
2 left
💡 Hint
Think about how developers test with real mainnet data safely.
✗ Incorrect
Mainnet fork testing creates a local environment that mirrors mainnet state at a block, allowing safe testing with real data without affecting the live network.
🔧 Debug
advanced2:00remaining
Why does this fork test script fail with 'invalid JSON RPC response'?
Given this Hardhat fork config and script, why does the script fail with 'invalid JSON RPC response' error?
Config snippet:
{
forking: {
url: "https://mainnet.infura.io/v3/INVALID_KEY",
blockNumber: 15000000
}
}
Script tries to get block number from provider.
Blockchain / Solidity
const blockNumber = await ethers.provider.getBlockNumber();
console.log(blockNumber);Attempts:
2 left
💡 Hint
Check the RPC URL and credentials.
✗ Incorrect
An invalid API key in the RPC URL causes the provider to fail connecting, resulting in an invalid JSON RPC response error.
📝 Syntax
advanced1:30remaining
Which option correctly sets up a mainnet fork in Hardhat config?
Select the correct Hardhat config snippet to enable mainnet forking at block 16000000 using Alchemy RPC.
Attempts:
2 left
💡 Hint
Check property names and syntax carefully.
✗ Incorrect
The correct Hardhat config uses 'forking' with 'url' and 'blockNumber' keys. Option A matches the correct syntax and types.
🚀 Application
expert2:30remaining
How many transactions are recorded after this fork test script runs?
You run a script on a mainnet fork that sends 3 transactions:
1. Transfer 1 ETH from account A to B
2. Deploy a contract
3. Call a function that reverts intentionally
After the script finishes, how many transactions remain on the forked chain?
Attempts:
2 left
💡 Hint
Think about how reverted transactions affect blockchain state.
✗ Incorrect
In a forked environment like Hardhat Network, all transactions—including those that revert—are mined into blocks on the local forked chain. Reverted transactions do not change the state but are still recorded.