Learn BlockChain Development with me #1: Introduction to Blockchain and Smart Contract

in #blockchain7 years ago (edited)

Recently, I just got started learning blockchain development. Therefore, I am going talk about basic blockchain concept and smart contract.

Blockchain development

In this post, I would mainly use ethereum and bitcoin to explain how blockchain works.

Topic cover

  • Basic blockchain concept
  • Smart Contract

Basic concept of Blockchain

Why is it called BlockChain?

Blockchain is pass by 1 block to another block


blockchain1.png

  • In block N, it contains transactions
  • In block N+1, it contians transactions and part of signature and block N
  • In block N+2, it contains transactions and part of signature of block N+1

The first block

The first block is called the genesis block which is configured in genesis.json. The genesis block is often hardcoded into the applications that use block chain. [1]

In the main-net, every block is connected to existing blockchain.

For private network (normally for development purpose), the block chain are in full control, which means the network can be defined by the owner because there is only a node (or more nodes).

In genesis block perspective, the block chain started like this:


blockchain2.png

  • In block 1, it is the first block / genesis block
  • In block 2, it contains transaction and part of signature of Block 1
  • In block 3, it contains transaction and part of signature of Block 2

How new block created?

For ethereum and bitcoin, new block is created by miners. The miners is running server that trys to solve a hard calculation to verify the transactions. The calculation for solving by using a lot of computing power.

Both Bitcoin and Ethereum used Proof-of-work concept.

Proof of work means that piece of data is hard to produce but very easily to be verify. [2]

How is transaction created?


blockchain3.png

Assume you want to make 1 ether transaction, you first set up the amount to send, the sign it with private key. The valid transaction is created after that, and it will send to the network. When the next block is mined, the transaction will then be included into the blockchain.

ether is the currency called for ethereum cryptocurrency.

How to store blockchain?

Using a wallet, which is a private and public key pair.

Private key are just like how ssh works. In case you are not familiar with ssh, public key and private key pair will be generated.

The private key is use to sign transactions, and should be kept as secrete.

The public key which is derived from the private key are used to verify transactions. There is almost not possible to retrieve private key from public key.

Wallet address also derived from public key.

Where is blockchain located?

Blockchain is a constantly growing "ledger" of transaction information. The database are massively distributed, which we called the data to be decentralized. So, the data/blockchain can be stored on many computers of the blockchain user around the world.

Using Geth, a Golang implementation for ethereum, you can download the whole chain.

Smart Contract

Smart contract is a contract that helps to exchange with transparent and conflict-free way (to avoid man in the middle service) [3] You can read more about it here.

Programming language for Smart Contract

These languages compiled down to Ethereum Virtual Machine (EVM) Assembly

  • Solidity
  • Serpent
  • LLL

Screen Shot 2018-01-20 at 7.14.37 PM.png

An example on how smart contract looks like from OpenSourceUniversity

From this smart contract, you can see that the contract consist of:

  • Data type (UInt, Boolean, Array, Struct, Mapping, Address)
  • Class like structure
  • Functions
  • Event
  • If/Else
  • Loops (While/For)
  • Inheritance
  • Import

Deployment

To make our smart contract into deployment, there is a few necessary steps on how it works.

First, Creation of Smart Contract. Smart Contract is the very high level language like Solidity(Syntax like JavaScript).

Once the Smart Contract is done, it will be compiled into bytecode which is a very low level codes that can be understand by machine, which runs on EVM.

Then, the byte code will send over the network. These transactions has no receiver and contains only data. Deploy the contract to the network and give it an address.

Interaction

Once the contract is deployed, we can interact with the contract.

We send a data field while sending an transaction.

On client side, it make use of Application Binary Interface (ABI) which is used to interact of the contract. ABI is in JSON format, which contains all the necessary information to interact with the contract.

Smart Contract are immutable (meaning it should be unchanged over time)

REFRENCE

  1. https://en.bitcoin.it/wiki/Genesis_block
  2. https://en.bitcoin.it/wiki/Proof_of_work
  3. https://blockgeeks.com/guides/smart-contracts/


superoo7.png

APP.png

Sort:  

Come on man! Cheering you and 100% encourage you on blockchain development!

just started like today. Wanna know more then try and explore other stuff like iota or nem

Congratulations! This post has been upvoted from the communal account, @minnowsupport, by superoo7 from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, theprophet0, someguy123, neoxian, followbtcnews, and netuoso. The goal is to help Steemit grow by supporting Minnows. Please find us at the Peace, Abundance, and Liberty Network (PALnet) Discord Channel. It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.

If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: 50SP, 100SP, 250SP, 500SP, 1000SP, 5000SP.
Be sure to leave at least 50SP undelegated on your account.

This post is sponsored by @appreciator in collaboration with #steemitbloggers. Keep up the good work

Thank you appreciator

I tried to read but as a result my head is spinning....kudos on the effort though!

Thanks for reading through haha. It is a bit technical, I try to understand how ethereum smart contract works and then gonna study a bit on other technology.

I know the basics by watching youtube videos, but you lost me starting from EVM haha

Basically when you want to do smart contract, ethereum already done the hard stuff for you. So, you use some high level programming language, to state how the smart contract looks like. The high level programming language will be compiled to Assembler, a low level language that can be understand by Ethereum Virtual Machine (EVM), then you can deploy it.

OK....umm...yea....I'm just gonna sit in a corner there and be quiet :P

haha...thanks for that straight forward laymen's terms break down of the blockchain and smart contracts. the code language still makes my head go a bit wonky. but you certainly made it more digestible than i have seen thus far. cheers for that!

The code language a bit hard to explain for those who are not familiar to code, so I just brief through that haha. Thanks for finding it useful!

Thank you@superoo7 for your explanation, this post will surely prove to be useful to many users :)

Thanks for finding it useful

Coin Marketplace

STEEM 0.17
TRX 0.16
JST 0.029
BTC 76408.37
ETH 2936.47
USDT 1.00
SBD 2.63