Everything You Need to Know About Smart Contracts!

in LeoFinance3 years ago (edited)

Greetings amazing people!
In today’s blog, we will be breaking down smart contracts, from their history, and composition to their working. Everything you need to know as a beginner trying to understand smart contracts.

1_xIzdc_FVszgB3cCaqMd5ZQ.png
Source

Intro
To understand smart contracts you need to first understand what a blockchain is (check out one of my previous blogs on blog chain for more information on it ).In short think of it as multiple blocks that store
data and a hash (for each block). The blocks are connected so that the hash of a certain block depends on the previous block.
This “BlockChain “ acts as a public ledger of transactions that occur on a particular network. The idiosyncratic part of the blockchain is that it is decentralized hence a lot of issues that arise due to middlemen are eliminated.

Breaking it Down
Smart Contracts is one of the most utilised applications of the blockchain. According to google, the concept of smart contract was first introduced in 1994 by Nick Szabo (who was a cryptographer). In simple terms smart contract is a contract( composed of a code[Solidity in terms of Ethereum network]) that can be converted to code and run within a blockchain. Ethereum is the most used network/platform used for deploying smart contracts. Like I mentioned above its code is concealed within a contract, This code checks if a condition of the contract is met or not(if statement…..if condition ‘a’ is met then action ‘A’ is performed . eg if crypto is transferred then send money to this address), If the condition is satisfied then can exchange crypto(any asset) or perform a function within the network.

Mint_and_Transfer_of_Entity_Token_in_Smart_Contract.png
Source
When we all create accounts on meta mask, We can perform transactions on a particular chain using that account. A smart account is an entity (account) that can be automatically executed based on the predetermined rules are in the contract. Smart contacts are used in places where we need the consent of a few parties……usually in a crypto lottery( to choose a random no. once all the crypto is locked),nfts minting, games, etc. This makes the entire process much more trustworthy.
Composition
Finally, before we break down the smart contract completely let’s understand, what a transaction is? Transaction on a chain has 4 main components

  1. Nounce: it’s a serial number
  2. To: to whom is the amount is being sent to
  3. Value: is the value being sent
  4. V/R/S: This is a complex concept, here your private key generates v, r and s values which in turn produce an intermediate code. This intermediate code can derive your account number but not reproduce your private key/

pasted-image-0.png
Source
A smart contract is similar to a transaction but it is controlled by a code as mentioned above. The components of the smart contract are :

  1. CODE( the condition for it to execute)
  2. balance: the amount of money present in the contract
  3. storage: any type of data the application uses

Also, there’s one major difference between a smart contract and a transaction. The transaction with the same account can be made on multiple networks but a smart contract can only be used on one network once it’s deployed.

Hope you learned something new from this blog. Lemme know your thoughts on this topic in the comments :^)

Sort:  

Congratulations @the-prithvi! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s):

You received more than 2000 upvotes.
Your next target is to reach 2250 upvotes.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Check out the last post from @hivebuzz:

Our Hive Power Delegations to the March PUM Winners
Feedback from the April 1st Hive Power Up Day
The fourth edition of Hive Power Up Month started today. Don't miss it!
Support the HiveBuzz project. Vote for our proposal!