Blockchain and Smart Contracts

Ritika Singh
4 min readOct 20, 2022

Now, before getting into the technical terms, I want to emphasize on why Blockchain is important. Have you ever been afraid of using these 3rd party apps for large transactions? Have you seen tons of political debates after every election if some party has done tampering of the actual votes by some means? Have you ever second guessed before donating money for a fundraiser or a crowdfunding through a 3rd party platform? Or speaking in bigger terms, have you ever wondered that the government and the banks are actually centralized authorities and they can do anything with your money deposited in the bank?

The thing that is common to all these scenarios is that we have to trust some 3rd party Centralized system over which we have no control. Blockchain presents to you a decentralized way of doing all these tasks making sure there is no central authority controlling anything.

As the name suggests blockchain refers to a chain of blocks which contains some information. It is open to anyone, and once any data is inside the blockchain it is very difficult to tamper with the data without getting caught. Each block in the chain contains -

Some data, Hash of the block and Hash of previous block and moreover the data depends on the type of blockchain which is in use.

A representation of Blockchain

Now let’s see what makes a blockchain so secure?

You can understand hash as a fingerprint which uniquely identifies a block and its content. Once a block is created its hash is calculated , and if data inside the block is tampered, the hash will change.

So , if someone tampers with the 2nd block, its hash changes. But block 3 has the original hash of the previous block ,hence it can be used to detect the tampering in the 2nd block and also all following blocks have been disconnected from the 2nd block. They no longer have the valid hash of 2nd block, but hashing isn’t enough to stop the tampering of data because computers nowadays can calculate tons of hashes every minute so they can tamper all the further blocks in the chain and make it seem like everything works fine.

So, here comes the concept of Proof Of Work which basically slows down the creation of new blocks. It takes approximately about 10 mins to calculate the required proof of work for a bitcoin network and add a new block to the chain, so this makes it hard to change all blocks immediately and hence the tampered block can be detected easily.

Another key aspect of the security behind Blockchain is its distributed nature, instead of a centralized unit it uses a Peer to Peer (P2P) network. It is an open network which anyone can join, and on joining gets a full copy of the blockchain itself , which can be used to verify if everything is in order.

When a new block is created by someone, that block is sent to everyone on the network and each node verifies that if it has been tampered or not, each node adds this block to their blockchain. So this means that they should arrive at a consensus whether the block is valid or not.

Let’s see how does a transaction works with Blockchain?

Transactions with Blockchain

Just like verifying the blocks, every transaction has to first reach a consensus by all the nodes whether the transaction has to be added or not. Now, the nodes which are verifying these transactions are incentivized which means by solving a puzzle which is also referred to as “proof of work”. This puzzle is basically a complex mathematical problem needed to add another block to the chain, this process is also called mining and the miners are rewarded in the form of “Cryptocurrency”.

But with the evolution in Blockchain, “SMART CONTRACTS” are being used these days using which transactions can be completed when certain conditions are met automatically.

Creation of smart contracts- Smart contracts are basically programs stored on blockchain which can be used to automatically exchange coins based on certain conditions. It is written in a programming language

Let’s understand how a smart contract works with an example.

Consider any crowdfunding website like Kickstarter- used to collect funds for starting their startup or collecting enough funds to work on their project. When the target amount of fund is reached, it is transferred to the project owners, otherwise it is returned back to the donors. But what if this funding process can be done without the involvement of a third-party like Kickstarter?

Well, Blockchain provide a decentralized way of achieving the same goal. The difference is that this time it is done with the help of smart contracts which is written in a programming language called Solidity which was originally build specifically for Ethereum blockchain. Smart contracts are pieces of code present inside the blockchain which makes it both immutable and distributed. Being immutable means that, when a smart contract is deployed no one can tamper with the code and being distributed means that each and every transaction through the smart contract will be validated by every single node present. Thus, tampering with a smart contract is impossible because the properties of blockchain discussed above.

Hope this gives you a basic idea of how blockchain works in a decentralized manner, you can learn further about Decentralized Finance in my next blog.

--

--