You are on page 1of 9

Bitcoin was the first application to take the Blockchain mainstream.

Ethereum takes blockchain one step ahead. It allows to make smart contracts, Dapps, defy and more.

Smart contracts need to access external data and external computation outside of blockchain using
Oracles.

Chainlink is the most powerful decentralized oracle network and allows us to build hybrid smart
contracts which allows us to use external computation and external data.

The ORACLE PROBLEM

Getting data inside the blockchain using oracle creates a single point of failure and makes the
network centralized. This is the biggest issue in Blockchain.

Hybrid smart contract

If real world data is brought into a smart contract, then its called a hybrid smart contract.

Advantages of Smart Contract

Decentralized

There is no central authority. There are independent nodes which connect and make up the whole
blockchain environment. Banks do shady stuff, freeze your accounts, don’t give you loans and can do
anything with your money. Robbin Hood Case (read about it!!)

Transparency and Flexibility

Everything which happens on blockchain can be seen. Of course there is annomousity but everything
still has a record.

Speed and Efficiency

Banks take 3-5 days for a transaction to proceed. It takes a few minutes to do it on blockchain
depending on the type of blockchain.

Security and Immutibility

Can’t hack. Data can’t be tempered. If the servers of bank go down, all data will be lost. In blockchain
all nodes have complete record of data, so data can’t be lost.

Trust Minimized Agreements

Smart contract depends on maths and don’t require any trust of any sort.
Gas

Gas price is in Wei or Gwei. It’s the cost of gas per unit. More computation means more gas used.

Transaction fees = Gas price * Gas

We can’t set the gas price to minimum because of block size issue(will be discussed later). Higher
gasprice means that the calculation will be validated asap.

Mining
The problems miners have to solve is to come up with a Nonce that gives the Hash 4 zeroes in the
beginning. The Hash is calculated by the SHA256 hashing function(data goes in, hash comes out).
After we click the mine button, the nonce changes and a new hash comes out which has 4 zeros in
the start.

Genesis Block
The first block in the blockchain is called genesis block. Its previous hash is zero.
The hash of the block is linked to the next block by the Previous field. So if you change the data, the
hash is changed and the previous column doesn’t match and thus as a result the whole blockchain
becomes invalid. This is the reason why blockchain is immutable and can’t be tampered.

(The hash is calculated by the block, nonce, data and previous fields)

By changing the data, the hash is changed. The prev field is also updated and thus the hash doesnot
start with four zeros anymore.

However it is possible to mine the whole blockchain again so that a new hash is calculated for each
block (hash starts with 4 zeroes.)

DISTRIBUTED BLOCK CHAIN


In distributed blockchain, each user has its own copy of blockchain. There is no single point of
authority. So the way to check the validity of a blockchain is to check if the final hash of each
blockchain is the same. In blockchain, democracy rules, so if a single user has a different final hash he
will be in minority and his blockchain will be marked as invalid.
Public and Private Keys
Each Metamask account has a public and a private key. The public key is derived from the private
key using a hashing algorithm (Eliptic curve digital signature algorithm). The account address is then
derived from the public key. Keep your private key a secret as it is used to sign all the transactions.

Whenever we make a transaction, it is signed by the private key to generate a message signature.
The message signature can then be verified to see if it came from the correct public key.

All keys are always in hexa decimel so add Ox before.

The normal websites run on a centralized server(Facebook has its own server for storing data so does
Google). Blockchain runs on decentralized nodes (each person can has its own copy of blockchain).
In normal world, if a company server goes down or its hacked or is bribed, the whole system goes
down. However, in blockchain, each person has its own copy. So if only one node survive, the whole
blockchain is preserved and if one node acts maliciously then it can be voted out as its final hash
won’t match the rest of the nodes.

Consensus
Consensus is the mechanism used to agree on the state of blockchain. (if a blockchain misbaheves It
can be voted out).

Write notes from 1:10 to 1:30 for PoW , PoS.

Writing first Solidity Program


In solidity there are 4 types of visibilities

1. Public Making a variable public so it can be called by other people.


2. Private
3. Internal (default)
4. External This function cant be called by the same contract it has to called by an external
contract …store function cant be called.
View functions don’t make a transaction, that’s why there color is different. View functions
means they just want to read the state of the blockchain.
Pure Functions just do some Math. That’s why they are in blue.

We can store variables in Memory and storage.

_name will be thrown after function execution. Storage variable names there.

You might also like