So the next important blockchain platform is Ethereum platform.
Ethereum platform has taken most of the principles from the Bitcoin blockchain, so most of the architecture
where the transactions are being processed is similar to Bitcoin blockchain.
The transactions are submitted by the applications using the RPC or SQS.
These transactions goes to the memory pool from memory pool miners take up the transactions, they validate
the transactions and finally add them inside the blocks.
Then miners do the nonce calculation and confirm the block over the blockchain.
The whole process is very similar to that, but there are few of the major differences which Ethereum
offers from Bitcoin blockchain.
In Ethereum, we mostly have decentralized applications as Ethereum supports the concept of smart contracts.
So we have applications which are going to interact with the smart contracts through the SDKs, one
of the main SDKs, which help us to perform the functionalities with Smart contract is Web3.
JS So you have a web browser which is used for Dapp applications.
This is basically using HTML, CSS, JavaScript and have Web3 JS and finally it has a web server which
is Apache or Nginx or any other web server you want to utilize.
The calls are made to the Ethereum nodes which are running the Ethereum Blockchain.
Ethereum nodes are not common nodes like Bitcoin.
Ethereum nodes are very special nodes which run Ethereum virtual machine, Ethereum Virtual Machine
is like a compiler which compiles the smart contract into an executable code.
So every Ethereum node will have this Ethereum virtual machine associated with them and they will compile
the smart contracts into the executable code.
Let's go and see that, how this complete process works with the help of an example.
So here I have a notepad open with me.
So initially I'll just give you a brief on how Bitcoin is working.
Let's take an example that we have three users Alice, Bob and Dave, and they are using Bitcoin blockchain.
So normally what happens with Bitcoin that Bitcoin utilizes UTC's principles?
UT Exos are the unspent transaction outputs.
So basically it specifies that you can only send a transaction if you have received a transaction.
If Alice doesn't have a transaction, then she is not able to send any other transaction.
So this will have a principle where you need to have a transaction before you can commit another transaction
on top of the Bitcoin blockchain.
So mostly what will happen with Bitcoin that let's say Alice has received the transactions from V2 blocks.
So V2 blocks sends ten coins to Alice.
So this is one of the transaction received by Alice.
So now Alice can use this transaction to send across to Bob.
Let's say Alice wants to send two coins to Bob.
So in Bitcoin blockchain the phenomena which happens is that this whole transaction is taken out and
this whole transaction is then divided into two separate transaction.
The first transaction is that Alice sent to.
Points to Bob.
And the second transaction will be Alice sends eight coins to Alice.
So you see in this, the whole transaction is divided into two.
One is the actual transaction which Alice is about to make and the other transaction is a changed transaction.
So that is the leftover change with Alice is going to receive back.
And as we are using the principles, we are making sure that Alice have a transaction which she can
use in future to make many more transactions.
So let's say now Alice is sending this, so we will take this transaction house.
Alice sends two coins to Bob and give this transaction to Bob.
So now Bob also has a transaction to use and send across different coins on top of the blockchain platform,
and Alice sends eight coins to Bob.
This we will store here.
This transaction, which was initially received by Alice, will now be archived and confirmed, so this
will be Archived transaction in case of Bitcoin blockchain.
Normally we can also call it as a use transaction.
So now nobody else can use this transaction to make future transaction, but this will be kept immutably
inside the bitcoin blockchain.
So auditability is maintained and transparency is achievable inside Bitcoin blockchain.
So that's the case about the Bitcoin blockchain.
With Ethereum blockchain, we don't use the show's principle, but we use instead we use the accounts.
Principle accounts are basically similar to your payment apps, so you might have used Google Pay or
Apple Pay.
So these are the apps which provides you the similar kind of structure as Ethereum.
So everyone, Alice, Bob, Dave, they will have their own account storage associated with them.
This account storage is holding the tokens which Alice, Bob or Dave are part of.
So any smart contract they are part of any ethers they are holding, all those will be part of these
account storage.
Let's say Alice is holding four ether, so four ethers will be part of this.
Then Bob is holding two ethers that will be part of this.
And let's say Dave is not holding anything apart from this Smart contract tokens will be also part of
account storage itself.
So let's say if Alice is part of a smart contract, which is selling cars, so she has two car tokens,
so car tokens will be part of this account storage.
Similarly, Bob is part of Apple, so he has 100 Apple tokens associated with him.
So all these different tokens and ethers will be part of the account storage.
And it's very similar to how the payment application works where we have the wallet system.
If Alice is sending anything across, let's say Alice is sending two ethers to Bob, then from the account
storage of Alice, this will be deducted to two.
And for the bob this will be added with the two.
So in this way the account storage for Ethereum works.
Apart from this, as I already told you, that Ethereum blockchain has the core concepts similar to
Bitcoin blockchain, but a main functionality which Ethereum blockchain provides is related to the smart
contracts.
How smart contracts work.
Smart contracts work in the similar fashion as a normal transaction.
In case of Bitcoin blockchain, let's say you have a user, let's say Alice is there and Alice is going
to create a new smart contract related to selling of pens.
So Alice is creating a new smart contract.
For sale of pens.
So this smart contract, she is going to call it as.
Pen smart contract and she's writing this smart contract in solidity language.
Once the smart contract is written, once all the functions have been provided, Alice creates a new
transaction which is going to be posted on the Ethereum node.
This transaction is a special transaction because this transaction will have a flag which gives us that
the coming transaction has the contract code associated with it.
So Alice is going to create a new transaction which will have a flag which will say this is a smart
contract transaction.
Apart from this, this transaction which Alice has created will also have another thing which is called
metadata associated with transaction.
This metadata, in case of our Smart contract transaction, will be hosting the smart contract code
itself.
So the smart contract code which we are developing will be part of the transaction as metadata.
So now Alice has created this transaction with a specific flag and the metadata as the smart contract
code.
This transaction is sent to the Ethereum node.
Ethereum node receives this transaction and see that a flag of smart contract is added to the same Ethereum
node already has the Ethereum virtual machine running with it.
Ethereum Virtual Machine is like a compiler which compiles the smart contract code into the executable
code.
So Ethereum virtual machine sees that this is the smart contract code which we have received inside
the transaction metadata.
It takes out the code from the metadata from the transaction compiles the code into an executable format
and stores it back inside the transaction metadata.
So Ethereum node, which is receiving the transaction from the application, is going to take up the
code which is present with the metadata, compile it and store it back within the metadata as the executable
code.
So that's the process with Bitcoin.
If you remember, inside the Bitcoin architecture, the application directly submits the transaction
to a node.
This node has the connection engine storage, engine validation engine working with it, and it makes
sure that the transaction is added to the transaction memory pool.
And from there the miners can work on it.
But with the Ethereum case, the application which Alice is using is submitting the transaction to the
Ethereum node.
Currently, the transaction is not part of the transaction memory pool.
The first thing which happens is that Ethereum virtual machine comes into an effect and it takes out
the transaction, metadata compiles it generates a binary format for the code and store it back inside
the transaction.
So Ethereum node changed the transaction and now this transaction has the metadata as in the compiled
code.
So now this is a new transaction which is formed.
Once this is done, this transaction is added to the memory pool and then the concepts are very similar
to Bitcoin blockchain where the transaction will be part of the memory pool from memory pool, the miners
will start working on it.
Miners will take the transactions, verify it and then store it inside the block.
And then once the block has been formed, this block is going to be broadcasted over the blockchain.
So in this way, a new smart contract is uploaded on top of the Ethereum blockchain.
Once this is done, the smart contract code is immutably present over the blockchain.
Let's say we have different blocks running in and we were at block 98 and this smart contract came at
block 99.
So apart from account storage, there is also a hidden storage present with Ethereum blockchain and
this hidden storage is known as contract storage.
Every user who is creating an account on top of Ethereum blockchain will always have two storage.
One is account storage, holding the tokens and the other is the contract storage.
Contract storage is going to hold the executable code which this user is part of.
So it's not going to be that every time a user is making a function call for a smart contract, we are
going to fetch the data from the blockchain.
It's more of a feature where once the user makes a function call to the smart contract, the executable
code of the smart contract is stored back inside the contract storage.
So now we don't need to go back to the blockchain and do the complete iteration to find the smart contract
and run the function from it.
We can directly call up the function from the contract storage.
So let's say Alice was part of Car Token.
So that means inside contract storage.
She has car smart contract.
Now she has created a new smart contract pen, smart contract.
So that is also part of contract storage.
So all the executable part is present with the contract storage.
Similarly, Bob will also have the same contract storage and this contract storage will be as per what
Bob is part of.
So Bob is part of Apple Token.
So he will be part of Apple Smart contract let's say.
Now Bob wants to be part of the pen smart contract too.
He sees that the block 99 is holding the pen smart contract.
So what he does, he creates a transaction.
This transaction could be initiating the smart contract or buying any tokens from the smart contract
or purchasing any pens, whatever he's trying to do.
He creates a transaction against it.
Let's say he has bought some pen tokens from the Pen Smart contract.
The first time he does that, the Pen Smart contract will be taken from the transaction metadata and
stored it with the contract storage of Bob, and the Pen tokens will be added to the account storage.
Let's say he bought 50 pen tokens, so that will be added to the account storage for Bob.
So in this way the complete process of Ethereum blockchain architecture is working.
Again, if you look into the process, you will see that there are many components which are interacting
to form the complete platform architecture and you can replace different components as per your enterprise
applications or as per your requirements for the projects.
You can also see the comparison of Bitcoin and Ethereum blockchain architecture with this image.
As you can see in Bitcoin, we are using the principles, so everybody needs to have a transaction to
create a future transaction.
So let's say the previous state was 920 BTC for these two different addresses and a new transaction
has to be created.
So they are going to utilize the previous transactions to create the new transactions and then submit
on top of Bitcoin blockchain.
But with Ethereum we are not taking up the access principle.
We are directly taking in the account stages.
So if you see here we have nine, 20 ethers and 30 ethers and if we want to create a new transaction,
this transaction is not linked.
As a UT Texas, we are not going to take the history of the transactions we are directly taking in the
account states, modifying the account states and the transactions are separately recorded on top of
Ethereum blockchain.
But with Bitcoin blockchain, the state of the addresses remains the same as they are immutably stored.
We just update the flag that this is now a consumed transaction so nobody else can consume it.
And we create a new transaction which is known as now unspent transaction output or unconsumed transaction
which the account holders can use to make future transactions.
Another major blockchain platform which we are going to study next is the Hyperledger Fabric Blockchain
platform.
Now let's go and analyze Hyperledger fabric blockchain architecture and see how and see how Hyperledger
fabric blockchain works.