Ethereum Interview Questions Part - 1

Ethereum Interview Questions – Part 1

Ethereum Interview Questions - Part 1

Who is the founder of Ethereum?

Vitalik Buterin

What is the average block time in Ethereum?

14–20 seconds

What is the average block size in Ethereum?


What is the average number of transactions per second?


Is Ethereum a public or private ledger?

Ethereum, by default is a public ledger. But one can also spawn a private Ethereum Network.

What is Consensus?

In the blockchain, Blockchain consensus is a mechanism that enabled nodes to agree on the sequences of transactions in a block.

What is the difference between algorithm and protocol?

Protocol refers to the general rules. For example, Bitcoin and Ethereum are protocols. Algorithms are the steps taken to implement a protocol. For example, Proof-of-Work in case of Ethereum 1.0 and Proof of Stake in case of Ethereum 2.0

What are the public and private keys?

The public key is known to all nodes and it is used to identify the recipient. The private is known only to the owner and it is used to sign a transaction.

What is a smart contract?

Smart Contracts are lines of code that are stored on a blockchain and execute on external triggers (Outside blockchain or by other smart contracts).

What is EVM?

EVM stands for Ethereum Virtual Machine. It is a runtime environment for smart contracts in Ethereum. It handles the internal state and computation of the Ethereum protocol.

What is Gas?

Gas is the fee(Ether) required to successfully conduct a transaction or execute a smart contract.

What languages are used to write smart contracts?

  1. Solidity
  2. Serpent(Deprecated)
  3. Viper
  4. Bamboo

What is geth?

Geth (go-ethereum) is an Ethereum client, i.e. an implementation of the Ethereum protocol. It is written in the Go language. In addition, Geth, there are other Ethereum clients such as Parity.

What is an Ethereum client?

Ethereum client is an implementation of the Ethereum protocol. A running client called a node, which is able to parse and verify the blockchain, its smart contracts, and everything related. It also provides an interface to create transactions and mine blocks which is the key for any blockchain interaction.

Do all functions in a smart contract costs money?

No. The functions that modify the state of EVM costs money (or gas). But functions that read the state of EVM doesn’t cost any money (or gas). Basically, all write operations cost money while all read operations don’t.

What is a state machine? Why Ethereum is called a state machine?

A state machine refers to something that makes a transaction from one state to another based on the input.

When nodes make transactions, the current state transitions into some final state. At any point in time, this final state represents the current state of Ethereum.

What is a Merkle tree? What is the importance of the Merkle tree in blockchain? How Ethereum implements a Merkle tree?

A Merkle tree, in the most general sense, is a way of hashing a large number of “chunks” of data together which relies on splitting the chunks into many buckets, where each bucket contains only a few chunks. Then taking the hash of each bucket and repeating the same process, continuing to do so until the total number of hashes remaining becomes only one: the root hash (Merkle Root).

A binary Merkle tree looks like below:

Binary Merkle tree
Binary Merkle tree

The Merkle Root is important because it summarizes every transaction in the block and is located on the block header. If there is any malicious change in the transactions stored in the block, the Merkle root changes. This makes it easier to verify whether or not a transaction has occurred within a block.

The Ethereum blockchain uses a modified version of the basic Merkle tree which is actually called the Merkle Patricia tree, Patricia tree, or Patricia Trie.

Each Ethereum block header has three Merkle trees.

  1. Transactions
  2. State
  3. Receipts (essentially, pieces of data showing the effect of each transaction)

The first one is the root of transactions on the block, the second is the root showing the state of the Ethereum network, and the third is the receipt root.

Ethereum’s global state consists of a mapping between account addresses and the account states. This mapping is stored in the Merkle Patricia tree. In this data structure, data is stored in the form of a key-value pair.  The state in Ethereum is different, and as explained by Vitalik Buterin, it is a key-value map. The keys are the addresses of an account, and the values are nonces, account balances, and code and storage. 

How does the gas parameter save the system from attackers?

Let us consider a situation where an attacker wants to halt the Ethereum network by running a smart contract which consists of an infinite loop. Without the gas parameter, every node will execute the infinite loop which will eventually crash the network.

With the gas parameter included, if an attacker runs such a smart contract, he will also have to attach the equivalent amount of gas i.e Ether. So, it will only lead to the attacker’s loss as he will eventually run out of gas and the execution will stop at that instant. This is how the gas parameter saves the Ethereum network from attackers.

Gas is the Ether, the cryptocurrency of the network.

Where does the contract code is executed?

A smart contract is executed when a mining node includes the transaction in a block it generates. The associated gas acts as a fuel to run the smart contract. If the gas price is sufficient enough to run the contract, state transitions as directed by smart contract and the related transaction is included in the block and is then broadcasted in the network. If the gas is not sufficient, it throws an error. The smart contract codes are then run by every other node when they include the block in their local Ethereum Network.

What is DAO and how it functions?

A decentralized autonomous organization is an organization represented by rules encoded in a transparent smart contract and it is controlled by shareholders or board of directors.

For certain actions to enforce, be it transfer of fund or modification in the base code, there should be the consent of at least 2/3rd of the members. Methods for allocating a DAO’s funds could range from bounties, salaries, internal currency to reward work.

What GHOST protocol? What problems does it solve in Ethereum?

The GHOST (Greedy Heaviest-Observed Sub-Tree) protocol picks the path that has had the most computation done upon it.

GHOST solves the issue of network security loss by including in the calculation of which chain is the “longest by not only including the parent and further ancestors of a block but also the stale blocks (called uncle blocks).

Name 4 components of the account state?

nonce: For an externally owned account, this number represents the number of transactions sent from the account’s address. For a contract account, the nonce is the number of contracts created by the account.

