Blockchain Interview Questions

Introduction

The demand for Blockchain developers increases, so in this post, I’m trying to set some of the most common blockchain interview questions and their answers to help developers pass the blockchain interviews. Blockchain interview questions can be sometimes tricky, so I tried to set some of the tricky and straightforward questions in the post.

Blockchain is a shared ledger or database that is distributed over different nodes worldwide. The data on the blockchain is stored in blocks. One key difference between a typical database and a blockchain is how the data is structured. A blockchain collects information together in groups, known as blocks. Blockchain will change technology and the world as what internet did. Because many benefits of blockchain, the blockchain development job becomes one of the most important jobs and there is much demand for blockchain developers worldwide. This post provides a list of blockchain interview questions and answers that can help you in the blockchain interview journey.

Blockchain history

In the early era of the internet (web 1.0) there was mainly static data, where the internet users can just read the static information with interactions. In 2004 the term “Web 2.0” came to prominence, describing an evolution of the web toward user-generated content, responsive interfaces, and interactivity. Web 2.0 is not a technical specification, but rather a term describing the new focus of web applications. The concept of DApps is meant to take the World Wide Web to its next natural evolutionary stage, introducing decentralization with peer-to-peer protocols into every aspect of a web application. The term used to describe this evolution is web3, meaning the third “version” of the web. First proposed by Dr. Gavin Wood, web3 represents a new vision and focus for web applications: from centrally owned and managed applications, to applications built on decentralized protocols.

What are the types of blockchains?

  • Public
  • Consortium
  • Private

What are the differences between blockchain and traditional databases?

  • Blockchain is only applying insert transactions, traditional databases can apply CRUD (create, read, update and delete)
  • Blockchain uses majority consensus, whereas traditional databases use distributed transactions (commit and rollback) mechanism.
  • The blockchain block data is replicated on every network peer, while the traditional database is saved on a central server or using the master-slave mechanism.

What are the private and public keys?

The private and public keys are used in security in general where the private key keep secure and safe but the public key can be shared with others to receive assets. The private and public keys are used in cryptography ( encryption and decryption) to secure the data. In the blockchain, the public key is used to send assets into a wallet. The private key is used to verify transactions and prove the ownership of the address.

What is the Merkle tree?

Merkle Tree also known as ‘hash tree’ is a data structure in cryptography in which each leaf node is a hash of a block of data, and each non-leaf node is a hash of its child nodes. A hash tree allows efficient and secure verification of the contents of a large data structure. A hash tree is a generalization of a hash list and a hash chain.

  Merkle tree

Merkle tree (hash tree)

As it is illustrated in the above example, Merkle tree leaf nodes (L1, L2, …) represent the data blocks. The hashes 0-0, 0-1, 1-0, etc. represent the hash values of the data blocks (L1, L2, etc). Hash 0 represents the hash of both Hash 0-0 and Hash 0-1, also Hash 1 represents the hash of both Hash 1-0 and Hash 1-1.

What are the differences between proof-of-work (POW) and proof-of-stake (POS)?

POW and POS are different ways for a cryptocurrency to reach a consensus about which blockchain should be the “real” one. The Proof of Work allows protection of the integrity of the blockchain, by making certain that no one can tamper with old blocks. However, it is computationally intensive and therefore expensive to ‘mine’ one block, which means that miners are incentivized to form pools and share their rewards. The Proof of Work (POW) uses a competitive validation method to confirm transactions and add new blocks to the blockchain. Proof of Stake (POS) uses randomly selected miners to validate transactions.

What is Double Spending?

Double spending happens when a digital asset can be spent twice or more as the token is digital data that can be cloned. One of the main strengths areas in blockchain technology is that blockchain tries to prevent double-spending by using the proof of work or proof of stake principles.

What is the consensus algorithm? give some examples.

  1. Proof-of-work
  2. Proof-of-stake
  3. Delegated proof-of-stake
  4. Proof-of-elapsed time
  5. PBFT (Practical Byzantine Fault Tolerance)

What is Ethereum?

Ethereum is a global, decentralized computing infrastructure that executes software programs called smart contracts (check below) at Ethereum virtual machine (EVM). It uses the blockchain networks to synchronize and store the system’s state changes, along with a cryptocurrency called ether to meter and constrain execution resource costs. In contrast to Bitcoin, Ethereum is designed to be a general-purpose blockchain that is able to execute business in the smart contract, while Bitcoin is a digital currency payment network.

What is solidity?

Solidity is an object-oriented programming language that is used to build blockchain smart contracts. Below is an example of a smart contract built using solidity.

// An example of a simple smart contract written in solidity
pragma solidity 0.8.4;

contract CustomContract {
  // Public variables (make getters with "public")
  uint256 public customNumber;
  
  // A function to change number by anyone. Must not be same number
  // If it is, it will fail with message "They are the same number"
  function changeNumber(uint256 newNumber) public {
    require(customNumber != newNumber, "They are the same number");
    customNumber = newNumber;
  }
  
  // This is how to return a public variable. This is already set with public
  // however for non public variables, this is how we create them
  function getTheCustomNumber() public pure returns(uint256) {
    return customNumber;
  }
}

An example of a simple smart contract written in solidity

What is the smart contract?

The smart contract is the set of rules that govern and control how the accounts will integrate with each other. Below is an example of a smart contract.

// an example of a smart contract

//SPDX-License-Identifier: MIT
pragma solidity ^0.8.8;

contract CustomerContract {
    // The Global public variables (make getters with "public")
    address public owner = msg.sender;
    uint256 public publicNumber;

    // Private variables
    uint256 private currentNumber;
    string private message;

    // A function to change the current number by any uint256 value. The stored number and the new number
    // should not be the same, If it is, it will fail with message "Identical numbers"
    // If the person who ask to change the number is not the contract owner, require function will fails
    // With returning error message "Only the owner who can update"
    function changeNumber(uint256 number) public {
        require(currentNumber != number, "Identical numbers");
        require(msg.sender != owner, "Only the owner who can update");

        currentNumber = number;
    }

    // This is how to return the current number.
    function getCurrentNumber() public view returns (uint256) {
        return currentNumber;
    }
}

Smar contract sample

What is the NFT?

A non-fungible token (NFT) is financial security consisting of digital data stored in a blockchain, a form of a distributed ledger. Non-fungible means it can’t be replaced. For example, if you have one USD, you can replace it with any other USD. NFT is not the same case which means if you have an NFT no one can have the same NFT unless you transfer the ownership of your own NFT to a new person. In other words, NFT is a digital asset that can’t be replaced/traded with another equivalent value.

Conclusion

The blockchain developer job is very required in the current days and the demand for blockchain developers increases. In this post, I provide a list of blockchain interview questions that can help you with the blockchain interview questions. You can find sample source codes on Github Enjoy…!!!

I can help you to build such as software tools/snippets, you contact me from here

 

2 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *