SlideShare a Scribd company logo
Lucien Lee
Blockchain 101 for Frontend Engs
前端工程師也可以懂的區塊鏈
2021
Lucien Lee・鹿尋
2
Tech Lead
Dapps Fullstack Eng
The first Taiwanese Defi
CEO Co-founder
The largest crowdsourcing
fact-check platform in Asia
PREVIOUS
What is Blockchain?
3
a semantic overloaded word
4
We only discuss this today
So blockchain is a P2P Network that…
5
Public Permissionless
Distributed
Decentralized Immutable
Unforgeable
Data Storage Compute Engine
+
You can believe the justification of computing
on this P2P Network
6
Robust Public
Trust(less)
Machine
Ledger
7
Data Storage
How to achieve that
Unforgeable
8
Public-key cryptograph
Digital Signature
How to achieve that
Immutable
9
Block Hash Chain
https://andersbrownworth.com/blockchain/
How to achieve that
Decentralized
10
Kademlia
Msg exchange
consensus
POW, POS, PBFT…
Example of ETH Tx
POW version
11
1. A user init an TX
2. Input Tx Info in wallet,
3. Sign TX with private key
4. Broadcast “Signed Tx” to nearby ETH node
Broadcast to
( nearby ) node
4
Creat a Tx
Steve
0x123… 0x321… ether
FROM
Dave
TO
12
AMOUNT
10
gwei
GAS PRICE
units
21,000
GAS LIMIT
Welcome to Pelith! …
INPUT DATA
Tx Signature
3
Wallet
Private Key
Steve
2
1
12
State Database
SQL
BALANCE
( ether )
ADDRESS
34
16
9
Steve
Dave
W
130
X
0.7
Y
0.02
Z
9
First Miner finding out the “nonce”
Generate new block and get the ETH award
Tx Pool
Filtered by “Gas Price”
Tx
Gas Limit
Gas Price
W X 3.5
Y Z 0.7
Depoly
Contract
Call
Contract
I J 25
S D 12
21,000
21,000
21,000
500,000
120,000
21,000
11
10
10
8
8
7
Check Status
5 Join Wait List
6 Executed in EVM
8
( ≈ 2.4 TB )
Node
7
New
Block
Calculating “nonce” for block <PoW>
(Competing with other nodes)
Total Gas Limit < 8,000,000
EVM
Ether Balance Updated
Smart Contract Deployed / Called
1 Block ≤ 8M Gas
Blockchain
New
Block 8660586
Block 8660585
Block 8660584
5. Check the balance
6. Put Tx in the pool
7. Nodes keep broadcast and received new Tx
8. Nodes select more tips tx, calc and prepare
to pack them into new block
9. Mine the block
13
Node
Node
Node
Node
Node Node
Node
Node
Node
Node
Broadcast with each other
to update latest status
10
P2P Network
11 12
10. Broadcast the new block to the network
11. Nodes sync the new block, state and Tx pool
12. Loop
Smart Contract
14
Computing Engine
Code is Rule
Resistance to Censorship
Verifiable Behavior
It’s like serverless Architecture
Function-as-a-Service
15
Source: https://medium.com/@tanmayct/serverless-architecture-function-as-a-service-19e127b8c990
16
Todo App as example
const { AWS } = require('../connection');


const docClient = new AWS.DynamoDB.DocumentClient();


exports.getTodo = async function (event, context) {


let response;


let todoId;


const table = "Todos";


if (event.body) {


let body = JSON.parse(event.body);


todoId = body.id;


}


const params = {


TableName: table,


Key: {


"id": todoId,


}


};


try {


const data = await docClient.get(params).promise();


response = {


'statusCode': 200,


'body': JSON.stringify({


message: data,


})


}


} catch (err) {


response = {


'statusCode': 400,


'body': JSON.stringify({


message: err,


})


}


}


return response;


}
getTodo
17
Cost is based on actual execution time
18
Cost is based on sum of opcode, storage usage, message call…
19
Dapps Architecture
20
RPC, Remote Procedure Call
balanceOf(address)
0x70a08231b98ef4ca268c9c……db06bb5d45e689f2a360be
8
sha3
{

"jsonrpc":"2.0"
,

"method":"eth_call"
,

"params":
[

{

“to":"<contract address>"
,

"data":"0x70a08231<arg>
"

}
,

"latest
"

]
,

“id":
1

}
Post to RPC endpoint
Why we need trust(less) computing
Loot drop rate is a blackbox
21
How does JS get involved in blockchain?
22
Dapps
The UI for users interacting with blockchain
23
Why Frontend Engs are so important?
Put an elephant into refrigerator
24
Gas fee too expensive Lightweight Backend
Move user-friendly logic to FE
Isomorphic-like app


