Category: Blockchain Basics

  • What are Testnets

    A mainnet is the main blockchain network on which cryptocurrencies are transacted. Whereas a testnet is a replica of the mainnet with reduced security and reduced network capacity.

    Why create a separate Testnet?

    Testnets are akin to sandboxes in software development. They are used to test a feature which is not yet implemented on the main blockchain. These testnets are a way to test blockchain features and even DApps that are about to go live on the mainnet.

    A testnet is a cheaper way to simulate the working of the mainnet because of several reasons.

    The first reason is that the testnet requires much lesser security than the mainnet. For example,. in Ethereum the mainnet has around 900k validators while the Goerli testnet has only aboout 1800 validators.

    A second reason is testnet cryptocurrencies such as Sepolia ETH or Goerli ETH are available for free and therefore are worthless. Also Testnet ETH cannot be converted into Mainnet ETH.

    #NOTE: During shortages, Gloerli ETH happens to be sold to the developers who need it to test their Dapps.

    List of Ethereum Testnets

    Only Ethereum testnets bear a different name because Ethereum has more than one testnet. Another testnet with its own unique name is Polygon’s Mumbai.

    In other cases, the testnet bears the same name as the mainnet with just the word “testnet” suffixed to it.

    1. Goerli – deprecated
    2. Sepolia
    3. Holesky
    4. Rinkeby -Sunsettted
    5. Kovan – Sunsetted

    #NOTE: Sunsetted means the project is permanently shut down. Deprecated means it is out of use and could be soon shut down.

    How to Add a Testnet to MetaMask?

    Testnets have to be added as custom networks in MetaMask.

    Adding a Custom Network on MetaMask
    Adding a Custom Network on MetaMask

    Currently only Sepolia and Holesky testnets are active in Ethereum. Others have either been deprecated or sunsetted.

    Ethereum – Sepolia Testnet

    To add Sepolia Testnet to MetaMask, click on impport token and then select custom import. Add the following details to add the testnet.

    • Network Name: Sepolia Test Network
    • New RPC URL: https://sepolia.infura.io/v3/
    • Chain ID: 11155111
    • Currency Symbol: SepoliaETH
    • Block Explorer URL: https://sepolia.etherscan.io

    Ethereum – Holesky

    • Network Name: Holesky
    • New RPC URL: https://rpc.holesky.ethpandaops.io
    • Chain ID: 17000
    • Currency Symbol: ETH
    • Block Explorer URL: https://dora.holesky.ethpandaops.io/

    Polygon Testnet – Mumbai

    • Network Name: Mumbai Testnet
    • New RPC URL: https://rpc-mumbai.maticvigil.com/
    • Chain ID: 80001
    • Currency Symbol: MATIC
    • Block Explorer URL: https://polygonscan.com/

    Frequently Asked Questions

    How do I get Testnet ETH for Ethereum?

    You can get testnet ETH from the following faucets:
    1. Goerli Faucet
    2. Moralis Web3

    How do I start developing on Ethereum Testnet?

    You need to learn Solidity to create smart contracts and basic programming to design the frontend of the DApp on Ethereum.

    After that you can add some testnet ETH to your wallet. Make sure not to send real ETH to testnet otherwise it will lead to a loss.

    Develop a smart contract using Remix IDE or any other Solidity IDE.

    Go to Goerli.Net or any other testnet terminal to deploy your DApp.

    Do all blockchains have Testnet?

    Yes, a testnet is necessary to test the blockchain features. Therfore, most blockchains do have an active testnet.

  • What is Sharding in Blockchain?

    Sharding is the process of breaking a blockchain’s consensus mechanism(total no. of validators) into smaller units called “Shards”. Each shard has its own unique set of validators. This increases the capacity of a blockchain by the same multiple as the number of shards.

    Listen to this article as an Audio Podcast.

    Definition of Sharding

    Sharding can be defined as dividing the entire set of validators of the blockchain into smaller units. These smaller units are called as shards. Each shard has its own unique set of validators.

    The Need for Sharding

    The current methods of scaling poses the risk of off-chain tampering in ZK rollups as well as inclusion of undetected tampering in OP rollups.

    Currently, these two scaling methods are at work to scale Ethereum.

    • Scaling methods like Optimistic Rollups use call-data to store transaction records on Ethereum blocks. Call data is a empty space in a block that is not verified through consensus mechanism. However it makes the block heavier.
    • Zero Knowledge Rollups, another scaling solution verifies transactions on a second blockchain and stores the summary of these transactions as a single transaction on Ethereum. If the final state change after the transaction is as expected, the summary is considered as valid.

    However, these methods are not the final solution as Ethereum will forever depend on them to scale up. Also there is a possibility that someday one of them might ultimately replace ethereum.

    Also, the number of validators on Ethereum (more than 900k) will not be efficiently utilized. Dividing them into independent groups make much more sense as blockchains even with small groups work fine in Proof of Stake systems.

    1. Algorand has 110 validators
    2. Shibarium has 100 slots for validators
    3. Polygon has 100 validators

    How Sharding Works?

    In a blockchain, consensus is achieved after all or maximum number of validators verify the transaction.

    How Sharding is supposed to work in Ethereum
    Sharding in Ethereum

    Now, for big blockchains, like Ethereum, which has over 900k validators, running each transaction through all the validators does not make much sense. Blockchains can be even secured with lesser number of validators.

    So, what sharding proposes is dividing these 900k validators into 64 groups (via the Danksharding Proposal). Each group will have more than 14k validators which is enough to secure transactions and prevent 51% attacks.

    Since each shard will be able to act independently, each of them can add blocks to the blockchain. Therefore, now the speed of Ethereum can be 64 times higher (theoretically) than the current speed of 10-15 transactions per second.

    Sharding vs Proto-Dank Sharding

    In sharding the total no of validators are divided into independent groups each of which is able to add blocks to the blockchain.

    However, this is not easy to implement in Ethereum considering its security and size. Therefore, the Ethereum Improvement Proposal (EIP-4844) seeks to implement another technique called as proto-dank sharding.

    Proto Dank Sharding

    Proto-Dank sharding is the implementation of Sharding on the Ethereum blockchain but in a way which is feasible right now.

    It was named after two Ethereum researchers Protolambda and Dankrad Feist.

    It proposes to add “blobs” to the Ethereum blocks which can store transactions similar to call data in optimistic rollups. Unlike call data which stays on the blockchain forever, these blobs can be deleted after 3 months which is enough for finality of transactions.

    Since, they are not processed by the EVM, their

    The current number of validators are not split in Proto-Dank sharding.

  • Finality in Blockchain

    Finality refers to the situation where a blockchain transaction is permanent and cannot be reversed. Finality is confirmed in a blockchain with its consensus mechanism where each validator validates the transaction and this contributes to finalize it.

    Finality is important on a blockchain because it makes the latter immutable and secure. If a transaction can be changed at any time, then there could be a loss of funds.

    Why is Finality Necessary?

    To Make Sure You Own 100% of Your Funds

    Let me explain it to you with an example. Suppose you run a grocery shop and get payments using Google Pay. Think about a customer who buys from your shop, pays with Google Pay and leaves. After some time, you notice that they have reversed the transaction and your money is now gone.

    How would you feel?

    This is the exact reason why finality is important. It is to make sure that whoever sends or receives crypto has complete control over their funds.

    Without finality, it would be impossible to have full control over your funds.

    Finality also Prevents Double Spending

    Double spending is a way where a single crypto token could be spent more than once. This was the reason why initial cryptocurrencies like Bit Gold failed.

    To eliminate double spending, it is made sure that after every transaction, the sender’s wallet is deducted and the receiver’s wallet is credited. This is done through a process called a consensus mechanism.

    • Each validator confirms that a certain transaction is genuine.
    • After confirmation, the validator adds the block to a blockchain.
    • Users can only their received funds once a certain number of blocks have passed after they have received crypto.

    Finality of Different Blockchains

    Each blockchain has a certain number of blocks/no of confirmations which must happen to finalize a transaction.

    Below is the number of confirmations that is used by Coinbase to add finality to their transactions.

    • Bitcoin – 2 Confirmations (6 Confirmations are very secure)
    • Ethereum – 12 Confirmations
    • Litecoin – 5 Confirmations

    Factors Affecting Finality

    Although there are several factors that affect latency, here are the top most ones.

    Hard Forks

    Hard Forks are changes in the blockchain which make it difficult for blockchains to recognize or accept transfers from their pre-fork blockchain.

    CASE – The Ethereum DAO Attack

    The most high-profile case where I have witnessed hard forks negatively affecting blockchain transactions was the Ethereum DAO Attack. The attacker stole 5% of the total ETH supply which was 1/3rd of the DAO’s value. The community proposed to rollback the hacker’s transaction through a hard fork. This led to a disagreement between community members.

    Eventually, the disagreement to do a hard fork led to the creation of Ethereum Classic by those who opposed the hard fork.

    Network Latency

    Network latency causes a delay in communications between validators which makes the blockchain slower and delays block creation.

    51% Attacks

    Attacks where the hackers steal more than 50% of the controlling power of the blockchain are called as 51% attacks. Here, they change the history of the blockchain by removing transactions from it in a way that benefits them.

    For example an attacker swaps 500 ETH with Shiba Inu with a user through two transactions. He then does a 51% attack to reverse the transaction. Here, he gets to keep both the Shiba Inu as well as the Ethereum.

    Types of Finality

    • Probabilistic Finality: Here, the likelihood of reversing a transaction decreases as time passes.
    • Economic Finality: In this case, it gets more and more expensive to reverse a transaction because if it is reversed the validator will lose stake.
    • Instant Finality: A fast blockchain leverages security with speed to provide finality in a very short time, say 1 second.
    • State Finality: Some blockchains like Optimism use periodic snapshots to record the state of the blockchain transactions. Once a state change has been recorded, it is impossible to reverse these transactions.
  • Mining Difficulty in Blockchain: Formula, Adjustment and Usage

    In crypto, Difficulty refers to how hard is it to find the nonce value of a transaction. If the difficulty is high, it would mean that finding the hash requires more computing. The parameter is used to prevent too many miners clogging the network.

    Also difficulty ensures that the space between production of two blocks remain consistent. This brings stability into the blockchain as all blocks will now be equally sized.

    What is Difficulty?

    Difficulty is the computational effort required to find the nonce value of a transaction in a blockchain. Nonce values are those unique numbers which are added to every transaction and are a result of hashing the following values:

    1. Hash of the previous block
    2. Transaction amount
    3. Sender and Receiver addresses

    During the calculation of nonce value, one must increment a value and keep repeatedly hashing the data till the resulting hash value is equal to the network’s hash difficulty.

    Difficulty is used to Control Miner/Validator Population

    Difficulty of a blockchain increases with the number of miners or validators because there is a limit on the number of new blocks that can be produced in a given time.

    Mining difficulty is adjusted after a certain period. For Bitcoin, the mining difficulty is adjusted once every 2016 blocks.

    If the number of new blocks is not controlled than an increased number of new miners will produce a high number of blocks. Since each block in a blockchain gets you some rewards (newly minted coins), therefore increased rewards will be accompanied with more coin supply. This will ultimately lead to a collapse in token price.

    Therefore to limit the number of blocks that can be produced at any given time, the difficulty of a blockchain is adjusted automatically.

    How is Mining Difficulty Calculated and Adjusted?

    Difficulty is calculated in terms of hash power of all the validators. If the hash rate is high, it means there are more miners. Therefore, the mining difficulty has to be increased.

    The mining difficulty could be calculated using a variety of formulas.

    Here’s a simplified explanation of how mining difficulty is calculated in Bitcoin:

    1. Target Block Time: The Bitcoin protocol aims to have a new block added to the blockchain approximately every 10 minutes.
    2. Previous Difficulty: The difficulty at which the last 2016 blocks were mined.
    3. Time Taken(Block Time): Calculate the time it took to mine the last 2016 blocks.
    4. Adjustment Calculation: If it took less than two weeks to mine the previous 2016 blocks, the difficulty increases. If it took more than two weeks, the difficulty decreases.
    5. New Difficulty: The difficulty is adjusted by changing the target value that miners must meet when solving the proof-of-work puzzle. A higher difficulty requires more computational power to find a valid block.

    The formula for calculating the new difficulty is:

    Mining Difficulty Adjustment Formula
    Mining Difficulty Adjustment Formula

    This formula ensures that if the network is finding blocks too quickly, the difficulty increases, making it harder to find the next block. Conversely, if blocks are taking too long to mine, the difficulty decreases, making it easier.

    Mining Difficulty Chart

    The mining difficulty chart shows how mining difficulty has changed over a given time. The mining difficulty chart for Bitcoin is shown below for the year of 2023.

    Bitcoin Mining Difficulty Chart in 2023
    Bitcoin Mining Difficulty Chart in 2023, Source: Blockchain.com

    What Miners do when Difficulty Increases?

    When Bitcoin mining got popular, the number of miners increased and this led to an increase in difficulty. To combat this, Bitcoin miners created mining pools where miners use to pool their computational resources and start mining as a team. With increased resources, they would now have a greater chance at discovering new blocks.

    #NOTE: Block discovery works in a way where the fastest one to verify and add transactions to finish a block is the only one to be rewarded. Other blocks which could not be included in the blockchain are called orphan blocks.

    Impact of Mining Difficulty

    Resource Consumption

    If the mining difficulty is not periodically regulated, the number of miners would rise disproportionately. This would cause an increased usage of power and computational resources (CPU, GPU). This could lead to power shortages.

    An increased mining difficulty discourages new miners after a certain level.

    Token Price Stability

    Token prices remain relatively stable because their supply is well regulated. If there would be uncontrolled mining, then token price would also come crashing down as each miner would produce several blocks and get mining rewards.

  • What is a Blockchain? History, Evolution and Concepts in 2024

    A blockchain is a set of blocks each of which records details of several transactions. Together, it creates a distributed ledger that is nearly immutable and is able to process transactions in a much efficient manner.

    Blockchains issue cryptocurrencies which are can be transacted cheaply and almost instantly. This led to the creation of a new era of finance called as Decentralized Finance.

    History of Blockchains

    Though blockchains existed since 1996 when Nick Szabo brought the concept of cryptocurrencies. However, then cryptocurrencies could not exist in a way that prevented double spending.

    Why early cryptocurrencies met failure?

    In early cryptocurrencies, anyone could copy them and spend them a number of times. This made it difficult to see whose transaction was original because every transaction was identical.

    This problem was called as double spending.

    Bitcoin Solves Double Spending

    The first cryptocurrency which prevented double spending was Bitcoin. It solved the problem through an innovative method called proof of work. Each transaction was broadcasted to the entire network and was verified multiple times. Further, a copy of all transactions was available with everyone, which prevented fake transactions.

    The people who validated the transactions had to go through a complex process to obtain a value called Nonce, which was unique to each transaction. Since every verifier could obtain the Nonce value independently, they were able to see that a transaction was valid.

    The transaction verifiers are paid a part of blockchain transaction fees. For proof of work blockchains, they are called as miners and for proof of stake blockchains they are known as validators.

    Automation of Blockchains with Ethereum

    The second generation of blockchain started when Ethereum was launched in 2015, its founder Vitalik Buterin and other co-founders added a feature called smart contracts which automated transactions. Now transactions need not to be initiated by humans, the blockchain was itself capable of doing so.

    The application was seen in betting, auctioning, decentralized exchanges, liquidity pools, cryptocurrency swapping protocols and several other areas.

    The Ethereum Blockchain
    The Ethereum Blockchain

    New Era of Cross-Chain Functionality

    Even the second generation of blockchains could not transfer assets among each other.

    This was solved with cross-chain transfers. Tokens were either locked or burnt on one blockchain and minted on the other. The value of tokens burnt on one chain were of the same value as those minted on the other chain.

    This was possible for all kinds of tokens, whether fungible (cryptocurrencies) or non-fungible (NFTs).

    Emergence of New Applications

    After the maturing of blockchain technology by 2018, new trends emerged in blockchain which catered to data management (The Graph), Internet of Things (IOTA Chain), data transfers to and from blockchains (Chainlink) and non-traceable blockchains(Monero).

    Trends which were till now suppressed due to reasons such as lack of adoption also re-emerged.

    One such application was asset tokenization. This application made it possible to convert the ownership of real world assets like cars, land and property into blockchain tokens which made it possible to transfer them within record time (as compared to traditionally several weeks).

    Blockchain Terminology

    • Atomic Swaps: These are cross-chain transfers between two addresses without the need of any centralized party. Asset is either locked or burnt on one chain and minted on another.
    • Coins: Those cryptocurrencies which exist on their own blockchain are called as coins. For example BTC on Bitcoin’s blockchain or ETH on Ethereum’s blockchain.
    • Consensus Mechanism: Consensus mechanism is a way through which multiple nodes in a blockchain agree that a certain transaction is valid or invalid.
    • Cryptocurrencies: These are assets on the blockchain which carry real monetary value. They can be converted in cash. These tokens are fungible which means they can be divided into small denominations (fungibility). For example, Bitcoin can be divided into 100 Million Satoshi, which is the smallest unit of a Bitcoin.
    • Difficulty: This is the numerical measure of complexity which is encountered while validating a blockchain transaction.
    • Finality: This is the step where blockchain transactions are permanently recorded in a block and few blocks have already passed. It ensures that a transaction is already final. Bitcoin’s finality is 6 blocks which means that after your transaction is added, 6 blocks should pass before receiver is able to use those funds.
    • Gas Fee: These are the transaction fees which are paid for transacting on the blockchain. Though initially meant for Ethereum transaction fees only, now it is a widely used term.
    • Gas Price: The price required to be paid to sign and initiate a transaction. In Ethereum, gas is calculated in terms of Gwei.
    • Gas Wars: A gas war is the auction for priority of keeping a transaction before everyone else. In blockchain, transactions are auctioned and bidders who are bidding higher fees are included first in a block.
    • Genesis Block: This is the first block of a blockchain and unlike other blocks it does not have any hash function of previous block since it is the very first one.
    • Halving: This is the schedule where Bitcoin’s rewards for miners reduced by half for each new block.
    • Hash: A hash is a data set that is obtained after processing earlier data in a way that the process is not possible backwards. For example, if the hash of data X creates data Y, the hash of data Y does not create data X.
    • Hash Rate: Hash Rate is the number of cryptographic hashes that can be done in one second.
    • Immutability: This is the blockchain feature which makes it almost impossible to change blockchain transactions after they are finalized.
    • Forks: A fork is a change in the blockchain. Hard forks are changes that make irreconcilable differences between the original and the new blockchains while soft forks are changes that do not impact the compatibility of original blockchains. No new blockchain is created as a result of soft fork.
    • Mainnet and Testnet: Mainnets are the main blockchain networks on which transactions occur while testnets are the functional replicas of mainnet used for testing of new blockchain features, tokens or Dapps.
    • Merkle Root: Merkle Root of a block is the hash result of all the transactions present in that block.
    • Merkle Tree: The pathway using which Merkle Root was generated is called the Merkle Block.
    • Mining: In proof of work blockchains the process of validating transactions and adding them to the blocks is known as mining.
    • NFTs: Non Fungible Tokens are those which cannot be divided. These are mostly assets which can be:
      • Text
      • Audio
      • Video
      • Image
      • Code
      • Software
    • Node: A node is a blockchain verifier that has full rights to add transactions to a blockchain. In a proof of work blockchain, these nodes are called as miners and in a proof of stake blockchain they are called as validators.
    • Nonce Value: The nonce value is a number which is obtained after hashing the transaction details and hash value of previous transaction in a block. Nonce values are unique for each transaction.
    • Oracles: Oracles are softwares that send information to blockchain smart contracts in a secure and verified manner. Examples are Chainlink, QED, etc. They can be either centralized or decentralized.
    • Orphan Block: Orphan blocks are those blocks which contain verified transactions but are not accepted in a blockchain because the transactions were already included in other blocks which were produced faster.
    • Optimistic Rollups: This is a mechanism where transaction data is written on an empty part of a block which was meant for storing metadata. Since writing metadata on blocks does not require validation, it costs cheaper than recording transactions in a blockchain. The transactions are written on a blockchain but in a cheaper way.
    • Private key: These are basically passkeys which allow you to send and receive cryptocurrencies. You can only send a cryptocurrency if you sign the transaction with your private key. If someone else accesses your private keys, they can access your funds, or even steal them.
    • Public Address: Also known as public key, this is the address on the blockchain using which you can receive cryptocurrencies. The public address is usually an alphanumeric string.
    • Ring Signature: A ring signature is a shared signature which is used to sign blockchain transactions. The ring signature could be used by anyone of the ring members.
    • Sharding: This is the process of dividing the single giant blockchain consensus network into numerous smaller ones which can process transactions independently. This increases the speed of the blockchains since each shard acts as an independent chain.
    • Smart Contract: A smart contract is a piece of code on a blockchain which can automate transactions based on a pre-determined instruction. For example, if a certain thing happens, pay X amount to someone.
    • Staking: This is the process of collateralizing cryptocurrencies so that you are given the right to validate transactions and earn rewards. Even if not validating transactions, anyone can stake their crypto to earn rewards indirectly (through a validator).
    • Tokens: Tokens are cryptocurrencies which are not on their own blockchain or might have no blockchain of their own. For example, USDT is a token on Ethereum’s Blockchain while ETH is a coin on Ethereum.
    • Token Standards: These are standardized protocols of creating new blockchain tokens which makes it possible for swapping with each other. For example USDT and USDC are stablecoins which both exist as ERC-20 tokens. ERC-20 is an Ethereum token standard.
    • Turing Complete: It means that a certain computer can execute any conceivable program or software. Ethereum is Turing Complete.
    • Wallet: A wallet is a software which stores your public addresses and private keys and lets you send and receive cryptocurrencies. For example: Lightning Network Wallet for Bitcoin.
      • Hot Wallet: These are wallets which exist as a software and are meant for easy access.
      • Cold Wallet: These are wallets which exist on hardware and are meant for secured storage.
    • Wrapped Tokens: These are tokens which locked in one chain and minted on another which makes it seem like they have been transferred across chains. For example, Bitcoin can be wrapped to create WBTC and transferred to Ethereum as an ERC-20 token.
    • Zero Knowledge Rollups: This is a mechanism which allows for the validation of a blockchain(L1) transaction outside of the blockchain (on another chain{L2}). At the end the summary of transaction is validated at once to see if there is any error.

    How does a Blockchain Work?

    All blockchains work basically in a similar way which starts with initiating a transaction, which is then verified and after that is finalized. The following stepwise process illustrates the working of a blockchain along with a flowchart.

    Proof of Work
    Working of a Blockchain
    1. A transaction is initiated by a user.
    2. The transaction is broadcasted to all the nodes (verifiers).
    3. Each node runs computations to verify the transaction.
    4. Transactions are added to a block.
    5. The newly added block is broadcasted to the network.
    6. The block is finalized when a certain number of new blocks is added after it.

    Hacking in Blockchain

    • Re-Entrancy Attack: In this attack, a function in the code is externally invoked which leads it to run multiple times in a single transaction. Hackers are able to repeat the same transfer of funds multiple times.
    • 51% Attack: Blockchain transactions work on majority rule. If more than 51% of nodes are hacked, then the hacker can do whatever with other people’s balance. This was seen in the Axie Infinity Hack where 51% (11/21 nodes) were hacked by Lazarus Group and at the end resulted in a $625 million loss.
    • DAO Attack: On June 17, 2016 Ethereum was hacked and hackers were able to steal 3.6 million of the total 11.5 Million ETH. This lead to the creation of Ethereum Classic which opposed the rollback (hard fork).
    • Frontrunning: Frontrunning is the process of buying tokens before a buyer and then selling the tokens to that original buyer for a higher price.