0
0
Blockchain / Solidityprogramming~20 mins

Ethereum Virtual Machine (EVM) in Blockchain / Solidity - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
EVM Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
1:30remaining
EVM Stack Behavior on PUSH and ADD
What is the final value on top of the EVM stack after executing these instructions?

PUSH1 0x03
PUSH1 0x05
ADD
Blockchain / Solidity
PUSH1 0x03
PUSH1 0x05
ADD
A0x08
B0x15
C0x02
D0x53
Attempts:
2 left
💡 Hint
Remember that ADD pops two values and pushes their sum.
🧠 Conceptual
intermediate
1:30remaining
Gas Cost for SSTORE Operation
Which of the following best describes the gas cost behavior of the SSTORE operation in the EVM?
ASSTORE always costs a fixed 20,000 gas regardless of the storage state.
BSSTORE costs more gas when changing a storage slot from zero to non-zero than from non-zero to zero.
CSSTORE costs less gas when changing a storage slot from zero to non-zero than from non-zero to zero.
DSSTORE gas cost is always refunded fully after execution.
Attempts:
2 left
💡 Hint
Think about how storage writes affect blockchain state and refunds.
🔧 Debug
advanced
1:30remaining
Identify the Error in EVM Bytecode Sequence
Given this EVM bytecode sequence, what error will occur during execution?

PUSH1 0x01
ADD
Blockchain / Solidity
PUSH1 0x01
ADD
ANo error, outputs 0x01
BOut of gas error
CInvalid opcode error
DStack underflow error
Attempts:
2 left
💡 Hint
ADD requires two values on the stack to operate.
📝 Syntax
advanced
1:30remaining
Correct EVM Assembly for Conditional Jump
Which EVM assembly code correctly performs a conditional jump to label 'loop' if the top stack value is non-zero?
A
PUSH1 loop
JUMPI
B
JUMPI
PUSH1 loop
C
PUSH1 loop
JUMP
D
PUSH1 0x00
JUMPI
Attempts:
2 left
💡 Hint
JUMPI expects the destination and condition on the stack.
🚀 Application
expert
2:00remaining
Calculate Final Gas After Execution
A contract execution starts with 100,000 gas. It performs:
- 3 SSTORE operations changing zero to non-zero
- 2 SSTORE operations changing non-zero to zero
- 10 ADD operations

Given:
- SSTORE zero->non-zero costs 20,000 gas each
- SSTORE non-zero->zero costs 5,000 gas each and refunds 15,000 gas each
- ADD costs 3 gas each

What is the final gas left after execution (ignoring other costs and refunds)?
A50,000 gas
B40,000 gas
C55,000 gas
D35,000 gas
Attempts:
2 left
💡 Hint
Calculate total cost, then subtract refunds from gas used.