solidity <-> JS/TS
contract blockchain
TypeChain, @symfoni/hardhat-react
Script / Arbitrage
25
What’s good scenario of blockchain?
26
Assets
To incentivize validators, blockchain network native has money system
Contact
27
Email
lucien@pelith.com
We’re hiring engineers!
cakeresume.com/companies/pelith/jobs
Facebook
facebook.com/lucienlee.deer

More Related Content

PDF
Blockchain Interview Questions and Answers | Blockchain Technology | Blockcha...
PDF
Blockchain Explained | Blockchain Simplified | Blockchain Technology | Blockc...
PDF
PDF
Blockchain Developer | How to Become a Blockchain Developer? | Blockchain Tra...
PDF
BlockChain Tutorial | Getting Started With BlockChain | BlockChain Certificat...
PPTX
Blockchain Tutorial For Beginners - 2 | Blockchain Technology | Blockchain Tu...
PDF
Blockchain for Graduates | Technical Explanation
PPTX
Blockchain workshop 101
Blockchain Interview Questions and Answers | Blockchain Technology | Blockcha...
Blockchain Explained | Blockchain Simplified | Blockchain Technology | Blockc...
Blockchain Developer | How to Become a Blockchain Developer? | Blockchain Tra...
BlockChain Tutorial | Getting Started With BlockChain | BlockChain Certificat...
Blockchain Tutorial For Beginners - 2 | Blockchain Technology | Blockchain Tu...
Blockchain for Graduates | Technical Explanation
Blockchain workshop 101

What's hot (20)

PDF
Blockchain tutorial for MBA
PDF
Bitcoin Blockchain Explained | Understanding Bitcoin and Blockchain | Blockch...
PPTX
Blockchain Explained | How Does A Blockchain Work | Blockchain Explained Simp...
PDF
Basic blockchain
PDF
1. ibm blockchain explained
PPTX
Blockchain
PDF
Blockchain
PPTX
The Blockchain, Bitcoin and other Cryptocurrencies
PPTX
Testing in the blockchain
PDF
Security in the blockchain
PDF
BigchainDB and Beyond
PDF
Blockchain
PPTX
The Cloud is dead ?! Blockchain in the new cloud
PPTX
Deja vu Security - Blockchain Security Summit - Adam Cecchetti
PDF
Blockchain overview, use cases, implementations and challenges
PPTX
01 what is blockchain
PPTX
Transaction speed
PPTX
Blockchain 101
PDF
List of best Open Source Blockchain platforms
PDF
Blockchain
Blockchain tutorial for MBA
Bitcoin Blockchain Explained | Understanding Bitcoin and Blockchain | Blockch...
Blockchain Explained | How Does A Blockchain Work | Blockchain Explained Simp...
Basic blockchain
1. ibm blockchain explained
Blockchain
Blockchain
The Blockchain, Bitcoin and other Cryptocurrencies
Testing in the blockchain
Security in the blockchain
BigchainDB and Beyond
Blockchain
The Cloud is dead ?! Blockchain in the new cloud
Deja vu Security - Blockchain Security Summit - Adam Cecchetti
Blockchain overview, use cases, implementations and challenges
01 what is blockchain
Transaction speed
Blockchain 101
List of best Open Source Blockchain platforms
Blockchain
Ad

Similar to [JSDC 2021] Blockchain 101 for Frontend Engs (20)

