How I learned fundamentals of blockchain with ChatGPT

Jananadi
10 min readJan 19, 2023

Recently, I was offered a position at a blockchain company 🎉. However, I felt bit rusty when I answered the questions at the interview. So before I start the new position, I wanted to revise my knowledge on blockchain technology and I asked ChatGPT some questions to save time.

In this article I’m listing the questions I asked from ChatGPT and the answers it gave me.

Q1: What are the fundamental concepts of blockchain technology?

A: The fundamental concepts of blockchain technology include:

  1. Distributed ledger: A blockchain is a decentralized and distributed digital ledger that records transactions across a network of computers.
  2. Immutable: Once data is recorded on a blockchain, it cannot be altered or tampered with.
  3. Cryptography: Blockchain uses advanced cryptographic techniques to secure and validate transactions on the network.
  4. Consensus: The process by which all participants in a blockchain network agree on the current state of the ledger.
  5. Smart contracts: Self-executing contracts with the terms of the agreement written into code.
  6. Decentralization: There is no central authority controlling the network and all the participants have equal power over the blockchain.

Q2: What is Consensus in a blockchain?

Consensus mechanisms are the algorithms used by blockchain networks to achieve agreement on the state of the ledger among all participating nodes. The consensus mechanism is a crucial part of blockchain technology as it ensures that all transactions on the network are valid and that the same copy of the blockchain is maintained by all nodes.

Here are some of the most popular consensus mechanisms used in blockchain technology:

  1. Proof of Work (PoW): PoW is the original consensus mechanism used by Bitcoin. It involves nodes (also known as miners) competing to solve complex mathematical problems. The first node to solve the problem gets to add the next block to the blockchain and is rewarded with a certain amount of cryptocurrency.
  2. Proof of Stake (PoS): PoS is an alternative consensus mechanism to PoW. Instead of requiring nodes to solve complex mathematical problems, it requires nodes to hold a certain amount of cryptocurrency (their “stake”) in order to participate in the validation process. The more cryptocurrency a node holds, the more likely it is to be chosen to validate the next block.
  3. Delegated Proof of Stake (DPoS): DPoS is a variation of PoS. In this mechanism, token holders vote for a certain number of “delegates” or “witnesses” who are responsible for validating transactions and maintaining the blockchain.
  4. Practical Byzantine Fault Tolerance (PBFT): PBFT is a consensus mechanism used in permissioned blockchain networks. It is based on the concept of “virtual voting” where nodes communicate with each other to reach consensus on the state of the ledger.
  5. Federated Byzantine Agreement (FBA): FBA is a consensus mechanism used in permissioned blockchain networks. It is based on the concept of “quorum slices” where nodes only need to reach agreement with a subset of the network in order to validate a transaction.
  6. Hybrid consensus: This is a combination of different consensus mechanisms to provide the best features of each one, for example, a combination of PoW and PoS.

It’s important to note that each consensus mechanism has its own trade-offs and advantages, and the choice of which one to use depends on the specific use case and requirements of the blockchain network.

Q3: Where is distributed ledger of a blockchain is stored?

A: A distributed ledger of a blockchain is stored in a computer network made up of multiple nodes, or computers. Each node in the network has a copy of the blockchain’s ledger, and every time a new transaction is added to the blockchain, each node updates its copy of the ledger. This means that the ledger is distributed across the entire network, rather than being stored in a central location. The ledger is also secured using cryptography, which helps to ensure that it is tamper-proof and can only be updated by the network’s consensus mechanism.

Q4: What is a DApp?

A: A DApp (Decentralized Application) is a software application that runs on a blockchain network. Unlike traditional applications that are controlled by a central authority, a DApp is decentralized and runs on a peer-to-peer network of computers.

DApps have the following characteristics:

  1. Open-source: The code of a DApp is open-source and available for anyone to review and contribute to.
  2. Decentralized: A DApp is decentralized, meaning that it is not controlled by a single entity or organization.
  3. Blockchain-based: A DApp runs on a blockchain network and uses smart contracts to execute its functions.
  4. Incentivized: DApps often use tokens or other forms of cryptocurrency to incentivize users to contribute to the network and maintain its security.
  5. Autonomous: DApps are autonomous, meaning that they can operate without the need for intermediaries or intermediaries approval

Some examples of DApps are Decentralized exchanges, prediction markets, social networks, games, and identity management systems.

