Bird
Raised Fist0
Blockchain / Solidityprogramming~20 mins

Contract verification on Etherscan in Blockchain / Solidity - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
Etherscan Verification Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this Solidity contract verification status check?
Given the following Solidity code snippet that queries Etherscan API for contract verification status, what will be the output if the contract is verified?
Blockchain / Solidity
pragma solidity ^0.8.0;

// This is a pseudo-code example to illustrate the concept
// Assume getVerificationStatus() calls Etherscan API and returns a string
contract VerifyStatusChecker {
    function getVerificationStatus() public pure returns (string memory) {
        // Simulated response
        return "Verified";
    }
}
ACompilation Error
B"Pending"
C"Not Verified"
D"Verified"
Attempts:
2 left
💡 Hint
Think about what the function returns as a simulated response.
🧠 Conceptual
intermediate
1:30remaining
Which step is NOT required for contract verification on Etherscan?
When verifying a smart contract on Etherscan, which of the following steps is NOT required?
ASubmitting the contract's ABI manually
BProviding the compiler version used
CUploading the contract source code
DSelecting the correct optimization settings
Attempts:
2 left
💡 Hint
Think about what Etherscan generates automatically after verification.
🔧 Debug
advanced
2:30remaining
Why does this contract verification fail on Etherscan?
A developer tries to verify their contract but Etherscan returns a verification failed error. The contract uses Solidity 0.8.12 with optimization enabled. The developer submits the source code but forgets to select optimization in the verification form. What is the likely cause of failure?
AMismatch in optimization settings between compiled contract and verification form
BIncorrect Solidity version selected
CSource code has syntax errors
DContract address is incorrect
Attempts:
2 left
💡 Hint
Think about what happens if optimization settings differ between compilation and verification.
📝 Syntax
advanced
1:30remaining
Which Solidity pragma version is compatible with Etherscan verification for a contract compiled with 0.8.12?
You want to verify a contract compiled with Solidity 0.8.12 on Etherscan. Which pragma directive is correct to ensure compatibility?
Apragma solidity 0.8.11;
Bpragma solidity ^0.8.12;
Cpragma solidity >=0.8.0 <0.9.0;
Dpragma solidity ^0.7.0;
Attempts:
2 left
💡 Hint
Consider the range of versions allowed by the pragma and the exact compiler version used.
🚀 Application
expert
2:00remaining
How many constructor arguments must be ABI-encoded and submitted during Etherscan verification for this contract?
Consider this Solidity contract: contract Token { string public name; uint256 public supply; constructor(string memory _name, uint256 _supply) { name = _name; supply = _supply; } } When verifying this contract on Etherscan, how many constructor arguments must be ABI-encoded and submitted?
A1
B2
C0
D3
Attempts:
2 left
💡 Hint
Count the parameters in the constructor function.

Practice

(1/5)
1. What is the main purpose of verifying a smart contract on Etherscan?
easy
A. To make the contract source code public and trusted
B. To increase the gas cost of contract deployment
C. To hide the contract's source code from users
D. To automatically upgrade the contract's functionality

Solution

  1. Step 1: Understand contract verification purpose

    Verification publishes the source code so users can see and trust it.
  2. Step 2: Eliminate incorrect options

    Increasing gas cost, hiding code, or auto-upgrading are not related to verification.
  3. Final Answer:

    To make the contract source code public and trusted -> Option A
  4. Quick Check:

    Verification = public and trusted code [OK]
Hint: Verification means sharing source code publicly [OK]
Common Mistakes:
  • Thinking verification hides code
  • Confusing verification with contract upgrades
  • Assuming verification increases deployment cost
2. Which of the following is the correct step to verify a contract on Etherscan?
easy
A. Deploy the contract twice on the blockchain
B. Send ETH to Etherscan wallet to activate verification
C. Upload the source code and match compiler version exactly
D. Encrypt the source code before uploading

Solution

  1. Step 1: Identify verification process

    Verification requires uploading source code and matching compiler settings exactly.
  2. Step 2: Remove incorrect options

    Sending ETH, deploying twice, or encrypting code are not part of verification.
  3. Final Answer:

    Upload the source code and match compiler version exactly -> Option C
  4. Quick Check:

    Upload code + match compiler = verification [OK]
Hint: Match compiler version exactly when uploading code [OK]
Common Mistakes:
  • Ignoring compiler version mismatch
  • Thinking payment is needed for verification
  • Trying to encrypt source code before upload
3. Given the following Solidity contract and verification attempt, what will happen if the compiler version used during verification does not match the deployed contract's compiler version?
pragma solidity ^0.8.0;
contract Simple { uint public x; constructor() { x = 10; } }
medium
A. Verification will fail due to compiler version mismatch
B. Verification will succeed and show the source code
C. Contract will be redeployed automatically
D. Verification will succeed but source code will be hidden

Solution

  1. Step 1: Understand compiler version role in verification

    Etherscan requires exact compiler version match to verify source code.
  2. Step 2: Analyze mismatch effect

    If versions differ, verification fails because bytecode won't match source code.
  3. Final Answer:

    Verification will fail due to compiler version mismatch -> Option A
  4. Quick Check:

    Compiler mismatch = verification fail [OK]
Hint: Compiler version mismatch causes verification failure [OK]
Common Mistakes:
  • Assuming verification ignores compiler version
  • Thinking contract redeploys automatically
  • Believing source code hides after verification
4. You tried verifying your contract on Etherscan but got an error saying "Bytecode does not match source code." What is the most likely cause?
medium
A. Your contract has no constructor
B. You used a different compiler version than the one used to deploy
C. You uploaded the wrong contract address
D. You forgot to pay the verification fee

Solution

  1. Step 1: Understand bytecode mismatch meaning

    Bytecode mismatch means the compiled source code does not match deployed bytecode.
  2. Step 2: Identify common cause

    Using a different compiler version or settings causes bytecode mismatch errors.
  3. Final Answer:

    You used a different compiler version than the one used to deploy -> Option B
  4. Quick Check:

    Bytecode mismatch = compiler version difference [OK]
Hint: Check compiler version if bytecode mismatch error occurs [OK]
Common Mistakes:
  • Thinking payment is required for verification
  • Confusing contract address with bytecode mismatch
  • Assuming constructor presence affects verification
5. You have a contract deployed with optimization enabled during compilation. When verifying on Etherscan, which of the following must you do to successfully verify the contract?
hard
A. Verify using a different contract address
B. Disable optimization and upload source code with any compiler version
C. Only upload the ABI without source code
D. Upload source code with optimization enabled and match compiler version

Solution

  1. Step 1: Understand optimization effect on bytecode

    Optimization changes compiled bytecode, so verification must match optimization settings.
  2. Step 2: Match compiler version and optimization settings

    To verify, upload source code with exact compiler version and optimization enabled as deployed.
  3. Final Answer:

    Upload source code with optimization enabled and match compiler version -> Option D
  4. Quick Check:

    Match optimization + compiler version = successful verification [OK]
Hint: Match optimization settings and compiler version exactly [OK]
Common Mistakes:
  • Ignoring optimization settings during verification
  • Uploading only ABI without source code
  • Trying to verify with wrong contract address