Why I think Blockchain is Like Firmware

Why I think Blockchain is Like Firmware

Software patches, upgrades, and new releases are typical for an application whenever software development wants or needs. Releases can occur regularly or irregularly depending on when and what functionality is being deployed. Hence, agile development methodologies can be adopted both pre and post-release.

Firmwares are embedded into the hardware. It is not feasible for the Firmware to update or patch whenever firmware development wants. Special hardware/software and physical machine or access are typically required to update or patch Firmware. For example, if your washing machine needs a firmware upgrade, it is not practical to drag it to the local appliance store to be re-flashed.
Due to the permanent nature of Blockchain, Smart Contracts are like firmware, not software. As with any other transaction stored on a Blockchain, a Smart Contract deployed to it is permanently stored and cannot be changed.

The new version of the Contract can be released to sit alongside the old ones, but the old ones can never be deleted. A published Smart Contract can never be upgraded or patched. Instead, a new Smart Contract can be created and published, but the old one will remain forever on the Blockchain.

Here, the Kill Function or a Self-destruction function can help. The Smart Contract’s old version may have a particular function that enables a Smart Contract to be “killed”. A killed Smart Contract will refuse any new transaction, although it exists. Kill function does NOT delete the Contract but puts the Smart Contract in dormant mode.

Kill function must be used very carefully and with great caution. It must be ensured that the correct people and circumstances can call the function. The Contract holds millions of dollars; malicious attackers may destroy by evoking the kill function.
DO NOT take the decision to implement a kill or self-destruct function lightly!

Understanding Different Types of Computing Systems 

Understanding Different Types of Computing Systems 

Centralized System :

  • A single entity owns the data and the solution.
  • The resources are centralized in one place.
  • Easy to maintain.
  • Single point of failure, low fault tolerance.
  • Low and fixed scalability

Distributed System:

  • A single entity owns the data.
  • The solution provider distributes resources across multiple locations, data centres, and systems.
  • Cloud computing and “as a service” solution.
  • Extremely high fault tolerance and more scalable.
  • Most centralized systems evolve into distributed systems.

Decentralized System:

  • There is no single owner of either data or network hardware.
  • Each participant is responsible for ownership and maintenance.
  • Highly fault tolerant.
  • Infinitely scalable as resources are independent entities.
  • Most challenging to maintain as no one entity owns it.
  • It is shared amongst the peers or participants of the system.
  • Runs over P2P network architecture. 
  • P2P is a network of equally privileged participants where tasks and workloads are partitioned across all participant
  • Participants are called Nodes.
  • In P2P systems, all nodes are both client and servers simultaneously.
Types of Blockchain Technology

Types of Blockchain Technology

With the advancement of blockchain technology over the past few years, it can be divided into multiple categories with distinct and sometimes partially overlapping attributes.

Since blockchain is a relatively new technology, many people use it interchangeably with cryptocurrency or digital currency. The main reason for this is that the first and most famous application of blockchain technology was Bitcoin, the first decentralized digital cryptocurrency.

You know about blockchain technology, but are you familiar with all of the types?

Before categorizing blockchain technology, we need to understand Distributed Ledger’s distinction from the blockchain.

The term distributed ledger corresponds to a shared database, so all blockchains can be considered distributed ledgers or shared databases. Even though all distributed ledgers are fundamentally blockchains, all blockchains are not necessarily distributed ledgers.

A distributed ledger does not always consist of blocks of transactions, which is what differentiates it from a blockchain. In fact, a blockchain consists of blocks of transactions and is a special type of shared database. 
An example of a distributed ledger that does not use blocks of transactions is R3’s Corda.

Distributed Ledger Technology (DLT) covers a wide range of distributed ledger technologies, including blockchains and distributed ledgers of all kinds.

Fig.

Public Blockchain

Public blockchains are not owned by anyone. Nodes on a public blockchain can participate in the decision-making process. Participants may or may not receive rewards. The users of these “permissionless” or “un-permissioned” ledgers keep a copy of the ledger on their local machines and use a distributed consensus mechanism to decide the eventual state of the ledger. 

Private / Consortium Blockchain

