Chiliz Chain 2.0 Developer Guide
English 🇬🇧 🇺🇸
Search…
⌃K
⛓

Blockchain

A general information about blockchain and what it is made up of!

Overview

Blockchain technology is a very robust, impressive and secure technology. This is one of the main reasons why it is being adopted for assets like cryptocurrencies which require a high level of security and reliability. As the name suggests, a blockchain is a set of blocks which act as ledgers filled with transactions. These blocks are linked together by an impenetrable algorithm.
The logic behind blockchain technology is simple. Blockchain being decentralised in nature any member of the network can check and verify the block at any given point. It is an online and transparent ledger system, hence, it is trusted the most in terms of security, integrity, transparency, and reliability.
All transactions on the block can be checked, validated, and verified by all the members of the network. Before approving a single block, all members of the network must reach a consensus.
Block = Data (sender, receiver, and amount to be sent) + Hash (the unique signature) + Hash of the previous block
The very first block of the blockchain is the Genesis block. Being the pioneering block on the blockchain, it doesn't have a previous hash. However, it produces a hash (a unique signature) for the consecutive block. The second block uses the previous hash and produces a hash for the next block. This cycle goes on uninterruptedly.
See the following figure:

Components of Blockchain

Genesis block

Genesis is the foundational block of your blockchain and hence, the blockchain for your cryptocurrency begins from this block. It is also called Block 0 for a reason. In a blockchain, each block is related to the previous block.

Hash

A hash is the most common term in blockchain technology. Each block in the blockchain generates a hash which is used as a unique signature to connect to the consecutive block. Hash helps to save a huge amount of data as it is stored in a cryptogenic order. The data in a massive blockchain can be traced easily when required using the Unique Hash ID or corresponding timestamps. It can further help to validate transactions once the cryptographic signatures are defined.

Accounts

Accounts in a cryptocurrency is a digital record, which is required to send, receive, and hold digital money such as crypto coins or tokens. To begin your cryptocurrency journey, you must have a digital account. It is usually not chargeable however, it depends on what type of digital account you hold. The following are two types of accounts:
  1. 1.
    Externally owned: this account can be operated and controlled by those having private keys. It's a free account through which transactions can be initiated.
  2. 2.
    Contract: this account is controlled by the code deployed on your network. A fee is charged as the contract runs on the external network, and charges are incurred for storage. You cannot initiate a transaction however, you can only send transactions against your received transactions.
Usually, both account types can transact and interact with smart contracts.
Since cryptocurrency is digital money, it doesn't rely on financial institutions namely banks, to validate or record transactions. Using accounts, you can send and receive payments (cryptocurrency) instantly and that too hassle-free.

Transactions

It is the record of every single entry that takes place on the digital wallet similar to the bank updates you receive on your bank account. All digital entries are coded instructions received by your wallet.
For example, if you receive some CHZs from another account, you will get an update about this particular transaction on your cryptocurrency wallet.
Following is the screenshot of how a successful transaction looks like when opened on the Scoville Explorer:
A successful transaction on Scoville Explorer
A single transaction consists of the following values:
Parameter
Description
Transaction hash
A unique ID of the transaction in a block
Result
End result of the transaction
Status
A confirmed state of the transaction
Block on
Block height
Timestamp
The time and date of a specific transaction
From
Public address of the sender
To
Public address of the receiver
Value
Amount of the transaction
Transaction Fee
Amount payable for a single transaction
Gas Price
A minimum fee required per transaction
Gas Limit
A maximum amount of fee (gas fee) the sender is willing to pay
Gas used by Transaction
Actual fee incurred to process the transaction
Nonce Position
A unique id to indicate position of the transaction in the blockchain, usually starts from 0

Gas fees

Gas refers to the fee required to successfully complete a transaction or run a smart contract on the blockchain platform. It's also a remuneration given to the miners for checking and validating transactions on the blockchain.
The gas fee varies from transaction to transaction. Often, you may have to pay more gas fees if the network is busy or loaded with a high volume of transactions on the block. In such cases, you can consider paying more gas fees and get your transaction listed on the top of the miner's validation list.

Nodes

Every computer in the network must agree upon each new block and the chain as a whole. These computers are known as "nodes". Nodes ensure everyone interacting with the blockchain has the same data since it is a prerequisite for all nodes to have the same data. To accomplish this distributed agreement, blockchain calls for a Consensus mechanism; elaborated further in this section.

Smart contracts

Smart contracts are digital contracts stored on the Blockchain. Basically, it is a set of coded instructions that deliver results when a function is called for. It sanctions coin-based and NFT exchanges when the required parameters are met.
Smart contracts are digital contracts stored on the Blockchain. Basically, smart contract is a coded script of instructions developed to return the result against a query. It sanctions coin-based and NFT exchanges when the required parameters are met.
Smart contracts are most commonly developed using an object-oriented programming language named Solidity. To be specific, Solidity uses syntaxes similar to other programming languages such as Python, C++, and JavaScript. A smart contract is nothing but a script. It can be customised or reused according to your business needs before deploying it on the blockchain.
Usually, once a smart contract is deployed it cannot be modified. Being a developer, if your smart contract needs to be tweaked or changed, you can consider upgradable smart contract. It allows you to alter the existing smart contracts using proxy patterns. After deployment, this proxy contract becomes a point of reference for all transactions instead of the old logic contract. You can use this concept if you wish to plug in new functionalities or bug fixes as a part of new logic.
Explore how to Deploy a Smart Contract.

Miners

