DEV Community

Cover image for 29 Essential Blockchain Interview Questions You Will Suck On
Alex 👨🏼‍💻FullStack.Cafe for FullStack.Cafe

Posted on • Originally published at fullstack.cafe

29 Essential Blockchain Interview Questions You Will Suck On

The demand for blockchain developers and engineers keeps on increasing without pause. The numbers don't lie and they are truly staggering. According to research done by management consulting firm, Janco Associates, the median salary for a blockchain developer is now as much as $127,000.

Originally published on FullStack.Cafe - Never Fail Your Tech Interview Again

Q1: What is blockchain?

Topic: Blockchain
Difficulty: ⭐

Blockchain is a secure distributed ledger (data structure or database) that maintains a continuously growing list of ordered records, called “blocks”, that are linked using cryptography. Each block contains a cryptographic hash of the previous block, a timestamp, and transaction data.

By design, a blockchain is resistant to modification of the data. It is "an open, distributed ledger that can record transactions between two parties efficiently and in a verifiable and permanent way".

Once recorded, the data in any given block cannot be altered retroactively without alteration of all subsequent blocks, which requires consensus of the network majority.

🔗 Source: en.wikipedia.org

Q2: Explain the common structure of blockchains

Topic: Blockchain
Difficulty: ⭐⭐

Blockchains are composed of three core parts:

  • Block: A list of transactions recorded into a ledger over a given period. The size, period, and triggering event for blocks is different for every blockchain.
  • Chain: A hash that links one block to another, mathematically “chaining” them together.
  • Network: The network is composed of “full nodes.” Think of them as the computer running an algorithm that is securing the network. Each node contains a complete record of all the transactions that were ever recorded in that blockchain.

🔗 Source: dummies.com

Q3: What is the blockchain data structure?

Topic: Blockchain
Difficulty: ⭐⭐

Basically the blockchain data structure is explained as a back-linked record of blocks of transactions, which is ordered. It can be saved as a file or in a plain database. Each block can be recognized by a hash, created utilizing the SHA256 cryptographic hash algorithm on the header of the block. Each block mentions a former block, also identified as the parent block, in the “previous block hash” field, in the block header.

🔗 Source: cryptoticker.io

Q4: What is the Genesis Block?

Topic: Blockchain
Difficulty: ⭐⭐

The first block in any blockchain **is termed the **genesis block. If you start at any block and follow the chain backwards chronologically, you will arrive at the genesis block. The genesis block is statically encoded within the client software, that it cannot be changed. Every node can identify the genesis block’s hash and structure, the fixed time of creation, and the single transactions within. Thus every node has a secure “root” from which is possible to build a trusted blockchain on.

🔗 Source: linkedin.com

Q5: What is the purpose of a blockchain node?

Topic: Blockchain
Difficulty: ⭐⭐

A blockchain exists out of blocks of data. These blocks of data are stored on nodes (compare it to small servers). Nodes can be any kind of device (mostly computers, laptops or even bigger servers). Nodes form the infrastructure of a blockchain.

All nodes on a blockchain are connected to each other and they constantly exchange the latest blockchain data with each other so all nodes stay up to date. They store, spread and preserve the blockchain data, so theoretically a blockchain exists on nodes.

A full node is basically a device (like a computer) that contains a full copy of the transaction history of the blockchain.

🔗 Source: lisk.io

Q6: What is proof-of-work?

Topic: Blockchain
Difficulty: ⭐⭐

A proof of work is a piece of data which is difficult (costly, time-consuming) to produce but easy for others to verify and which satisfies certain requirements. Producing a proof of work can be a random process with low probability so that a lot of trial and error is required on average before a valid proof of work is generated. Difficulty is a measure of how difficult it is to find a hash below a given target.

🔗 Source: en.bitcoin.it

Q7: What is deterministic behavior?

Topic: Blockchain
Difficulty: ⭐⭐

If A + B = C, then no matter what the circumstances, A+B will always be equal to C. That is called deterministic behavior.