Q5: What is the difference between a banking app and a DApp?

  • A DApp is a type of application that runs on a blockchain network, while a traditional banking app is a type of application that runs on a centralized server.
  • Underlying architecture: A dApp is built on a decentralized, distributed network, such as a blockchain, which means that it is not controlled by any single entity. Instead, it is maintained and operated by a network of users. A banking app, on the other hand, is built on a centralized server and is controlled by a single entity, typically a bank.
  • Level of security and transparency provided by the two types of apps. A dApp is more secure because it is built on top of a blockchain, which is inherently secure and tamper-proof. A banking app, on the other hand, may be more vulnerable to hacking and other types of cyber attacks because it is built on a centralized server. Additionally, dApps usually provide a higher level of transparency because all transactions are recorded on a blockchain and can be easily tracked and audited, while traditional banking apps may not provide the same level of transparency.
  • DApps are open-source, meaning anyone can view and contribute to its development, while banking apps tend to be closed-source and developed by specific institutions.

Q6: Write a simple blockchain program using Javascript

const SHA256 = require('crypto-js/sha256');

class Block {
constructor(index, timestamp, data, previousHash = '') {
this.index = index;
this.timestamp = timestamp;
this.data = data;
this.previousHash = previousHash;
this.hash = this.calculateHash();
}

calculateHash() {
return SHA256(this.index + this.previousHash + this.timestamp + JSON.stringify(this.data)).toString();
}
}

class Blockchain {
constructor() {
this.chain = [this.createGenesisBlock()];
}

createGenesisBlock() {
return new Block(0, "01/01/2021", "Genesis block", "0");
}

getLatestBlock() {
return this.chain[this.chain.length - 1];
}

addBlock(newBlock) {
newBlock.previousHash = this.getLatestBlock().hash;
newBlock.hash = newBlock.calculateHash();
this.chain.push(newBlock);
}

isChainValid() {
for (let i = 1; i < this.chain.length; i++) {
const currentBlock = this.chain[i];
const previousBlock = this.chain[i - 1];

if (currentBlock.hash !== currentBlock.calculateHash()) {
return false;
}

if (currentBlock.previousHash !== previousBlock.hash) {
return false;
}
}
return true;
}
}

let blockchain = new Blockchain();

blockchain.addBlock(new Block(1, "01/02/2021", { amount: 4 }));
blockchain.addBlock(new Block(2, "01/03/2021", { amount: 10 }));

console.log(blockchain);
console.log('Is blockchain valid? ' + blockchain.isChainValid());

Above program defines two classes: Block and Blockchain. The Block class is used to create individual blocks, which will be added to the blockchain. Each block has an index, timestamp, data, and a hash. The hash is created by taking a SHA-256 hash of the block’s index, timestamp, data, and previous hash. The Blockchain class is used to create the blockchain itself. It contains an array of blocks and has methods for creating the genesis block, getting the latest block, adding new blocks to the chain and checking the validity of the chain.

In this example, the Blockchain class is initialized with a single genesis block, and then two new blocks are added to the chain. The final output is the entire blockchain, including all of its blocks and their properties, and a message indicating if the blockchain is valid or not.

Q7: What are the differences between Bitcoin and Ethereum?

  1. Purpose: Bitcoin was created as a digital alternative to traditional fiat currencies, with the primary goal of enabling peer-to-peer electronic transactions. Ethereum, on the other hand, was developed as a platform for decentralized applications and smart contracts.
  2. Token: Bitcoin has a single token (BTC) that is used as a form of digital currency. Ethereum, on the other hand, has its own digital currency (ETH) but also supports the creation and execution of smart contracts and decentralized applications using a variety of tokens.
  3. Mining: Both Bitcoin and Ethereum use a proof-of-work (PoW) consensus mechanism, but Ethereum is planning to move to a proof-of-stake (PoS) mechanism. PoS is more energy efficient compared to PoW
  4. Block time: The time it takes for a new block to be added to the blockchain is different. Bitcoin’s block time is 10 minutes, while Ethereum’s is 15 seconds.
  5. Scalability: Bitcoin’s scalability is limited by the block size which is currently at 1mb, Ethereum’s scalability is limited by the amount of computations that can be done in a single block, which is currently at around 15 transactions per second.

Q8: What are Plasma and Optimistic rollup in Ethereum?

Plasma and Optimistic Rollup are both layer-2 scaling solutions for the Ethereum network.

