Eridian
eridian.xyzx.comGitHub
  • πŸ“–Eridian Docs
  • Ethereum Dev
    • ✏️Ethereum Notes
      • πŸŽ›οΈTechnical Basics
      • πŸͺ§Ethereum Addresses
      • πŸ“šEthereum State Explained
      • β›½Gas Fees Explained
    • πŸ”§Useful Tools
      • ☁️Ethers
      • *️⃣Ethernal
    • πŸ“Solidity Notes
      • ❔Interview Questions
        • 🟒1. Easy - Interview Questions
        • 🟠2. Medium - Interview Questions
        • 🟑3. Hard - Interview Questions
        • πŸ”΄4. Advanced - Interview Questions
      • πŸ’‘Note Ideas
      • ABI
      • abi.encodePacked
      • Abstract Contracts
      • Arrays
      • Casting
      • CEI - Checks, Effects, Interactions
      • Comments (NATSPEC)
      • Constructor
      • Contract Structure & Versions
      • Data - Storage vs Memory
      • Data - Storage Layout
      • Enum
      • Errors (require & revert)
      • Events
      • EVM Opcodes
      • External Contract Interaction
      • πŸ—οΈExternal Dependencies
      • Functions
      • Function Modifiers
      • If / Else / For / While Loops
      • Inheritance
      • Interfaces
      • Keccak256
      • Library
      • Mappings
      • msg.sender
      • Objects & Types
      • OpenZeppelin
      • Payable
      • Public State Variable vs Function
      • Receive & Fallback
      • Security
      • Self Destruct
      • Send ETH (transfer, send, call)
      • Stack Too Deep
      • Structs
      • Style Guide
      • Time Units
      • Try / Catch
      • Typecasting
      • Using Directive
      • Variables, Consts & Immutable
      • Withdraws
    • βš’οΈFoundry Notes
      • πŸ“–Docs & GitHub Pages
      • 🀝Useful Commands
        • πŸ”¨Anvil
        • πŸͺ„Cast
        • πŸ”₯Forge
      • πŸ§ͺTests
        • Cheatcodes
      • πŸ“Useful Scripts
        • Deploy Contract Using Hex
    • πŸ‘ΎDeFi Challenges
      • πŸ‘¨β€πŸš€Ethernaut
        • Ethernaut - Template
        • Level 1 - Fallback ⏺
        • Level 2 - Fallout ⏺
        • Level 3 - Coin Flip ⏺⏺
        • Level 4 - Telephone ⏺
        • Level 5 - Token ⏺⏺
        • Level 6 - Delegation ⏺⏺
        • Level 7 - Force ⏺⏺⏺
        • Level 8 - Vault ⏺⏺
        • Level 9 - King ⏺⏺⏺
        • Level 10 - Re-entrancy ⏺⏺⏺
        • Level 11 - Elevator ⏺⏺
        • Level 12 - Privacy ⏺⏺⏺
        • Level 13 - Gatekeeper 1 ⏺⏺⏺⏺
        • Level 14 - Gatekeeper 2 ⏺⏺⏺
        • Level 15 - Naught Coin ⏺⏺⏺
        • Level 16 - Preservation ⏺⏺⏺⏺
        • Level 17 - Recovery ⏺⏺⏺
        • Level 18 - Magic Number ⏺⏺⏺
        • Level 19 - Alien Codex ⏺⏺⏺⏺
        • Level 20 - Denial ⏺⏺⏺
        • Level 21 - Shop ⏺⏺
        • Level 22 - Dex ⏺⏺
        • Level 23 - Dex Two ⏺⏺
        • Level 24 - Puzzle Wallet ⏺⏺⏺⏺
        • Level 25 - Motorbike ⏺⏺⏺
        • Level 26 - DoubleEntryPoint ⏺⏺
        • Level 27 - Good Samaritan ⏺⏺⏺
        • Level 28 - Gatekeeper 3 ⏺⏺⏺
        • Level 29 - Switch ⏺⏺⏺⏺
        • Level 30 - Higher Order ⏺⏺⏺⏺
        • Level 31 - Stake ⏺⏺⏺
      • πŸ’ΈDamn Vulnerable DeFi
    • πŸ”Auditing
      • πŸ—žοΈExploit Resources
      • πŸ”§Audit Tools
    • πŸ€–MEV
  • Infrastructure Docs
    • πŸ’»Hardware
    • 🐧Linux
      • πŸ“–Linux Glossary
      • ⌨️Linux Commands
      • πŸ’ΎInstallation
      • πŸ—οΈMaintenance
      • πŸ–₯️Ubuntu Desktop
      • πŸ›œZeroTier
      • 🎞️TMUX
      • πŸ”΅Bluetooth
    • ⛓️Ethereum Clients
      • βš™οΈExecution Clients
        • ⛏️Geth
          • πŸ’ΎInstallation
          • ⌨️Useful Commands
          • πŸ—οΈMaintenance
        • 🐻Erigon
          • πŸ’ΎInstallation
          • ⌨️Useful Commands
          • πŸ—οΈMaintenance
        • 🧢Besu
          • πŸ’ΎInstallation
          • ⌨️Useful Commands
          • πŸ—οΈMaintenance
      • 🀝Beacon Clients
        • πŸ’‘Lighthouse
          • πŸ’ΎInstallation
          • ⌨️Useful Commands
          • πŸ—οΈMaintenance
        • πŸͺ…Teku
          • πŸ’ΎInstallation
          • ⌨️Useful Commands
          • πŸ—οΈMaintenance
      • πŸ’ŽValidator Clients
        • πŸ’‘Lighthouse
          • πŸ’ΎInstallation
          • ⌨️Useful Commands
          • πŸ—οΈMaintenance
      • βž•L2 Clients
        • πŸ”΅Base
          • πŸ’ΎInstallation
          • ⌨️Useful Commands
          • πŸ—οΈMaintenance
      • πŸ’°MEV Boost
        • πŸ’ΎInstallation
        • πŸ—οΈMaintenance
    • 🚨Alerting and Monitoring
      • πŸ”₯Prometheus
      • 🌑️HealthChecks.io
      • πŸ“ŸPagerDuty
  • General Dev
    • πŸ’ΎGit Notes
      • Repos
      • Committing changes
      • Branches
      • Merging & Rebasing
      • PRs
