cyfuer

Jun 15, 2022

学习笔记:《Full Stack Blockchain Lesson 1:Blockchain Basic》

 

What is a blockchain?

Bitcoin

bitcoin was one of the first protocols to use this revolutionary technology called blockchain.
the bit coin white paper was created by satoshi nocomoto, and an outlined how bitcoin can make peer to peer transactions in a decentralized network.
people took to this as a superior digital store of value(like gold).
 
bitcoin was the first protocol to take this blockchain technology into the limelight and take thes cryptocurrencies into the mainstream.
bitcoin is a sort of digital gold or a store of value able to make transactions between users in a decentralized manner.
 

Etherum

in 2015 vaitallic butterin and a number of other co-founders released the project etherum, where people could not only make decentralized transactions, but decentralized agreements、decentralized organizations and all these other ways to interact with each other without a centralized intermediary or centralized governing force.
take this thing that made bitcoin so great and add decentralized agreements or smart contracts.
 
etherum and other smart contract platforms take this blockchain technology one step further. enabling people to make smart contract and decentralized trust minimized agreements.
 
smart contract and decentralized applications can access and interact with the real world using something called decentralized oracle networks(去中心化预言机网络).
chainlink is a decentralized network that allows us to build these hybrid smart contracts which combines our on chain logic with our off chain decentralized data and decentralized computation. giving rise to our logic being completely decentralized and our data an external computation being completely decentralized. giving us all the features that traditional agreements and traditional contracts have.
 
 

Smart Contracts

Smart Contracts are a set of instructions executed in a decentralized way without the need for a centralized or third party intermediary.
 
easiest way to sum up what these smart contracts do is that they create trust minimized agreenments. a much easier way to think about it is just they give rise to unbreakable promises.
 

Web3

Web1: The permissionless open sourced web with static content. Web2: The permissioned web, with dynamic content. Where companies run your agreemens on their servers. Web3: The permissionless web, with dynamic content. Where decentralized censorship resistant networks run your agreement and code. It generally is accompanied by the idea of user owned ecosystems, where the protocols you interact with you also own a portion of. instead of solely being the product.
 
 

The purpose of Smart Contracts

a smart contract is an agreement, contract, or set of instructions that is deployed on a decentralized blockchain.
 
other features that smart contracts have over our traditional environment:
  1. Decentralized
  1. Transparency and Flexibility
  1. Speed & Efficiency
  1. Security & Immutability
  1. Counterparty Risk Removal
  1. Trust Minimized agreements
 

Defi

decentralized finance, it gives users the ability to engage with finance and markets without having to go through a centralized intermidiary.
 

DAOs

decentralized autonomous organizations, are group that are governed completely decentralized by set of instructions or smart contracts on chain.
 

NFTs

nonfungeable tokens, can be kind of described as digital art or just a unique asset
 

Your First Transaction

notion image
 
notion image

Transaction Info

 
Transaction Hash
a unique identifier for this blockchain that identifies this exact transacion
 
Transaction Fee
amount paid to the miner for processing the transaction
 
Gas Price
cost per unit of gas specified for the transaction, in Ether and Gwei. The higher the gas price the higher chance of getting included in a block.
1 Ether = 1000000000 Gwei = 1000000000000000000 Wei
 
Gas Fees
Base + Max Priority = Gas Price
 
Gas Limit
Maximum amount of gas allocated for the transaction
 
Usage by Txn
the amount eventually used.
Normal ETH transfers involve 21 ,000 gas units while contracts involve higher values.
The more people send transactions at the same time, the more expensive your gas costs are.
 
(Transaction Gas Fee) x (Gas Price) = (Transaction Fee)
 
Gas
A unit of computational measurement(计算度量单位).
The more complex your transaction is the more gas you have to pay.
 
 

How do Blockchains work?

 

Hash

A unique fixed length string, meant to identify a piece of data. They are created by placing said data into a "hash function".
Hash Algorithm
A function that computes data into a unique hash.
notion image
 

Block

blockchain miners were going through computationally process of trying to fund a nonce that fulfills whatever the problem is.
in this case, the block nonce and data all go through the hashing algorithm, and the problem is to find a nonce that allowed this hash to start with four zeros.
notion image
Mining
The process of finding the “solution” to the blockchain “problem”.
In our example, the “problem” was to find a hash that starts with four zeros.
Nodes get paid for mining blocks.
 
Block
A list of transactions mined together.
 
Nonce
A “number used once” to find the “solution” to the blockchain problem.
It’s also used to define the transaction number for an account/address.

Blockchain

 
notion image
Genesis Block
the block with the previus of all zeros is going to be known as the genesis block(创世块). The first block in a blockchain.
 
the block nonce、data and previous hash all go through this hashing algorithm to figure out what the hash is.
 

Signing

Public / Private Key Pairs
Private Key that randomly generated only known to the key holder, it’s used to “sign” transactions.
Public Key is derived by using elliptic curve digital signature algorithm on your private key. Anyone can "see" it, and use it to verify that a transaction came from you. It’s created by elliptic curve digital signature algorithm with Private Key.
Take public key, hash it using that same etherum hashing algorithm, and then take the last 20 bites. that’s how we actually derive to our address.
 
Signing a transaction A "one way" process. Someone with a private key signs a transaction by their private key being hashed with their transaction data. Anyone can then verify this new transaction hash with your public key.
 
Sign:(Private Key)+(Message) = (Message Signature) 【use elliptic curve digital signature algorithm】
Verify:(Public Key)+(Message Signature) = (Message)
notion image
notion image

High-Level Blockchain Fundamentals

Node

A single instance in a decentralized network.
 

Consensus(共识)

Consensus is the mechanism used to agree on the state of a blockchain
consensus protocol in a blockchain or decentralized system can be broken down into two pieces:
  1. a chain selection algorithm(链选择算法)
  1. a sybil resistance mechanism(公民抵抗机制)
 

chain selection

Nakamoto Consensus is a combination of proof of work and longest chain rule. the decentralized network decide that whichever block chain has the longest chain or the most number of block on it is going to be the chain that they use.
bitcoin and eth1 both use this.
 

sybil resistance

sybil resistance is a blockchain's ability to defend against users creating a large number of pseudo anonymous identities to gain a disproportionately advantageous influence
two type of sybil resistance:
  • poW(proof of work)
    • miners
  • poS(proof of stake)
    • validators
      avalanche、polygon、polka、terra、eth2.0
 

Attacks

Sybil Attack
the sybil attack is when auser creates a whole bunch of pseudo anonymous accounts to try to influence a network.
 
51% Attack
 

Scalabiity

Layer 1 refers to base layer blockchain implementation, such as bitcoin 、 etherum1.0 and avalanche.
Layer 2 is any application that is added on top of a layer 1, some examples of layer twos are going to be chain link、arbitrum、optimism.
 
two solution of scalabiity:
  1. Sharding(分片)
    1. There is a main chain that’s going to coordinate several chains that hook into this main chain.
 
  1. Rollups(汇总)
    1. roll up their transactions into a layer 1, arbitrum and optimism are known as this.
      they’re different from side chains, because side chains derive their security from their own protocols, roll ups their security from the base layers, so arbitram and optmism is going to be as secure as etherum.
 
ETH 1.0 and BTC are proof of work blockchains that follow nakamoto consensus.
ETH 2.0 will be proof of stake sharding blockchain.

Copyright © 2025 cyfuer

logo