Mining is a process through which new cryptocurrencies are generated and transactions are checked and verified before adding them to the blockchain. The mining activity calls for a huge well-connected but decentralised network across the world created with an intent to secure blockchains on various platforms.
Cryptographic calculations performed by specialised computers (nodes) verify and record every crypto transaction and ensure security of the blockchain. Miners (which can be software/hardware infrastructure) voluntarily contribute a vast amount of computing power to verify the blockchain.
Many companies make huge investments in purchasing and maintaining the infrastructure needed to run mining processes. It can involve renting/owning a space, paying for various expenses, and so on, much similar to running an office. In return, miners earn rewards that majorly depend on the block reward (it mostly remains constant) and transaction fees for transactions in the block.

Uncle blocks aka Ommer blocks

When blocks are created by two or more miners closely at the same time those blocks are called Uncle blocks. But, in practice, only one block can be mined, accepted, and approved on the blockchain. The ones excluding the accepted blocks are the Uncle blocks.

Block explorer

Block explorer is an interface to view the real-time data of your digital account. You can quickly review your transaction using a block explorer. Moreover, you can see the data available on the block along with cryptocurrency exchanges, accounts, mining, and other activities on the blockchain.

Consensus mechanism

Cryptocurrencies use blockchain as their database; therefore the consensus mechanism secures blockchain by validating entries into the blockchain thus ensuring the utmost security of all transactions. There are mainly three types of consensus mechanisms most prevalent in validating transactions; Proof of Stake, Proof of Staked Authority, and Proof of Work elaborated as follows:

Proof of stake aka PoS

Proof of Stake is a consensus mechanism to process transactions and create or add new blocks to the blockchain. Validators stake a certain amount of crypto as security to validate transactions on the blockchain. The system randomly picks validators to perform mining tasks, which is completely opposite to how the Proof of Work works. As a reward, validators get paid the transaction fees.
In PoS, blocks get assigned according to the stake pledged by validators. Rather than competing to be the first in finding the necessary amount of preceding zeros for a block hash, blocks are pre-assigned to validators.
Each of the consensus mechanisms has its own merits and limitations. However, PoS is supposed to be more environment-friendly than PoW as it doesn’t call for investing in the setup and/or consuming massive amounts of electricity.

Why PoS is preferred?

With proof-of-stake, the blockchain is kept secure by reducing the amount of computational work required for block verification and transaction verification. Each of the consensus mechanisms has its own merits and limitations. However, PoS is said to be more environment-friendly than PoW as it doesn’t call for investing in the setup and/or consuming massive amounts of electricity.

How does PoS work?

Proof of stake randomly selects validators who have pledged their stake to verify transactions and add new blocks to the blockchain. PoS is said to be more economical consensus mechanism than PoW in terms of infrastructure and setup. As there are certain factors required by PoS to work may incur a lot of expenses. For example, a full-fledged processing and storage unit corresponding to the size of your blockchain is required to run a full node.

The cons of Proof of Stake are:

One of the notable downsides of PoS is it encourages lobbying/hoarding of stakes. The larger crypto shares a party holds, the more will be their influence, irrespective of the consensus. This itself to some extent dismantles the idea of a decentralised framework and also fair trade the blockchain across the globe works on.

Proof of Staked Authority aka PoSA

PoSA has been widely used by many cryptocurrency networks or validators as an inherent consensus mechanism. Utilising a cryptocurrency client that participates in PoSA validation or becoming a validator in a way helps to secure the network and earn rewards.
PoSA Consensus Mechanism = Delegated Proof-of-Stake (DPoS) + Proof of Authority (PoA)
From that baseline of the EVM compatibility, Chiliz Chain 2.0 introduces a system of 11 validators with the Proof of Staked Authority (PoSA) consensus that supports shorter block time and lower fees. The most bonded validator candidates of staking then become the validators and start producing blocks. Moreover, the double-sign detection and other slashing logic further guarantee security, stability, and chain finality.

About Delegated Proof-of-Stake aka DPoS:

With Delegated Proof of Stake (DPoS) interested parties pledge some amount of token to become validators. These validators create and validate blocks of transactions on the blockchain.

Proof of Work aka PoW

Proof of work is another type of consensus mechanism. It validates, approves, and records all cryptocurrency transactions before adding to the blockchain. It potentially slows down the creation of new blocks. Proof of work assures secured transactions with no security breaches. It gives miners an opportunity to earn block rewards also in the form of crypto coins.

How does PoW work?

Every transaction comes with a transaction hash, here, the miner has to produce a hash similar to that of a target hash. Miners (specialised computers) aim to be the first ones at solving the equation.
Much similar to the video games we play, the complexity of mining gets tougher if these puzzles are solved in less time. Also, more complex puzzles can call for more rewards. That said, there is no structure or format to demonstrate how a mining algorithm works.

Decentralised Application aka Dapps

Dapps is short for a Decentralised Application. It is built on a decentralised network, which connects a frontend user interface with a smart contract. Usually, Dapps have open APIs and as a developer, you can possibly use existing smart contracts or templates coded by others.

Fungible tokens

Cryptocurrencies are the perfect example of fungible tokens since they have the same value as another coin of the same type at a given point. The fungible properties of cryptocurrencies are indicated by the code script/smart contracts. They can be divided into parts and are not unique.
GOOD TO KNOW
Fan tokens are fungible tokens.

Non-fungible tokens aka NFTs

Non-fungible tokens aka NFTs can be in the form of digital assets such as art, music, games, video games, rare collectibles, and so on. NFTs represent ownership of (mostly) unique items, which can be bought, sold, transferred, and even created. Since these tokens are stored on the blockchain, every transaction has its digital record on the blockchain, which allows creators to prove not only ownership but also authenticity of these assets.
The main similarity between NFTs and cryptocurrency is that they both are built on the blockchain and use similar programming languages.
Last modified 2mo ago