Powered by GitBook
On this page
  • 2.1 What is the difference between transfer and send?
  • 2.2 Why should they not be used?
  • 2.3 What is a storage collision in a proxy contract?
  • 2.4 What is the difference between abi.encode and abi.encodePacked?
  • 2.5 uint8, uint32, uint64, uint128, uint256 are all valid uint sizes. Are there others?
  • 2.6 What changed with block.timestamp before and after proof of stake?
  • 2.7 What is frontrunning?
  • 2.8 What is a commit-reveal scheme and when would you use it?
  • 2.9 Under what circumstances could abi.encodePacked create a vulnerability?
  • 2.10 How does Ethereum determine the BASEFEE in EIP-1559?
  • 2.11 What is the difference between a cold read and a warm read?
  • 2.12 How does an AMM price assets?
  • 2.13 What is a function selector clash in a proxy and how does it happen?
  • 2.14 What is the effect on gas of making a function payable?
  • 2.15 What is a signature replay attack?
  • 2.16 How would you design a game of rock-paper-scissors in a smart contract such that players cannot cheat?
  • 2.17 What is the free memory pointer and where is it stored?
  • 2.18 What function modifiers are valid for interfaces?
  • 2.19 What is the difference between memory and calldata in a function argument?
  • 2.20 Describe the three types of storage gas costs for writes.
  • 2.21 Why shouldn’t upgradeable contracts use the constructor?
  • 2.22 What is the difference between UUPS and the Transparent Upgradeable Proxy pattern?
  • 2.23 If a contract delegatecalls an empty address or an implementation that was previously self-destructed, what happens?
  • 2.24 What if it is a low-level call instead of a delegatecall?
  • 2.25 What danger do ERC777 tokens pose?
  • 2.26 According to the solidity style guide, how should functions be ordered?
  • 2.27 According to the solidity style guide, how should function modifiers be ordered?
  • 2.28 What is a bonding curve?
  • 2.29 How does _safeMint differ from _mint in the OpenZeppelin ERC721 implementation?
  • 2.30 What keywords are provided in Solidity to measure time?
  • 2.31 What is a sandwich attack?
  • 2.32 If a delegatecall is made to a function that reverts, what does the delegatecall do?
  • 2.33 What is a gas efficient alternative to multiplying and dividing by a power of two?
  • 2.34 How large a uint can be packed with an address in one slot?
  • 2.35 Which operations give a partial refund of gas?
  • 2.36 What is ERC165 used for?
  • 2.37 If a proxy makes a delegatecall to A, and A does address(this).balance, whose balance is returned, the proxy’s or A?
  • 2.38 What is a slippage parameter useful for?
  • 2.39 What does ERC721A do to reduce mint costs? What is the tradeoff?
  • 2.40 Why doesn’t Solidity support floating point arithmetic?
  • 2.41 What is TWAP? How does Compound Finance calculate utilization?
  • 2.42 If a delegatecall is made to a function that reads from an immutable variable, what will the value be?
  • 2.43 What is a fee-on-transfer token?
  • 2.44 What is a rebasing token?
  • 2.45 In what year will a timestamp stored in a uint32 overflow?
  • 2.46 What is LTV in the context of DeFi?
  • 2.47 What are aTokens and cTokens in the context of Compound Finance and AAVE?
  • 2.48 Describe how to use a lending protocol to go leveraged long or leveraged short on an asset.
  • 2.49 What is a perpetual protocol?