Unlike public blockchains, private blockchains are just that – private. The ledgers are only available to a consortium or group of individuals or organizations that have decided to share the ledger among themselves. Kadena and Quorum are examples of that.

Semi-private Blockchains

Semi-private blockchains have parts that are private and parts that are public. In a semi-private blockchain, the private part is controlled by a group of individuals, while the public part can be accessed by anyone.

Sidechains

The sidechain is a blockchain that is separate from the main bitcoin blockchain but is attached to it. By attached we mean that the sidechains are linked to, and derive their security from, the main Bitcoin blockchain. In this way, a second chain is created with a special purpose. The new blockchain is called a sidechain, because it’s secondary to the main chain. A good example is Bitcoin’s Lightning Network. Lightning Network is a sidechain that allows Bitcoin to scale. It works by using sidechains to create payments that are off-chain. 
There are two types of sidechains:
A.
A sidechain that is pegged to the Bitcoin blockchain, such that for every Bitcoin that moves there will be an equal amount on the sidechain in a 1:1 relationship.
B.
A sidechain that is not pegged to the Bitcoin blockchain, but the value of the sidechain is dependent on the value of the Bitcoin blockchain such that the bitcoin blockchain is the anchor to the sidechain.

Permissioned Ledger

A permissioned ledger is a distributed ledger where the participants are trusted. The technology is based on the idea that blockchain can provide a new kind of trustworthy and secure consensus mechanism to manage transactions. Permissioned ledgers can also be considered as the decentralized version of traditional databases. The difference between a permissioned ledger and a database is that the latter is a centralized system where only one entity controls access to the information in the database. On the contrary, in a permissioned ledger, all the participants have equal access to the same information. In this sense, a permissioned ledger is decentralized and permissionless at the same time.

Conclusion:

You have probably come across Bitcoin, Ethereum, and other cryptocurrencies when you think about blockchain technology. However, Blockchain, the decentralized ledger technology that underpins cryptocurrency, has a much broader application. Transactions are recorded in a distributed, tamper-proof ledger called a blockchain. It can be used for everything from financial applications to supply chain management. Blockchain will become the primary means of storing data in the coming years. It is a technology that will change how we work, shop, and socialize.

50 Answers to the Solidity Basic Questions