Hash functions are deterministic, meaning A’s hash will always be H(A).

🔗 Source: blockgeeks.com

Q8: Why does Blockchain need coins or tokens?

Topic: Blockchain
Difficulty: ⭐⭐

Tokens/Coins are used as a medium of exchange between the states. They are digital assets built in to perform a specific function within a blockchain.

When someone does a transaction, there is a change of state, and coins are moved from one address to another address. Apart from that, transactions contain some additional data; this data can be mutated through the change of state. For this reason, blockchains need coins or tokens to incentivize the participants to join their networks.

🔗 Source: mindmajix.com

Q9: What is Merkle Trees?

Topic: Blockchain
Difficulty: ⭐⭐⭐

Merkle trees are a fundamental part of blockchain technology. A merkle tree is a structure that allows for efficient and secure verification of content in a large body of data.

A Merkle tree summarizes all the transactions in a block by producing a digital fingerprint of the entire set of transactions, thereby enabling a user to verify whether or not a transaction is included in a block.

Merkle trees are created by repeatedly hashing pairs of nodes until there is only one hash left (this hash is called the Root Hash, or the Merkle Root). They are constructed from the bottom up, from hashes of individual transactions (known as Transaction IDs). Hashing is usually conducted using the SHA-2 cryptographic hash function, though other functions can also be used.

🔗 Source: hackernoon.com

Q10: What are some advantages of using Merke Trees?

Topic: Blockchain
Difficulty: ⭐⭐⭐

Using a Merkle tree can significantly reduce the amount of data that a trusted authority has to maintain for verification purposes. It separates the validation of the data from the data itself.

Merkle trees have three major benefits:

  1. They provide a means to prove the integrity and validity of data
  2. They require little memory or disk space as the proofs are computationally easy and fast
  3. Their proofs and management only require tiny amounts of information to be transmitted across networks

The ability to prove that a log is complete and consistent is essential to blockchain technology and the general ledger concept. Merkle trees help verify that later versions of a log include everything from an earlier version and that all data is recorded and presented in chronological order.

🔗 Source: hackernoon.com

Q11: Explain what do nodes do?

Topic: Blockchain
Difficulty: ⭐⭐⭐

When a miner attempts to add a new block of transactions to the blockchain, it broadcasts the block to all the nodes on the network. Based on the block’s legitimacy (validity of signature and transactions), nodes can accept or reject the block. When a node accepts a new block of transactions, it saves and stores it on top of the rest of the blocks it already has stored. In short, here is what nodes do:

  • Nodes check if a block of transactions is valid and accept or reject it.
  • Nodes save and store blocks of transactions (storing blockchain transaction history).
  • Nodes broadcast and spread this transaction history to other nodes that may need to synchronize with the blockchain (need to be updated on transaction history).

🔗 Source: medium.com

Q12: Why is the blockchain immutable?

Topic: Blockchain
Difficulty: ⭐⭐⭐

Altering a single block requires a new signature for every other block that comes after it all the way to the end of the chain. This is considered to be near impossible. Why?

Let’s say a corrupt miner has altered a block of transactions and is now trying to calculate new signatures for the subsequent blocks in order to have the rest of the network accept his change. The problem for him is, the rest of the network is also calculating new signatures for new blocks. The corrupt miner will have to calculate new signatures for these blocks too as they are being added to the end of the chain. After all, he needs to keep all of the blocks linked, including the new ones constantly being added. Unless the miner has more computational power than the rest of the network combined, he will never catch up with the rest of the network finding signatures.

Millions of users are mining on the blockchain, and therefore it can be assumed that a single bad actor or entity on the network will never have more computational power than the rest of the network combined, meaning the network will never accept any changes on the blockchain, making the blockchain immutable.

🔗 Source: medium.com

Q13: What is mining difficulty?

Topic: Blockchain
Difficulty: ⭐⭐⭐