Edit on GitHub
  1. Ethereum Dev
  2. Solidity Notes
  3. Interview Questions

2. Medium - Interview Questions

Last updated 1 month ago

2.1 What is the difference between transfer and send?

  • send

    • Returns a bool indicating success (true) or failure (false).

    • Only forwards a fixed 2300 gas stipend, which is often enough for basic operations but might not suffice for complex logic in the receiving contract.

    • If the transfer fails, it does not revert the transaction. You need to handle the failure by checking the return value.

  • transfer

    • Automatically reverts the transaction if the transfer fails, so no additional error handling is needed.

    • Also forwards a fixed 2300 gas stipend, preventing the receiving contract from executing too much code.

    • Generally considered safer because it reverts on failure, meaning you don’t have to manually check for success.

2.2 Why should they not be used?

Due to the fixed gas limits, they are not flexible enough to work with smart contract wallets which may require more gas than is available from transfer or send.

2.3 What is a storage collision in a proxy contract?

When a function in the proxy contract has the same 4-byte identifier as a function in the implementation contract. This will cause a collision and mean that the function in the implementation contract can never be called.

2.4 What is the difference between abi.encode and abi.encodePacked?

  • abi.encode

    • Encodes data in ABI (Application Binary Interface) encoding format.

    • Adds padding to make each data item fit into a 32-byte slot, following the ABI encoding standards.

    • Each argument is encoded as a standalone item, with proper padding and alignment, which makes it more readable and less error-prone when used in conjunction with other Solidity functions.

    • Example:

      • Input: bytes memory encodedData = abi.encode("Hello", uint256(123));

      • Output (encodedData): 0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000007b000000000000000000000000000000000000000000000000000000000000000548656c6c6f000000000000000000000000000000000000000000000000000000 (padded to 32 bytes).

  • abi.encodePacked

    • Encodes data in a compact, non-standard format.

    • Does not add padding, so each data item is placed directly after the previous one without any alignment.

    • Generally used for more compact encoding or for concatenating data, such as when creating a unique hash (e.g., in keccak256 hashing).

    • Be careful with potential collisions:

      • Concatenating variable-length types (like string and bytes) without padding can result in ambiguous results. For example, encoding two strings with abi.encodePacked("abc", "def") and abi.encodePacked("ab", "cdef") would produce the same output.

    • Example:

      • Input: bytes memory packedData = abi.encodePacked("Hello", uint256(123));

      • Output (packedData): 0x48656c6c6f000000000000000000000000000000000000000000000000000000000000007b000000000000000000000000000000000000000000000000000000 (no padding).

2.5 uint8, uint32, uint64, uint128, uint256 are all valid uint sizes. Are there others?

2.6 What changed with block.timestamp before and after proof of stake?

2.7 What is frontrunning?

2.8 What is a commit-reveal scheme and when would you use it?

2.9 Under what circumstances could abi.encodePacked create a vulnerability?

2.10 How does Ethereum determine the BASEFEE in EIP-1559?

2.11 What is the difference between a cold read and a warm read?

Cold reads happen when a storage slot is read for the first time during a transaction call. Cold reads are more expensive in terms of gas because the storage slot is being loaded into memory from disk.

Warm reads are for each subsequent call and have a lower gas cost than the initial cold read. The gas cost is lower for warm reads because the storage slot is already loaded into memory, eliminating the need for the more expensive disk access.

This distinction was introduced with EIP-2929 (Ethereum Berlin Hardfork) to make gas costs better reflect the computational effort required for storage access.

2.12 How does an AMM price assets?

2.13 What is a function selector clash in a proxy and how does it happen?