50 Answers to the Solidity Basic Questions

  1. What is an Ethereum smart Contract?
    It is a small program that runs on the Ethereum blockchain.
  2. What makes an Ethereum smart contract so special compared to other programs?
    It cannot be stopped, hacked or modified.
  3. Can a smart contract interact with other smart contracts?
    Yes. A smart contract can call function of other smart contract.
  4. Can a Solidity smart contract call an API on the web?
    No. Oracle pattern can call function on the smart contract and feed the data and Solidity smart contract may make use of the data received. Smart contract function can be called always from outside to the smart contract and never other way around
  5. Can a solidity smart contract store a lots of data?
    No. Smart Contract storing data cost a gas. So directly storage data is limited.
  6. Can a smart contract be written in another language than Solidity?
    Yes. Viper, LLL, etc. But Solidity is very popular.
  7. Is Solidity a Dynamically or Statically typed language?
    Statically typed language that means variable types are required to mention. Other language like Java or python where variable do not require to mention type, language figures out the type. We have to be careful about the type of the variable because once the contract is deployed we cannot change, this way we reduce the chances of error.
  8. Is Solidity complied or interpreted?
    Complied. Before run the program it require to compile the program. Different than Java language. Java machine compile on the fly.
  9. What is the file extension of Solidity files?
    .sol
  10. Can a single Solidity file have several smart contracts?
    Yes. However it is better to have single contract in single file in order to mange code better.
  11. What is the typical layout of a Solidity smart contract?
    1. pragma statement for the version of the solidity
    2. contract statement and curly braces. Everything between the curly braces is the part of this contract.
    3. Define some variables.
    4. And functions to read and modify data.
      //pragma statement (required)
      pragma solidity ^0.5.9;
      // contract declaration (required)
      contract A{
      //state variables uint a;
      //functions function foo() {.....}
      }
  12. What is the difference between state and local variables?
    State variables are persisted on Blockchain after a smart contract finishes to execute. Whereas local variable live only during the execution of the function.
    contract A {
    // state variable uint a;
    //functions function foo() {
    uint b;
    //local variable
    }
    }
  13. What is the problem with the following code-1?
    contract Storage{
    uint data; //should update the 'data' storage variable above
    function set (uint _data) external{
    address data = _data;
    }
    }

    The set function redefine the data variable inside its body and this will create a local variable that shadow the state variable defined above.
    Remove the address keyword when you reference the data inside the set function.
  14. What is the problem with the following code-2?
    contract Storage{
    uint data; //Should update the 'data' storage variable above
    function set(uint data) external{
    //data = data?
    }
    }

    The data argument of the set function shadows the data state variable inside the set function. Because of this we can access the data inside the set function. To solve the problem we need to rename the argument from data to underscore data.
  15. What are the 2 variable visibilities for state variables in Solidity?
    private and public.
  16. Who can read private and public variables?
    private → can be read by only function inside the smart contract.
    public → anyone.
  17. What is the default visibility of state variables?
    private.
  18. Are private variables really private?
    No. Private variables are private only for EVM, Ethereum Virtual Machine, the part of the Ethereum that execute Smart Contracts. The data of the Smart Contract is put on the Ethereum Blockchain and all the data in this Blockchain is public.
    You can use a special tool to analyse blockchain data and you will be able to read any variables including private variable of the smart contract.
    Private variables are not really private but a little bit harder to read.
  19. How to deal with private data than?
    1. Do not put private data on blockchain
    2. use hashes
  20. Mention 3 data types that you use often, and explain why.
    uint → integer type mainly use for Ether and token transfer.
    address → it is used for identifying humans in smart contract.
    string → used for naming things.
  21. What are the 2 container types in Solidity?
    mapping and arrays
  22. How to declare an array of integer in Solidity?
    uint[] a;
  23. How to declare a mapping of address to booleans in Solidity?
    mapping(address => bool) a;

    In above example “address” is the key and “bool” is the value.
  24. How to declare a mapping of address to mapping of address of booleans (nested mapping)?
    mapping(address => mapping(address => bool)) a;
    In above example first key “address” and than we have second key “address” and value “bool”.
  25. How to add to an array declared as a state variable?
    by using “push” method.
    uint[] a;
    function add(uint newEntry) external{
    add.push(a);
    }
  26. How to add data to a mapping declared as a state variable?
    mapping(address => bool) a;
    function add(address addr) external {
    a[addr] = true;
    }
  27. How to loop through an array?
    uint[] a;
    for(uint i = 0; i < arr.length; i++){
    // do something with arr[]
    // reading:
    uint a = arr[i]
    // writing:
    arr[i] = a
    }
  28. What is the difference between a uint8 and a uint16?
    uint8 can store → 28-1
    uint16 can store → 216-1
  29. What are the 4 function visibilities in Solidity by increasing permissiveness?
    private → the function can be only be called from inside the same contract.
    internal → the function can be called from inside the same contract or another contract that inherit from it.
    external → the function can only be called from outside the smart contract.
    public → the function can be called from anywhere, from the function and outside the contract.
  30. How to conditionally throw an error, with an error message?
    require(a != b, "My error message")
    Use “require” statement.
    Specify the testing condition. If the testing condition fails than the second argument is the error message.
  31. What are the 2 artifacts produced by the Solidity complier when compiling a smart contract.
    abi
    bytecode
  32. What is the ABI of a smart contract?
    ABI is the define interface of a contract.
    That means, set of functions that can be called from outside the smart contract.
    It is used to interact with the smart contract.
    The idea is to use outside libraries like web3.js.
    The smart contract only defines function signatures i.e. function name, argument type and written types but it does not defines the implementation of function.
    ABI also defines events of the funciton.
  33. In the following contract, which function will be part of the ABI?
    contract A{
    function foo()
    external {....}
    function bar() public {....}
    function baz() internal {....}
    }

    foo and bar will part of ABI.
    baz can only be called from inside and inherited from it.
  34. Does the EVM understands Solidity?
    No, EVM under only byte code which must first be produced by the solidity outside the blockchain.
  35. What is the EVM bytecode?
    EVM byte code is a series of EVM elementary instruction called opcodes.
    These opcodes are very simple instruction like adding number, loading number from memory, etc.
    There are more than 100 opcodes defined in the Ethereum Yellow Paper.
    Coding using opcode will be very tedious so we need higher level language call Solidity for higher level of abstraction.
  36. What are the 2 APIs used to interact with a smart contract?
    eth_sendTransaction
    eth_call

    Transaction cost money and can modify the blockchain.
    Call does not cost money and cannot modify the blockchain.
  37. What is gas?
    Gas is an abstract unit to measure transaction cost.
  38. How is gas paid?
    Gas is paid in ether calculated from the following formula:
    ether cost = gasPrice * gas
    gasPrice is wai / gas generally represent in gwai.
    gas represent the gas cost during the execution of the transaction.
    A transaction also specify a gas limit parameter. Which specifies the maximum number of gas that can be paid by transaction. Without this a transaction can drain all the ether in the wallet.
  39. What happen if there is not enough gas in a transaction?
    Transaction will fail and all state changes will be revert.
  40. Who pays for gas in a transaction?
    The sender of the transaction.
  41. What is the most famous IDE for Solidity?
    Remix.
    Remix – Ethereum IDE
  42. List 2 famous smart contract framework for Solidity.
    • Truffle – most popular framework for developing Solidity smart contract. It allows easy deployment of smart contract to developer blockchain and interact with it.
    • OpenZeppelin – provide reference implementation for a lot of tokens standards like ERC20, ERC721. Before developing smart contract always check whether OpenZeppline have already implementation for the re-use.
  43. Which Javascript Ethereum client can we use to develop Solidity on a local blockchain?
    Ganache – Ganache is a CLI tool that can create a blockchain development on the local computer. It is not connected to any public Ethereum blockchain network.
    Everytime it start it start with fresh blockchain with no data on it.
    It comes with 10 preloaded Ethereum account that can be used to develop the smart contract. All ethers specified in it are fake.
  44. What do you need to deploy a smart contract to the Ethereum Network?
    • bytecode from the smart contract,
    • ethereum address,
    • enough ether to cover the transaction cost,
    • wallet to sign the transaction,
    • tool to create transaction, coordinate the signing of the transaction with wallet and sending the signed transaction to the ethereum blockchain network.
  45. List 4 famous Ethereum wallets
    1. Metamask
    2. MyEtherwallet
    3. Ledger
    4. Trezor
  46. List network where you can deploy a Solidity smart contract.
    • Mainnet – real Ethereum network
    • Ropsten – public test net use fake ethers.
    • Koven – public test net specific for Parity client.
  47. How to manage dates in Solidity?
    Solidity does not have native date type. It is managed by storing timestamp in second and uses uint variable.
  48. How to have the current timestamp in seconds?
    use built in ‘now’ variable.
  49. How to construct a timestamp of 1 day in the future?
    now + 86400 ( number of second in one day)
  50. What are the 2 ways to define custom data structure in solidity?
    • struct,
    • enum.