Mining difficulty is the degree that determines how hard it is for miners in terms of hashing power (and thus also time) to find an eligible hash aka signature for their block (a block of transactions needs an eligible hash to be verified and added to the blockchain). On the Bitcoin blockchain, miners try to find an eligible hash by hashing random numbers.

A block of transactions will only be accepted by the rest of the network if it has a signature (hash) that meets certain requirements (in example of Bitcoin, the signature needs to start with a certain number of zeroes). In order to find this signature, miners are spending computational power (hashing power) to perform a set of pre-determined operations on random numbers untill they find a number that leads to an output number that meets the requirements.

Finding an output that starts with only one zero is much easier (generally more common) than finding an output number that starts with five consecutive zeroes (this is pretty rare so it would take much more time to find a number that leads to such output).

For example block 100 (back in 2009) only required a signature that started with eight consecutive zeroes, whereas the last recent block (block 542865) needed a signature that started with at least 18 consecutive zeroes.

🔗 Source: medium.com

Q14: Explain why there is a fixed supply of bitcoins?

Topic: Blockchain
Difficulty: ⭐⭐⭐

There is a fixed supply of bitcoins. There will never be more than 21 million bitcoins. Bitcoins are created each time a user discovers a new block. The rate of block creation is adjusted every 2016 blocks to aim for a constant two week adjustment period (equivalent to 6 per hour).

The number of bitcoins generated per block is set to decrease geometrically, with a 50% reduction every 210,000 blocks, or approximately four years. The result is that the number of bitcoins in existence will not exceed slightly less than 21 million.

🔗 Source: en.bitcoin.it

Q15: What is DApp or Decentralised Application?

Topic: Blockchain
Difficulty: ⭐⭐⭐

A decentralized application (DApp, dApp, Dapp, or dapp) is a computer application that runs on a distributed computing system.

Decentralized applications don‘t necessarily need to run on top of a blockchain network. Tor, BitTorrent, Popcorn Time, BitMessage, are examples for decentralized applications that run on a P2P network, but not on a blockchain – which is a special kind of P2P network.

DApps have been mostly popularized by distributed ledger technologies (DLT), namely the Ethereum Blockchain, where DApps are often referred to as smart contracts. Its backend code runs on a decentralized peer-to-peer network, and all records of the applicationʼs operation are stored on a blockchain. In most cases, the entire code base is Open Source.

🔗 Source: blockchainhub.net

Q16: What is a trapdoor function, and why is it needed in blockchain development?

Topic: Blockchain
Difficulty: ⭐⭐⭐

A trapdoor function is a function that is easy to compute in one direction but difficult to compute in the opposite direction unless you have special information. Trapdoor functions are essential for public key encryption—that’s why they are commonly used in blockchain development to represent the ideas of addresses and private keys.

🔗 Source: toptal.com

Q17: Explain why a blockchain needs tokens to operate

Topic: Blockchain
Difficulty: ⭐⭐⭐

Coins/tokens are used to implement changes between states. When somebody does a transaction, this is a change of state, and coins are moved from one address to another. Apart from that, transactions can contain additional data, and a change of state is used to mutate data—the only way to do this in an immutable-by-definition blockchain.

Technically, a blockchain doesn’t need coins for its essential operations, but without them, some other way needs to be introduced to manage states of the chain and to verify transactions.

🔗 Source: toptal.com

Q18: How do verifiers check if a block is valid?

Topic: Blockchain
Difficulty: ⭐⭐⭐

Every full node on the network does block verification. When a new block is announced, every node that receives it does a list of checks. The two most important checks are of proof of work (if a block provides enough work to be included into chain) and of the validity of all transactions (each transaction must be valid).

🔗 Source: toptal.com

Q19: What is RSA algorithm?

Topic: Blockchain
Difficulty: ⭐⭐⭐

RSA (Rivest–Shamir–Adleman) is an algorithm used by modern computers to encrypt and decrypt messages. It is an asymmetric cryptographic algorithm. Asymmetric means that there are two different keys. This is also called public key cryptography, because one of the keys can be given to anyone. The other key must be kept private. The algorithm is based on the fact that finding the factors of a large composite number is difficult.