PPTX
Introduction to Blockchain Web3 Session
DOCX
Blockchain based Banking System
PDF
tezos_hands-on-training.pdf
PPTX
Blockchain. A Guide For Beginners
PDF
Introduction to Ethereum Blockchain & Smart Contract
PDF
leewayhertz.com-How to build a dApp on Avalanche blockchain
PDF
New Business Models enabled by Blockchain
PDF
Muduo network library
PPTX
Consensus Algorithms - Nakov @ jProfessionals - Jan 2018
PDF
Kubernetes: My BFF
PDF
How to Build a Decentralized Cloud Computing Platform?
PDF
2019 blockchain economy
PDF
Block chain 101 what it is, why it matters
PDF
Blockchain IoT Night / 25th Oct 2017
PPTX
BlockChain for the Banker
PDF
Token platform based on sidechain
PDF
OpenSSL Basic Function Call Flow
PDF
Introducing Moonbeam: A Smart Contract Parachain with Ethereum Compatibility
PPTX
EthereumBlockchainMarch3 (1).pptx
PDF
10 Best Programming Languages for Blockchain in 2023.pdf
Introduction to Blockchain Web3 Session
Blockchain based Banking System
tezos_hands-on-training.pdf
Blockchain. A Guide For Beginners
Introduction to Ethereum Blockchain & Smart Contract
leewayhertz.com-How to build a dApp on Avalanche blockchain
New Business Models enabled by Blockchain
Muduo network library
Consensus Algorithms - Nakov @ jProfessionals - Jan 2018
Kubernetes: My BFF
How to Build a Decentralized Cloud Computing Platform?
2019 blockchain economy
Block chain 101 what it is, why it matters
Blockchain IoT Night / 25th Oct 2017
BlockChain for the Banker
Token platform based on sidechain
OpenSSL Basic Function Call Flow
Introducing Moonbeam: A Smart Contract Parachain with Ethereum Compatibility
EthereumBlockchainMarch3 (1).pptx
10 Best Programming Languages for Blockchain in 2023.pdf
Ad

More from Lucien Lee (9)

PDF
【真的假的 Cofacts】事實查核案例分享
PDF
Start Prototyping From Keynote
PDF
[HackCampus] 圖書館自習區體驗設計-行政及閱覽組回饋篇
PDF
[HackCampus] 圖書館自習區體驗設計-探索篇
PDF
Hack the hacking
PDF
Multidisciplinary @NTUIM
PDF
智慧家庭音樂體驗設計工作坊
PDF
CSS 開發加速指南-Sass & Compass
PDF
初心者 Git 上手攻略
【真的假的 Cofacts】事實查核案例分享
Start Prototyping From Keynote
[HackCampus] 圖書館自習區體驗設計-行政及閱覽組回饋篇
[HackCampus] 圖書館自習區體驗設計-探索篇
Hack the hacking
Multidisciplinary @NTUIM
智慧家庭音樂體驗設計工作坊
CSS 開發加速指南-Sass & Compass
初心者 Git 上手攻略

Recently uploaded (20)

PPTX
Current and future trends in Computer Vision.pptx
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
additive manufacturing of ss316l using mig welding
PPTX
Artificial Intelligence
PPT
Mechanical Engineering MATERIALS Selection
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
web development for engineering and engineering
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PDF
Well-logging-methods_new................
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPT
introduction to datamining and warehousing
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
UNIT 4 Total Quality Management .pptx
Current and future trends in Computer Vision.pptx
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
additive manufacturing of ss316l using mig welding
Artificial Intelligence
Mechanical Engineering MATERIALS Selection
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
web development for engineering and engineering
CYBER-CRIMES AND SECURITY A guide to understanding
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Internet of Things (IOT) - A guide to understanding
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Operating System & Kernel Study Guide-1 - converted.pdf
Well-logging-methods_new................
Automation-in-Manufacturing-Chapter-Introduction.pdf
introduction to datamining and warehousing
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
OOP with Java - Java Introduction (Basics)
UNIT 4 Total Quality Management .pptx