The 7 Things You Need To Know About Blockchain

The 7 Things You Need To Know About Blockchain

There’s no denying the hype around blockchain technology. But for anyone who wants to get ahead of the game, here’s what they need to know about blockchain in order to capitalize on this groundbreaking new trend.

Blockchain is the technology behind Bitcoin taking into consideration as an example. It’s a decentralized digital ledger of all transactions that happen across the internet. It’s the backbone of the cryptocurrency industry, and it’s been hailed as a potential game-changer for how people and businesses interact with each other. It’s the latest buzzword to enter the technology realm, and here’s everything you need to know about blockchain and why you should be paying attention.

But what exactly is blockchain? Here are 7 things you need to know.

How does it work?

Essentially, a blockchain encrypts information in such a way that it cannot be altered, hacked, or cheated. The blockchain serves as a digital ledger of transactions that is duplicated and distributed across the entire network of computer systems. It is a secure, open-source, distributed database used to keep track of who owns what, and who owes whom. Databases and lists of records are referred to as blocks, and they are cryptographically linked together.

Fig-1 – BlockChain

The first block in the chain is called Genesis Block, whose previous block hash is zero.

http://www.anf.es/pdf/Haber_Stornetta.pdf

The work of Stuart Haber and W. Scott Stornetta from 1991 on How to Time-Stamp a Digital Document and their follow-up paper Improving the Efficiency and Reliability of Digital Time-Stamping introduced the idea of a chain of hashes to create a total order of commitments to a dynamically growing set of documents. 