RSA involves a public key and private key. The public key can be known to everyone; it is used to encrypt messages. Messages encrypted using the public key can only be decrypted with the private key.

🔗 Source: simple.wikipedia.org

Q20: What is a smart contract?

Topic: Blockchain
Difficulty: ⭐⭐⭐

A smart contract is a computer protocol intended to digitally facilitate, verify, or enforce the negotiation or performance of a contract. Smart contracts allow the performance of credible transactions without third parties. These transactions are trackable and irreversible.

The aim of smart contracts is to provide security that is superior to traditional contract law and to reduce other transaction costs associated with contracting. Various cryptocurrencies have implemented types of smart contracts.

🔗 Source: en.wikipedia.org

Q21: What is a 51% attack?

Topic: Blockchain
Difficulty: ⭐⭐⭐⭐

If a bad actor has more computational power than the rest of the network combined he could alter a block of transactions and try to calculate new signatures for the subsequent blocks in order to have the rest of the network accept his change. Theoretically yes, this is possible and it is called a 51% attack.

On practise though it can be assumed that a single bad actor or entity on the network will never have more computational power than the rest of the network combined, meaning the network will never accept any changes on the blockchain, making the blockchain immutable.

Attempting a 51% attack is practically trying to fight all the other users on a blockchain just by yourself. This is also the reason that the more users participate in the mining process, the more secure a blockchain becomes.

🔗 Source: medium.com

Q22: What is a stealth address?

Topic: Blockchain
Difficulty: ⭐⭐⭐⭐

Public ledgers are generally considered to be “pseudo-anonymous”, which means that an address is linked to one person, but that person is unknown to the public.

A stealth address is a privacy-enhancing technology for protecting the privacy of receivers of cryptocurrencies. Stealth addresses require the sender to create random, one-time address for every transaction on behalf of the recipient so that different payments made to the same payee are unlinkable.

🔗 Source: blockchainhub.net

Q23: Explain what is target hash?

Topic: Blockchain
Difficulty: ⭐⭐⭐⭐

Hash target is a 256-bit number, which is used as the threshold for mining. In order to mine a block successfully, one has to produce some value x, which after hashing results in a number that is lower than this target. Concisely:

𝐻(𝑥)<𝑡𝑎𝑟𝑔𝑒𝑡

This value x generally represents the block itself and some unique value (called a nonce) that the miner chooses. The latter is essentially like a lottery ticket - a miner continues testing different unique values (nonce) until he comes with the right one. If some other miner succeeds, then everyone moves to the next block and try again - it’s a race.

The hash target is adjusted every couple of weeks on average to ensure that it’s difficult enough to mine new blocks. This is generally done by lowering the target, since the probability of finding a smaller hash decreases with the size of the target.

🔗 Source: investopedia.com

Q24: What Is a Proof of Stake?

Topic: Blockchain
Difficulty: ⭐⭐⭐⭐

**Proof of Stake (PoS) **concept states that a person can mine or validate block transactions according to how many coins he or she holds. This means that the more Bitcoin or altcoin owned by a miner, the more mining power he or she has.

In PoS, each validator owns some stake in the network, ether in the case of Ethereum, that they bond. Bonding stake means you deposit some money into the network, and in some sense use it as a collateral to vouch for a block. In PoW you know a chain is valid because lots of work is behind it, while in PoS you trust the chain with the highest collateral.

🔗 Source: investopedia.com

Q25: What is the difference between PoW and PoS?

Topic: Blockchain
Difficulty: ⭐⭐⭐⭐

Proof of Work (POW) requires huge amounts of energy, with miners needing to sell their coins to ultimately foot the bill; Proof of Stake (PoS) gives mining power based on the percentage of coins held by a miner.

