Blockchain interview questions and answers: fundamentals to smart contract security

Prepare for your blockchain interview with our extensive guide featuring over 50 essential questions and answers. Covering key concepts, technologies, and best practices, this resource will help you understand blockchain fundamentals and excel in your interview.

Aug 13, 2024 - 11:48
Updated: 14 days ago
104.2k
Blockchain interview questions and answers: fundamentals to smart contract security

Quick answer: Blockchain interviews test whether you understand how blocks, hashes, consensus and digital signatures make a shared ledger tamper-evident without a central authority. Expect questions on Bitcoin and Ethereum, proof of work versus proof of stake, smart contracts, wallets, common attacks like double spending and reentrancy, and where blockchain is and is not a good fit.

Key takeaways

  • Know blocks, hashes, Merkle trees, digital signatures and consensus well.
  • Be able to compare proof of work and proof of stake.
  • Understand smart contracts and attacks such as reentrancy.
  • Explain when a blockchain is a poor fit.
  • Practise on a test network.

Fundamentals

1. What is a blockchain?

A shared, append-only ledger stored across many computers. Records are grouped into blocks, and each block contains the hash of the previous one, so changing history is detectable.

2. What is in a block?

A header with the previous block's hash, a timestamp and a Merkle root, and a list of transactions.

3. What makes a blockchain tamper-evident?

Each block includes the previous block's hash. Changing an old block changes its hash and breaks every later link.

4. Public, private and consortium blockchains?

Public: anyone can join and read, such as Bitcoin. Private: one organisation controls access. Consortium: a group of organisations share control.

5. What is decentralisation and why does it matter?

No single party controls the ledger, which reduces the need to trust one authority.

Cryptography

6. What is a hash function?

A function that maps data to a fixed-length output. It is one-way and small input changes produce very different outputs. Bitcoin uses SHA-256.

7. What is a Merkle tree?

A tree of hashes in which each leaf is a transaction hash and each parent hashes its children. It lets you prove a transaction is in a block efficiently.

8. How do digital signatures work in blockchains?

A private key signs a transaction. Anyone can verify the signature with the public key. This proves the owner authorised it.

9. What is a wallet?

Software or hardware that stores private keys and lets you sign transactions. The coins live on the ledger, not in the wallet.

Consensus

10. What is consensus?

The way nodes agree on which transactions and blocks are valid.

11. Proof of work?

Miners compete to find a hash below a target. It costs energy, which makes rewriting history expensive.

12. Proof of stake?

Validators lock up tokens as a stake and are chosen to propose and attest blocks. Misbehaviour can lead to loss of stake.

13. What is a 51% attack?

An attacker controlling most of the mining power or stake could reorder recent transactions or double spend. It is costly on large networks.

14. What is a fork?

A divergence in the chain. A soft fork is backward compatible. A hard fork is not.

15. What is double spending?

Spending the same coin twice. Consensus and confirmations prevent it.

Bitcoin and Ethereum

16. How does Bitcoin track ownership?

With the UTXO model: unspent outputs from earlier transactions that can be spent with the right key. See the Bitcoin developer guide.

17. How is Ethereum different?

It uses an account model and supports programmable smart contracts on the Ethereum Virtual Machine. See ethereum.org.

18. What is gas?

The fee that pays for computation on Ethereum, which also limits runaway code.

Smart contracts

19. What is a smart contract?

Code stored on a blockchain that runs when conditions are met. Once deployed, it is hard to change.

20. What is an oracle?

A service that brings outside data on-chain, since contracts cannot fetch it themselves. It can be a point of failure.

21. What are tokens, ERC-20 and ERC-721?

Tokens are assets on a blockchain. ERC-20 is a standard for interchangeable tokens. ERC-721 is a standard for unique tokens.

Security

22. What is a reentrancy attack?

A malicious contract calls back into a vulnerable contract before its state is updated, repeating withdrawals. Prevent it with checks-effects-interactions ordering and reentrancy guards.

23. How do you secure a smart contract?

Use well-tested libraries, minimise complexity, test thoroughly, get an independent audit and limit privileges.

24. How do you protect private keys?

Use hardware wallets, offline backups, strong passphrases and never share seed phrases.

25. What is a rug pull or phishing risk?

Scams where developers drain funds or users are tricked into signing malicious transactions. Check what you sign.

Applications

26. Where does blockchain fit well?

Where several parties need a shared record without a trusted central party, such as some supply chain and settlement uses.

27. When is blockchain a poor fit?

When one trusted party can run a normal database more cheaply and faster.

28. What is the scalability problem?

Many chains process few transactions per second. Layer 2 solutions and sharding aim to improve throughput.

29. What is Hyperledger?

A family of open-source enterprise blockchain projects hosted by the Linux Foundation, designed for permissioned networks.

30. How would you practise?

Use a test network and a faucet, deploy a small contract and try breaking it safely.

How should you prepare?

Draw a block diagram from memory, explain proof of work in plain words, and write one small contract. Related reading: what blockchain technology is and Bitcoin and Ethereum security.

Next steps

For the security angle, see Bitcoin and Ethereum security and our Cyber Security course.

Frequently Asked Questions

A blockchain is a shared, append-only ledger kept by many computers. Transactions are grouped into blocks and each block includes the previous block's hash, so changing old data is detectable.

Proof of work needs miners to spend computing power to find valid blocks. Proof of stake selects validators who lock up tokens as a stake and can lose it if they misbehave.

A smart contract is code stored on a blockchain that runs automatically when its conditions are met. Once deployed it is hard to change, so careful testing and auditing are essential.

It is when one party controls most of a network's mining power or stake and can reorder recent transactions or double spend. On large networks it is very expensive and difficult.

A malicious contract repeatedly calls back into a vulnerable contract before its state is updated, allowing repeated withdrawals. Prevent it by updating state first and using reentrancy guards.

When a single trusted party can run an ordinary database faster and more cheaply. Blockchain makes sense mainly when several parties need a shared record without trusting a central authority.

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Wow Wow 0
Sad Sad 0
Angry Angry 0
Anjali

I am passionate about technology, invention and big challenging tasks on my to- do list. In terms of the work I am doing also at Bunnyshell, I am most passionate about the technologies that we are using., I'm devoted to delivering content that not only informs but also inspires. Whether you need in- depth analysis pieces, educational attendants, or study- provoking opinion pieces, I draft content that resonates with tech suckers and professionals likewise.