Cryptography – How SHA256 Hash Works

Our fingerprints are unique to each individual, as we all know. It is highly unlikely that two individuals will have identical fingerprints. It cannot be denied, however, that 1 in 60 million people have a similar fingerprint. In this respect, a fingerprint is considered to be the unique identifier of a person. As a matter of fact, it is used by forensic personnel to identify criminals.

Is there any possibility of attaching some type of unique identification to digital assets to make them identifiable?

One idea for using a digital fingerprint is SHA256, developed by the NSA. SHA-256 is a cryptographic hash function that produces a value of 256 bits.  SHA – Secure Hash Algorithm and 256 stands for 256 bits taken in the hash. Hash is always 64 characters long. 64 characters are hexadecimal (numbers from 0 to 9 and letters A to F).

What is a cryptographic hash function?  Any function that maps arbitrary data (text, video, audio, any kind of digital assets of any length or you can put whole operating system) to a fixed-size value can be called a hash function – a fingerprint. This is the core principle used in the Blockchain.

The following linked video and a demo is a very basic visual explanation of the principles behind a blockchain: https://andersbrownworth.com/blockchain/hash  

There are 5 requirements of the SHA256 hash algorithm and these are:

1. One-way: The conversion from digital asset to hash must be one-way.

Fig-2 Hash

This means that the original copy cannot be recreated or restored or reverse Engineer using the hash function. As with fingerprints, no one can recreate a person using its fingerprint.

2. Deterministic: Every time it generates a hash for the same digital asset, it should be the same.

3. It must have fast computation.

4. The Avalanche Effect: It means that, even if a small change is made to the document, the hash will change completely. It is implemented in this manner in the algorithm. A small change may have a significant impact on the algorithm’s output.

5. It must withstand collision: Similar to the case of fingerprint, that 1 in 60 million may have the same fingerprint. There may be a chance that two arbitrary documents may have the same hash function. It is because 64-character combinations are still limited while the creation of digital assets is limitless. Therefore, it is likely at some point that a collision will occur. This is called the pigeon hole principle.  

Fig-3 – pigeonhole  

“In mathematics, the pigeonhole principle states that if {\displaystyle n}n items are put into {\displaystyle m}m containers, with {\displaystyle n>m}n>m, then at least one container must contain more than one item.” Wikipedia. It must be possible for the algorithm to handle it even though it is very rare.   

Refer to chapter 1 of the below-linked book for more details on the SHA256 Hash Algorithm.

https://webspace.science.uu.nl/~tel00101/liter/Books/CrypCont.pdf

Immutable Ledger

Immutable means “impervious to change.” Ledger is a fancy term for the record, which refers to something recorded. In other words, an immutable ledger is a record that cannot be altered.

We can trust digital data in the digital age if the data is secure and hasn’t been altered.

When tracking money transactions, trust and proof of trust are very significant. Let’s say you sent me an e-funds transfer of $100 without any proof that you did so and without any way to verify that you did so. When the money showed up, I would believe you, and if it did not show up–what then?

Banks and credit card companies use ledgers to keep track of transactions. Can we trust them? If we do not wish to hand over our money to a large corporation, bank, or government, what can we do?

Blockchain technology introduced the concept of the Immutable Ledger. Mathematics underlies this concept. Knowing it can’t be altered or changed, you put your trust in that math. 

What does the blockchain do to ensure its immutability? The hash is its foundation. Hashes are like digital signatures, and if a hacker tampers with the ledger, its hash will change. 

The blockchain will reject the hash if it no longer matches the previous hash in the ledger, making it null and void like a bad check.

Fig-4 – BlockChain-hack

It means that the hacker would have to change the next block, the one after that, and the entire blockchain itself. 

Distributed P2P Network