Proof of Stake (POS) is seen as less risky in terms of the potential for miners to attack the network, as it structures compensation in a way that makes an attack less advantageous for the miner.

🔗 Source: investopedia.com

Q26: What is off-chain transaction?

Topic: Blockchain
Difficulty: ⭐⭐⭐⭐

On-chain, transactions are considered to be valid when a blockchain reflects the transactions on the distributed public ledger. This includes authentication and validation of a transaction by a defined number of participants. The different details of a transaction are recorded on the block and distributed to the entire blockchain making the transaction irreversible since it can’t be altered.

An off-chain transaction is the movement of value outside of the block chain. Basically there would be no record of the transaction at all in the public blockchain just shift who owns what amount of coins. This is happening for saving time rather than waiting for miners to confirm a valid transaction in Blockchain.

🔗 Source: etorox.com

Q27: Why is Git not considered a “block chain”?

Topic: Blockchain
Difficulty: ⭐⭐⭐⭐⭐

The reason why Git and blockchains appear similar is because they are both using merkle trees as their underlying data structure. But unlike cryptocurrency blockchains; git doesn't have a p2p trustless consensus mechanism.

In a blockchain implementation, every block is verified independently multiple times before it is added to the blockchain. On the other hand, many git projects do not require independent verification and, when they do, they only require one person to sign off on a change before it is committed to the repository. Hence, with at most one point of validation that you must trust, git breaks one of the core tenets of blockchain technology.

You can rewrite git history. In blockchains, the ledger is an immutable history.

🔗 Source: stackoverflow.com

Q28: What are miners really solving?

Topic: Blockchain
Difficulty: ⭐⭐⭐⭐⭐

As with mining, what are miners really solving? I read they are solving hashes, but what does that really mean.


Miners try to find a random nonce (a little random data) that goes into a block and makes the block have a (SHA256) hash that (in binary) starts with a certain amount of 0's. The more zeroes the more rare hash is. A good hash' outcome is not predictable, and so you have to try a lot of times to find a good nonce.

Basically is a description of the global, statistical gamble which is played every 10 or so minutes. The interval of the game is controlled by the difficulty which says how many "hashes" are needed per interval. In other words, the difficulty and target define the "odds of the house" against your chance of getting a winning SHA hash. The nonce is the "scratch-off" area.

So at the end of the day, all a miner does is:

  • Take a block header as input
  • Change the Nonce
  • Test if the Block Header hash is less than the Target. If it is, you win.
  • Go to step 2 (or go to step 1 if someone else won the block)

🔗 Source: stackexchange.com

Q29: Is it possible to brute force bitcoin address creation in order to steal money?

Topic: Blockchain
Difficulty: ⭐⭐⭐⭐⭐

It is possible to brute force some Bitcoin addresses, because some people generate their private keys in an insecure manner using "deterministic wallets". A deterministic wallet is a system of deriving keys from a single starting point known as a seed. The seed allows a user to easily back up and restore a wallet without needing any other information and can in some cases allow the creation of public addresses without the knowledge of the private key. Any (non-zero) 32 bytes can be a private key. So running sha256 over a passphrase gives an apparently random, but brute force-able private key.

Take sha256("sausage") for instance:

$ echo -n 'sausage' | sha256sum
30caae2fcb7c34ecadfddc45e0a27e9103bd7cfc87730d7818cc096b1266a683  -

Load up bitaddress and paste that private key into the 'wallet details' tab to get the corresponding Bitcoin address, then look it up on blockexplorer:

$ GET http://blockexplorer.com/q/getreceivedbyaddress/1TnnhMEgic5g4ttrCQyDopwqTs4hheuNZ; echo
0.01000000

and you'll see that the address held one bitcent for about 2 days in February 2012.

In reality, Bitcoin addresses are actually the 256-bit SHA hash of an ECDSA public key, so any vulnerabilities in those algorithms would constitute a vulnerability in bitcoin itself. Realistically, however, breaking this level of encryption requires a huge amount of processing power. Coincidentally it requires precisely the same kind of processing power that bitcoin mining requires and in almost every scenario it would be massively more profitable to mine than to hack.