A function selector clash in a proxy contract occurs when a function in the proxy contract has the same function selector as a function in the implementation contract. Since the proxy handles calls before they reach the implementation, if the proxy defines a function with the same selector as one in the implementation, the proxy function will always take precedence, preventing the implementation function from ever being called.

2.14 What is the effect on gas of making a function payable?

2.15 What is a signature replay attack?

When a signature is reused multiple times, this could occur on the same chain or across different chains. Signature replay attacks can be mitigated by specifying a nonce to stop a signature from being used twice on the same chain, as well as a chain identifier so that the signature is only valid on the chain it was intended to be used on.

2.16 How would you design a game of rock-paper-scissors in a smart contract such that players cannot cheat?

2.17 What is the free memory pointer and where is it stored?

0x40

2.18 What function modifiers are valid for interfaces?

Only externalis a valid modifier for interfaces.

2.19 What is the difference between memory and calldata in a function argument?

2.20 Describe the three types of storage gas costs for writes.

2.21 Why shouldn’t upgradeable contracts use the constructor?

A constructor is run the first time a contract is deployed, but as an implementation contract stores its state on the proxy contract, any actions that occur in the constructor of the implementation contract would act in the context of that implementation contract.

This would lead to unexpected and unintended consequences, so this is why a initializer is used for upgradeable contracts instead of the constructor.

2.22 What is the difference between UUPS and the Transparent Upgradeable Proxy pattern?

2.23 If a contract delegatecalls an empty address or an implementation that was previously self-destructed, what happens?

In both cases, the call fails, returns false, and reverts if require(success) is used.

2.24 What if it is a low-level call instead of a delegatecall?

2.25 What danger do ERC777 tokens pose?

They implement a callback mechanism that has the potential to allow reentrancy attacks.

2.26 According to the solidity style guide, how should functions be ordered?

2.27 According to the solidity style guide, how should function modifiers be ordered?

2.28 What is a bonding curve?

2.29 How does _safeMint differ from _mint in the OpenZeppelin ERC721 implementation?

2.30 What keywords are provided in Solidity to measure time?

  • 1 == 1 seconds

  • 1 minutes == 60 seconds

  • 1 hours == 60 * 60 seconds

  • 1 days == 24 * 60 * 60 seconds

  • 1 weeks == 7 * 24 * 60 * 60 seconds

uint deadline = block.timestamp + 3 days;

2.31 What is a sandwich attack?

2.32 If a delegatecall is made to a function that reverts, what does the delegatecall do?

2.33 What is a gas efficient alternative to multiplying and dividing by a power of two?

2.34 How large a uint can be packed with an address in one slot?

2.35 Which operations give a partial refund of gas?

2.36 What is ERC165 used for?

2.37 If a proxy makes a delegatecall to A, and A does address(this).balance, whose balance is returned, the proxy’s or A?

2.38 What is a slippage parameter useful for?

2.39 What does ERC721A do to reduce mint costs? What is the tradeoff?

2.40 Why doesn’t Solidity support floating point arithmetic?

1. Determinism and Precision: Solidity operates in a decentralized environment where all computations must produce identical results across all nodes. Floating-point arithmetic is prone to rounding errors and imprecision due to the way computers represent real numbers, which could lead to inconsistencies in transaction outcomes.

2. Gas Costs: Implementing floating-point operations would increase the computational complexity and gas costs, as these operations require additional processing for handling precision, rounding, and edge cases. This inefficiency makes them impractical for the EVM.

2.41 What is TWAP? How does Compound Finance calculate utilization?

2.42 If a delegatecall is made to a function that reads from an immutable variable, what will the value be?

If a delegatecall is made to a function that reads from an immutable variable, the value returned will be garbage (invalid data) or potentially zero, depending on the context. This happens because immutable variables are stored in the code section of the contract that defines them, and delegatecall does not change the code context.

This issue is specific to immutable variables. It does not apply to constant variables or hardcoded values.

2.43 What is a fee-on-transfer token?

2.44 What is a rebasing token?

2.45 In what year will a timestamp stored in a uint32 overflow?

2.46 What is LTV in the context of DeFi?

2.47 What are aTokens and cTokens in the context of Compound Finance and AAVE?

2.48 Describe how to use a lending protocol to go leveraged long or leveraged short on an asset.

2.49 What is a perpetual protocol?

For signed integers, it will be the year .

For unsigned 32-bit integers, it will be the year .

πŸ“
❔
🟠
2038
2106
Over 150 interview questions for Ethereum Developers - RareSkillsRareSkills
Logo