Plasma is a framework for building scalable, decentralized applications on top of the Ethereum blockchain. It allows for the creation of child chains, or sidechains, that can handle a large number of transactions without putting a strain on the main Ethereum blockchain. These child chains are connected to the main Ethereum blockchain through a smart contract, which allows users to move assets between the child chain and the main chain in a secure and transparent manner.

Optimistic Rollup is a type of layer-2 scaling solution that uses a smart contract on the main Ethereum blockchain to keep track of the state of a separate, off-chain rollup chain. This rollup chain can process a large number of transactions in parallel, which increases the overall throughput of the Ethereum network. The smart contract on the main Ethereum blockchain serves as a “safety net” that can be used to validate and correct any errors that may occur on the rollup chain. This allows for high-performance and low-cost transactions while still maintaining security and trustlessness of the Ethereum blockchain.

In summary, both Plasma and Optimistic Rollup aim to increase the throughput and lower the cost of transactions on the Ethereum network by moving some of the computation off the main blockchain, allowing for more transactions to be processed in parallel.

Q9: What are layer-2 networks in blockchain?

Layer-2 networks in blockchain refer to scaling solutions that operate on top of a blockchain’s underlying protocol, or layer-1. These solutions are designed to increase the throughput and lower the cost of transactions on a blockchain network, without changing the underlying protocol.

Layer-2 networks can take different forms, but they all aim to alleviate the scalability issues that many blockchain networks face by moving some of the computation off the main blockchain and into a separate layer. This allows for more transactions to be processed in parallel, which increases the overall throughput of the network.

Examples of Layer-2 solutions include:

  • Plasma, which allows for the creation of child chains, or sidechains, that can handle a large number of transactions without putting a strain on the main blockchain.
  • State Channels, which allow for off-chain transactions between parties, with the option to settle on-chain if a dispute arises.
  • Optimistic Rollup, which uses a smart contract on the main blockchain to keep track of the state of a separate, off-chain rollup chain that can process a large number of transactions in parallel.
  • Sharding, which allows for the partitioning of the blockchain into smaller chunks, or shards, which can be processed in parallel.

Layer-2 solutions can be implemented on different blockchain protocols, and more than one can be used at the same time. It is worth noting that Layer-2 solutions are not a replacement of the underlying protocol, but a complementary solution that aims to improve the scalability, security and user experience of the blockchain network.

Q10: What are the trends in blockchain technology

Blockchain technology is a rapidly evolving field, and new trends and developments are emerging all the time. Some of the current trends in blockchain technology include:

  1. Decentralized Finance (DeFi): Decentralized finance (DeFi) refers to a new class of financial applications built on blockchain technology, which allow for peer-to-peer transactions without intermediaries. DeFi includes lending, borrowing, trading, and other financial services.
  2. Non-Fungible tokens (NFTs): NFTs are unique digital assets that represent ownership of a digital item such as artwork, music, videos, etc. They are built on blockchain technology and are becoming increasingly popular in the art and collectibles market.
  3. Enterprise blockchain: More and more companies are turning to blockchain to improve efficiency, security, and transparency in their business processes. Sectors such as supply chain management, logistics, healthcare, and finance are particularly interested in using blockchain technology.
  4. Interoperability: Interoperability is the ability of different blockchain networks to communicate with each other. This is becoming increasingly important as different blockchain platforms are being developed for different use cases and it is important for them to be able to communicate and transact with each other.
  5. Privacy and Security: Blockchain technology is known for its security and transparency features, but privacy concerns are also becoming more prominent. As a result, there is a growing interest in developing privacy-enhancing technologies such as zero-knowledge proofs (ZKPs) and ring signatures.
  6. Hybrid Blockchain: The integration of public and private blockchain is becoming a trend, allowing companies to take advantage of the security and transparency of public blockchain while keeping sensitive data on a private blockchain.
  7. Edge and IoT: The integration of blockchain with the Internet of Things (IoT) is becoming increasingly popular. The use of edge computing and blockchain together can create a secure and decentralized system for collecting and processing IoT data.
  8. Cloud-based Blockchain: The use of cloud-based blockchain solutions is becoming more popular as it allows for easy deployment and scalability of blockchain applications.

Conclusion

ChatGPT was comprehensive on all the answers it provided and was nice enough to explain even the code it wrote for me.

Overall, it was an fruitful study session with no distractions since I only asked what i was really curious about and I could read the answer right away.

Although, knowing which questions to ask seems immensely important, and it might help to be more efficient in your quest.

Happy reading and happy studying! 💪🏼

--

--

Jananadi

Trying to build cool things for the web 🦹🏻‍♀️