Skip to content
Tech Interview Prep
Technical interview guide

Smart Contract Development (Solidity & EVM)

Writing and deploying self-executing contract code on the Ethereum Virtual Machine: state, gas, and the constraints of on-chain execution.

Minutes to read
3
Practice MCQs
25
Interview Q&A
25
Edition
v4
Editorial status
Reviewed

Scope: Solidity latest documentation (0.8.36/0.8.37 development line reviewed 2026-09-04); Ethereum EVM documentation updated 2026-07-26; target-chain fork rules must be verified at deployment; ERC-1967, EIP-170, and EIP-1153.

Overview

Curated: · Written: · Reviewed:

Smart Contract Development (Solidity & EVM)

In one line

A Solidity contract is bytecode that every node re-executes, so it fits shared state that several parties must trust without an operator. Design for who can call it, what each operation costs in gas, and what happens after deployment, since upgrades and reversals are not free.

Key definitions

  • Storage: persistent 32-byte slots in global state; survives across transactions.
  • Calldata: immutable transaction input, cheapest to read, no copy needed.
  • Function selector: first four bytes of the Keccak-256 hash of the canonical signature.
  • msg.sender vs tx.origin: the immediate caller vs the EOA that signed the transaction.
  • Reentrancy: a callee calls back into the caller before the caller's state update has run.
  • Delegatecall: runs callee code against the caller's storage, balance and context.

Formulas and complexity

SSTORE0→≠0=20,000SSTORE≠0→≠0=2,900\text{SSTORE}_{0\to\neq0} = 20{,}000 \qquad \text{SSTORE}_{\neq0\to\neq0} = 2{,}900 SLOADwarm=100SLOADcold=2,100TLOAD=TSTORE=100\text{SLOAD}_{\text{warm}} = 100 \qquad \text{SLOAD}_{\text{cold}} = 2{,}100 \qquad \text{TLOAD} = \text{TSTORE} = 100 refundmax⁡=4,800 per transaction (EIP-3529)\text{refund}_{\max} = 4{,}800 \text{ per transaction (EIP-3529)} CREATE address=keccak256(rlp(sender,nonce))[12:]\text{CREATE address} = \text{keccak256}(\text{rlp}(\text{sender}, \text{nonce}))[12:] CREATE2 address=keccak256(0xff  ∥  deployer  ∥  salt  ∥  keccak256(initcode))[12:]\text{CREATE2 address} = \text{keccak256}(0\text{xff} \;\|\; \text{deployer} \;\|\; \text{salt} \;\|\; \text{keccak256}(\text{initcode}))[12:] 3,000×15,000=45,000,000>30,000,000 (block gas limit)3{,}000 \times 15{,}000 = 45{,}000{,}000 > 30{,}000{,}000 \text{ (block gas limit)}

How it works

  1. A transaction carries to and calldata. The dispatcher matches the first four bytes to a function, decodes the arguments and runs the body.
  2. Persistent state lives in storage. Memory and stack are discarded when the call returns.
  3. Every external call hands control to other code, which can reenter before your function finishes.
  4. A revert undoes state and events in that call context, but the transaction still pays for the gas consumed.
  5. Deployment runs init code once. The constructor returns the runtime bytecode, which is what gets stored at the new address.
Tx: to + calldata Dispatcher matches selector Decode args from calldata Checks Effects: SSTORE Interaction: external call Return data or revert

When to use and when not to

SituationUse a contractRedesign or avoid
Shared state several parties must trust without an operatorYesKeep it off-chain if no one needs to verify it
External data needed during executionOnly through an oracle with explicit trustThe EVM cannot fetch HTTP during execution, because every node must reach the same result
Payouts to a list that growsNo as a single loopPull claims, paginated
Logic expected to changeUpgradeable proxy, accepting the storage and governance riskImmutable contract if the rules are fixed
Secrets needed inside logicNo: storage is readable by any nodeKeep secrets off-chain, commit only hashes

Traps interviewers probe

  1. Effects after the external call. Attackers reenter and pass the stale balance check. Fix: checks, then effects, then interactions. Add a reentrancy guard where shared state spans several functions.
  2. Push payments in a loop. A growing list exceeds the block gas limit, and an attacker can inflate it. Fix: each recipient claims its own balance (pull payments), with pagination where batching is needed.
  3. tx.origin for authorization. A phishing intermediary keeps the victim as origin. Fix: check msg.sender against roles or ownership.
  4. Treating private as secret. Any node can read the slot with eth_getStorageAt. Fix: keep secrets off-chain and commit to hashes only.
  5. Inserting a variable mid-layout in an upgrade. Later slots shift and live state is misread. Fix: append only, diff storage layouts between versions, and reserve gaps.

Interview tips

Opening: 'Every node re-executes the transaction, so I design for who calls, what each step costs, and what the code can never change after deployment.'

Expect these follow-ups: read-only reentrancy after basic reentrancy; why transfer and send with their 2300 gas stipend are no longer recommended; timelocks after access control; storage gaps and namespaced storage after proxies; why a receipt's status and events matter more than the transaction hash.

30-second outline:

  • Mechanism: selector, dispatch, state in storage.
  • Risk: external call before effects allows reentry; fix the ordering, then guard if shared state needs it.
  • Cost: user-growing loops hit the gas limit; use pull claims.
  • Upgrades: append-only layout, role-gated upgrade, timelock for users to exit.
  • Verification: check receipt status and expected events before reporting success.

Feedback on this overview

Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.