A distributed peer-to-peer network is one where every participating node is equal and independent. This means no single entity can control the network or the resources of the network. In addition, it enables participating users to make money by sharing the processing power and storage capacity of their systems with other users in need. The user with excess processing power can rent it out to users who have a specific job he or she cannot accomplish alone. 

Decentralization of network able to lends itself to different applications and services such as distributed storage and bandwidth, digital content distribution, cryptocurrencies, prediction markets, and much more.

Blockchain is distributed network technology where everyone has a copy of all the transactions blocks, which is stored in every node. The data on these blocks is encrypted and shared among all of the participating peers. In fact, everyone has access to a copy of the entire network and is able to see who owns what. The transactional records cannot be changed retrospectively without altering all subsequent blocks and collusion of the network. All of the transaction data is stored in a decentralized fashion, without a single point of failure. Such Peer-to-peer sharing of information directly between peers without the involvement of a central third party makes a P2P network. 

It is important to understand the difference between “distributed” and “decentralized”.

“distributed” means that not all transactions are processed in the same place, while “decentralized” means that no single entity controls the entire process.

Fig 5 – (a) centralized (b) decentralized (c) distributed

[source: https://medium.com/@VitalikButerin/the-meaning-of-decentralization-a0c92b76a274]

How Mining Works

Here is the simple analogy of Blockchain Mining:

I tell my friends that I am considering a number between one and 100, and on a paper, I write the number and seal it inside an envelope.
 
There’s no need for my friends to guess the exact number; just that they must be the first to guess any number lower than or equal to the one I am thinking of. It does not matter how many guesses they get.
Let me say that I am thinking of the number 19. If Frіеnd A guеѕѕеѕ 21, they lоѕе bесаuѕе оf 21 is greater than 19. If Frіеnd B guesses 16 and Friend C guеѕѕеѕ 12, then they have both thеоrеtісаllу аrrіvеd аt vіаblе аnѕwеrѕ, because of 16<19 and 12<19. Thеrе is no “еxtrа сrеdіt” for Frіеnd B; even thоugh B’ѕ аnѕwеr was closer to thе target аnѕwеr оf 19. 

Nоw imagine that I роѕе the guess whаt number I am thinking? But this time I am nоt asking just three frіеndѕ, аnd I am nоt thіnkіng оf a number bеtwееn 1 аnd 100. Rаthеr, I am asking millions оf wоuld bе mіnеrѕ, and I am thinking оf a 64-dіgіt hexadecimal numbеr. Do you believe that іt iѕ gоіng tо bе extremely hаrd tо guеѕѕ?

Comparing to above аnаlоgу, where thе number 19 оn a ріесе of рареr іn a sealed envelope, in bitcoin mining tеrmѕ, thаt metaphorical undisclosed numbеr іn the envelope іѕ called thе tаrgеt hаѕh – 64 Digit Hexadecimal Number.

Whаt Iѕ a “64-Digit Hеxаdесіmаl Numbеr?
The following Hexadecimal number is any example оf such a numbеr:
0000000000000000057fсс708сf0130d95е27с5819203е9f967ас56е4df598ее
The numbеr above hаѕ 64 dіgіtѕ.

Mіnеrѕ are dоіng wіth those massive computers аnd dоzеnѕ оf сооlіng fаnѕ is guеѕѕіng аt thе tаrgеt hаѕh. Mіnеrѕ makes these guеѕѕеѕ by randomly gеnеrаtіng as many “nоnсеѕ” аѕ “роѕѕіblе, as fаѕt аѕ possible. 

A nоnсе іѕ short fоr “numbеr оnlу used оnсе,” and thе nоnсе is the kеу tо gеnеrаtіng thеѕе 64-bit hеxаdесіmаl numbеrѕ. 
In Bitcoin mіnіng, a nonce іѕ 32 bіtѕ іn ѕіzе—muсh smaller thаn thе hash, which іѕ 256 bits. Thе fіrѕt mіnеr whоѕе nonce gеnеrаtеѕ a hаѕh thаt іѕ lеѕѕ thаn оr еԛuаl tо thе target hаѕh іѕ аwаrdеd сrеdіt fоr соmрlеtіng thаt block and is аwаrdеd.

Byzantine Fault Tolerance

To illustrate how a group of Byzantine generals could have communication problems when trying to decide on their next move, the Byzantine Generals’ Problem was devised in 1982.

The generals have their own armies, and each army is positioned at different locations around the city they plan to capture. They must decide whether to attack or retreat. If all generals reach a consensus, i.e., agree on a common decision that will be executed in coordination, it does not matter if they attack or retreat.

Now there are the following requirements:

  • Decisions must be made by generals regarding attacking or retreating (yes or no);
  • Once a decision is made, it cannot be changed;
  • All generals must agree upon a synchronized decision.

Generals are only able to communicate with each other through messages sent through couriers, which creates communication problems. Byzantine Generals’ Problems are characterized by the fact that the messages can get delayed, lost or destroyed.

A message may also be delivered successfully, but a general may decide (for whatever reason) to send a fraudulent message to confuse other generals, leading to a total failure.

With blockchains, each general represents a node in the network, and the nodes must agree on the current state of the system is before the general can move forward. As another way of putting it, when a distributed network operates, the majority of the participants must agree on the same action and execute it.

Therefore, the only way to achieve consensus in a distributed system is by having at least ⅔ or more reliable and honest network nodes. This means that if most of the network decides to act maliciously, the system is prone to failures and attacks (such as the 51% attack).

Consensus Protocol

Blockchain consensus protocols are the rules that govern what constitutes valid transactions on a distributed ledger. In other words, they define what the “consensus” is around any given set of transactions. They are a critical component of blockchain technology because they determine whether or not a transaction is valid. Blockchains operate based on consensus rather than a central authority.
This means that any participating node can create a block and contribute it to the chain. Instead of having a central authority that authenticates transactions, blockchains use consensus algorithms to determine which transactions are allowed to enter into the ledger.
The miners secure consensus algorithms, and the miners are compensated by earning transaction fees or new coins. The two main consensus algorithms are Proof of Work and Proof of Stake. 
The create of the original blockchain, Bitcoin, invented the “Proof of Work” consensus algorithm.
Ethereum is currently a PoW blockchain.

Conclusion

In conclusion, blockchain technology is already being used by more than 1,000 organizations across various industries. It is predicted to disrupt almost every industry in the next few years. However, many people still don’t understand what blockchain is, how it works, and why it is such a game-changer.

“Solidity Smart Contracts on Ethereum Blockchain” In Plain English

“Solidity Smart Contracts on Ethereum Blockchain” In Plain English

A “solidity contract” is different from a “product” or “service” contract. What makes a solidity contract different is that it resides on the Ethereum blockchain. On the blockchain, all transactions are permanent and cannot be reversed. Once I sign the contract, I cannot back out of it and deliver the money to you because then there would be no record of the transaction on the blockchain. Also, since everything is on the blockchain, the money you give me can never be stolen by hackers. All these factors combine to make a “solidity.

A Solidity contract consists of functions, data, and states, which reside on the Ethereum blockchain at a specific address.

A “function” is simply an action or a task. For example, in the case of the solidity contract, one function of the contract is to display the current temperature in Los Angeles. Another function of the contract could be to display the date. And, another function could be to record a person’s birthdate. All these are examples of “functions.” Functions can be made as complex or as simple as required. In the previous example of the solidity contract, we had only two functions. However, if you are working on a more complex project, you could have tens or hundreds of functions in your contract.

The term “data” refers to any information that can be input into a computer. The data for the previous example of the solidity contract would be the name of the city, the name of the weather station, the date, the time, and the current temperature in that specific location.

A “state” is simply a condition or a status of something. A condition is a state-related to a specific condition or a state when it relates to one particular condition. In the previous example, the current temperature, the state of the weather at a specific location was recorded.

Classes in object-oriented languages can compare solidity contracts to classes in object-oriented languages. Every contract consists of:

1. Declarations of State Variables, 
2. Functions, 
3. Function Modifiers, 
4. Events, 
5. Errors, 
6. Struct Types and 
7. Enum Types.
A contract may also inherit features from another contract.
Furthermore, a special type of contract exists known as a library or an interface.