[JSDC 2021] Blockchain 101 for Frontend Engs

  • 1. Lucien Lee Blockchain 101 for Frontend Engs 前端工程師也可以懂的區塊鏈 2021
  • 2. Lucien Lee・鹿尋 2 Tech Lead Dapps Fullstack Eng The first Taiwanese Defi CEO Co-founder The largest crowdsourcing fact-check platform in Asia PREVIOUS
  • 3. What is Blockchain? 3 a semantic overloaded word
  • 4. 4 We only discuss this today
  • 5. So blockchain is a P2P Network that… 5 Public Permissionless Distributed Decentralized Immutable Unforgeable Data Storage Compute Engine +
  • 6. You can believe the justification of computing on this P2P Network 6 Robust Public Trust(less) Machine
  • 8. How to achieve that Unforgeable 8 Public-key cryptograph Digital Signature
  • 9. How to achieve that Immutable 9 Block Hash Chain https://andersbrownworth.com/blockchain/
  • 10. How to achieve that Decentralized 10 Kademlia Msg exchange consensus POW, POS, PBFT…
  • 11. Example of ETH Tx POW version 11 1. A user init an TX 2. Input Tx Info in wallet, 3. Sign TX with private key 4. Broadcast “Signed Tx” to nearby ETH node Broadcast to ( nearby ) node 4 Creat a Tx Steve 0x123… 0x321… ether FROM Dave TO 12 AMOUNT 10 gwei GAS PRICE units 21,000 GAS LIMIT Welcome to Pelith! … INPUT DATA Tx Signature 3 Wallet Private Key Steve 2 1
  • 12. 12 State Database SQL BALANCE ( ether ) ADDRESS 34 16 9 Steve Dave W 130 X 0.7 Y 0.02 Z 9 First Miner finding out the “nonce” Generate new block and get the ETH award Tx Pool Filtered by “Gas Price” Tx Gas Limit Gas Price W X 3.5 Y Z 0.7 Depoly Contract Call Contract I J 25 S D 12 21,000 21,000 21,000 500,000 120,000 21,000 11 10 10 8 8 7 Check Status 5 Join Wait List 6 Executed in EVM 8 ( ≈ 2.4 TB ) Node 7 New Block Calculating “nonce” for block <PoW> (Competing with other nodes) Total Gas Limit < 8,000,000 EVM Ether Balance Updated Smart Contract Deployed / Called 1 Block ≤ 8M Gas Blockchain New Block 8660586 Block 8660585 Block 8660584 5. Check the balance 6. Put Tx in the pool 7. Nodes keep broadcast and received new Tx 8. Nodes select more tips tx, calc and prepare to pack them into new block 9. Mine the block
  • 13. 13 Node Node Node Node Node Node Node Node Node Node Broadcast with each other to update latest status 10 P2P Network 11 12 10. Broadcast the new block to the network 11. Nodes sync the new block, state and Tx pool 12. Loop
  • 14. Smart Contract 14 Computing Engine Code is Rule Resistance to Censorship Verifiable Behavior
  • 15. It’s like serverless Architecture Function-as-a-Service 15 Source: https://medium.com/@tanmayct/serverless-architecture-function-as-a-service-19e127b8c990
  • 16. 16 Todo App as example const { AWS } = require('../connection'); const docClient = new AWS.DynamoDB.DocumentClient(); exports.getTodo = async function (event, context) { let response; let todoId; const table = "Todos"; if (event.body) { let body = JSON.parse(event.body); todoId = body.id; } const params = { TableName: table, Key: { "id": todoId, } }; try { const data = await docClient.get(params).promise(); response = { 'statusCode': 200, 'body': JSON.stringify({ message: data, }) } } catch (err) { response = { 'statusCode': 400, 'body': JSON.stringify({ message: err, }) } } return response; } getTodo
  • 17. 17 Cost is based on actual execution time
  • 18. 18 Cost is based on sum of opcode, storage usage, message call…
  • 20. 20 RPC, Remote Procedure Call balanceOf(address) 0x70a08231b98ef4ca268c9c……db06bb5d45e689f2a360be 8 sha3 { "jsonrpc":"2.0" , "method":"eth_call" , "params": [ { “to":"<contract address>" , "data":"0x70a08231<arg> " } , "latest " ] , “id": 1 } Post to RPC endpoint
  • 21. Why we need trust(less) computing Loot drop rate is a blackbox 21
  • 22. How does JS get involved in blockchain? 22
  • 23. Dapps The UI for users interacting with blockchain 23
  • 24. Why Frontend Engs are so important? Put an elephant into refrigerator 24 Gas fee too expensive Lightweight Backend Move user-friendly logic to FE Isomorphic-like app 
 solidity <-> JS/TS contract blockchain TypeChain, @symfoni/hardhat-react
  • 26. What’s good scenario of blockchain? 26 Assets To incentivize validators, blockchain network native has money system