🔗 Source: bitcoin.stackexchange.com

Thanks 🙌 for reading and good luck on your interview!
Please share this article with your fellow devs if you like it!
Check more FullStack Interview Questions & Answers on 👉 www.fullstack.cafe

Top comments (2)

Collapse
 
jpantunes profile image
JP Antunes

This isn't very good, sorry Alex.

Q1 - a blockchain is a data structure that stores messages (blocks) sequentially using
the previous block's hash as a back link, so it resembles a linked list but backwards / “previous block hash" instead of next block pointer

A distributed ledger is an user level application that can use a blockchain to manage its data

Q2 - State, a state-transition function and messages

Q3 - that's an ok answer but ...

Q4 - ok

Q5 - the purpose of a node is to keep a local copy of the blockchain. it also allows for greater privacy when actually using a blockchain

Q6 - ok

Q7 - ok

Q8 - incorrect!!! Tokens and coins are not required to use a blockchain since any type of message can be sent and cause a change in state, it really depends on the state transition function used

Q9 - ok but... a merkle root is 32 bytes and it can represent anything from 0 to N bytes of data and not once is the relation to binary trees mentioned.

Q10 - ok but how about : data integrity, compression and efficiency

Q11 - nodes access the network directly and listen to messages, process those messages and brodcast new messages. there are different types of nodes in different blockchain implementations but these 3 are common among all of them

Q12 - the record of blocks in a chain is immutable because every new block relies on the previou block's hash. This means that due to how hashing works, any change to a historic block would break this chain. Ie, form the last block, you cannot travel back to the genesis block. There are cases where more than one chain can be fully valid and have different transaction histories which is where the consensus algorithm comes in.

Q13 - this is related to the proof of work algorithm and is a way of adjusting the block production times and ensure that enough work has been put into generating a new block that it is safe to trust it

Q14 - because this creates scarcity and is a driver for price growth. public blockchains are expensive to maintain and if the network token ("coin") isn't valued then no one will maintin it...

Q15 - ok but how about: it's just a regular app with access to a blockchain network and smart contracts. It can be just a React front end to a voting smart contract or it can be a whole business like Augur for instance.

Q16 - trapdoor functions are not visible or used in the blockchain, they are secp256k1 cryptographic primitives and at best it's used in a blockchain to derive an address from a private key. Mind you that hashing is not a trapdoor function because its not reversible while deriving a priv key from a pub key can be done (if one has unlimited computing power)

Q17 - no, no and no. changes in state can happen without tokens or coins being involved. see a multi-sig wallet for instance.. it collect signatures before any coin is used!

Q18 - true for full nodes but doesn't explain how light nodes can also trust the chain of blocks they are following

Q19 - ok

Q20 - a smart contract is a set of instructions or algorithms that are hosted and ran in a blockchain. they are not trustwhorty in and on themselves, ie a bad actor can make a bad contract that does bad things

Q21 - ok but...

Q22 - ok but...

Q23 - :-( this is bad! not only does it misrepresent difiiculty target calculation but also does a terrible job with the nonce!!!

Q24 - :-( this is worse. PoS means that the state transition function is controled by a semi-closed group who must put a large amount of money at stake in order to be trusted to produce or validate blocks. Modern PoS designs include the concept of slashing which is like a penalty applied to a validator who accepts bad blocks or bad transactions so it would be like a PoW miner having their rig explode.

Q25 - ok but... PoW is fully trustless and PoS introduces some trust requirements, it nothing more then in the staking contract not having any bugs

Q26 - it's all and every transaction that happens outside a blockchain but whose proof (like a link to a receipt or its hash) is stored on-chain

Q27 - ok but.. you can also rewrite blockchain history (ie: long range attack)

Q28 - ok

Q29 - ok but..

Collapse
 
elmoktadi profile image
Tarik El Moktadi

Very helpfully thanks