balance: The number of Wei owned by this address.

storageRoot: A hash of the root node of a Merkle Patricia tree. This tree encodes the hash of the storage contents of this account and is empty by default.

codeHash: The hash of the EVM code of this account. For contract accounts, this is the code that gets hashed and stored as the codeHash. For externally owned accounts, the codeHash field is the hash of the empty string.

How the signing and verification of a transaction take place in Ethereum?

The private key along with the transaction data is used to sign a transaction. ECDSA signatures in a transaction consist of three parameters r, s, and v. Ethereum clients provide a global method that returns an address given these three parameters. If the returned address is the same as the signer’s address, then the signature is valid.

What is the importance of difficulty?

The “difficulty” of a block is used to enforce consistency in the time it takes to validate blocks. If a certain block is validated more quickly than the previous block, the Ethereum protocol increases that block’s difficulty. If a block validation takes more time than the previous block, the Ethereum protocol decreases that block’s difficulty.

What is intrinsic gas value?

Intrinsic gas value gives an estimated cost of the gas fees. So, the transaction’s gas limit must be equal to or greater than the intrinsic gas. Intrinsic gas consists of –

  1. a predefined cost of 21,000 gas for executing the transaction
  2. a gas fee for data sent with the transaction (4 gas for every byte of data or code that equals zero, and 68 gas for every non-zero byte of data or code)
  3. if the transaction is contract-creating, an additional 32,000 gas

What is the importance of account nonce in Ethereum?

An account nonce is a transaction counter in each account. It is used to prevents replay attacks i.e. taking a transaction on one blockchain, and maliciously or fraudulently repeating it.

What is the state channel?

State channels are used for scaling the Ethereum blockchain and reducing costs for micropayments by moving on-chain components to off-chain. This can avoid delays and fees associated with micropayments. This is similar to the Lightning network in Bitcoin. Participants in a state channel pass cryptographically signed messages without publishing them to the main chain until they both decide to close the channel.

What is Whisper Protocol?

Whisper is a peer-to-peer communication protocol for Dapps built upon the Ethereum network. It provides a privacy-focused, encrypted messaging system for Dapps. Properties of Whisper protocol

  1. Low-level
  2. Low-bandwidth
  3. Uncertain-latency

What is Dapp?

Dapp stands for Decentralized Applications. They are like normal apps but the key difference is, that Dapps’ components run one or more peer-to-peer networks, such as a blockchain. It was popularized by Ethereum.

What is ABI?

It stands for Application Binary Interface. We get ABI(Usually in JSON format) after compiling a smart contract. It is used to invoke smart contract functions from the client-side.

What is Solidity?

Solidity is the most popular language to write a smart contract on Ethereum. It is statically typed language i.e. variable types are explicitly declared and thus are determined at compile time.

Why do we specify the compiler version in a smart contract?

It prevents incompatibility errors that can be introduced when compiling with another version.

What are the different types of functions in Solidity?

  1. Constructor – It is an optional function and is used to initialize state variables of a contract.
  2. Payable functions – Payable functions provide a mechanism to collect/receive funds in ethers to your contract.
  3. Fallback functions – Fallback functions are unnamed functions. They are executed when a function identifier does not match any of the available functions in a smart contract
  4. View functions -View functions ensure that they will not modify the state.
  5. Pure functions – Pure functions ensure that they are not read or modify the state.

What is the purpose of modifier in Solidity?

It allows you to control the behavior of your smart contract functions. It includes a variety of use cases, such as restricting who can run a given function, unlocking functions at a certain time frame etc.

What are the access specifiers in Solidity?

There are 4 types of access specifiers in Solidity, they help to define the scope/visibility of functions and state variables.

external – External functions are part of the contract interface, which means they can be called from other contracts and via transactions. An external function f cannot be called internally (i.e. f() does not work, but this.f() works). External functions are sometimes more efficient when they receive large arrays of data.

public– Public functions are part of the contract interface and can be either called internally or via messages. For public state variables, an automatic getter function (see below) is generated.

internal – Those functions and state variables can only be accessed internally (i.e. from within the current contract or contracts deriving from it), without using this.

private – Private functions and state variables are only visible for the contract they are defined in and not in derived contracts.

Name different types of EVM memory?

  1. stack
  2. memory
  3. storage

What is Account in Ethereum?

An Ethereum account is a 20-byte address which can store the state of ownership of ether tokens. There are two types of account in Ethereum-

  1. Externally Owned Account(EOA)- These accounts are controlled by a private key. It has no associated code and is mainly used to perform transactions.
  2. Contract Account- This account has a code associated with it. It is mainly used to invoke smart contract functions.

What is a nonce?

nonce is an abbreviation for “number only used once”. Miners compete in a Proof-of-Work based blockchain network to find the targeted hash. In addition, every Ethereum account has a incremental nonce to prevent replay attack.

What is the gas limit?

The Gas Limit is the maximum amount of Gas that a user is willing to pay when sending a transaction or performing a smart contract function, in the Ethereum blockchain. In Ethereum there is no block size limit rather blocks has Gas limit. Currently accepting blocks with an average block gas limit of around 10,000,000 gas.

Explain different types of blockchain syncs are there in Ethereum?

Full Sync: a node replicates the blockchain state starting from the genesis block. It downloads every transaction ever made on the network and computes the state.

Fast Sync: A node downloads the blocks, and only verifies the associated proof-of-works.

Light Sync: It only stores the header chain and requests everything else on-demand from the network.

Archive Sync: It is similar to full sync but stores all intermediate states in the disk.

Wanna learn about Crypto?

Subscribe to our weekly newsletter

Leave a Reply