SlideShare uma empresa Scribd logo
1 de 65
Kenneth Hu
• CTO at Baypay Inc
• I am enthusiast, not expert.
• Ethereum, Bitcoin,
• Email: Kenneth.hu@Hotmail.com
• Meetup
• Blockchain&Dapps meetup
• Singapore IOTA meetup
• Trainer
• Institute of Blockchain (previous)
• 0xAcademy
• BlockTec
Agenda
• Blockchain
• Consensus
• Public/Private Key
• Ethereum
• Ethereum account
• MetaMask
• Solidity
• MetaCoin
What is Blockchain
• Blockchain = Chain of Data Block
Distributed Ledger
Secure
Transactions are
verified by the
entire network
Decentralized
(no owner)
Immutable
Peer-to-Peer
Network
Nodes should
ledger of facts +
history of updates
How Blockchain work?
Ledger
Immutable
Transaction
Block
Chain
Mining
Consensus
What is transaction?
Kenneth Alice
$30 SGD
Transaction: “ is a transfer of value”
Ledger : “a collection of financial accounts or transactions”
Ledger
Kenneth Alice
#30
Amy Jen
#50
Immutable : The ledger cannot be changed. Ever!
What is ledger?What is Immutable?
What is block?
BLOCK
Block Header
Hash of previous
block header
Merkle root
Timestamp
Nonce
Transactions
Block : A block records some or all of the most recent transactions. Thus a block is like a
page of a ledger or record book.
帳本
Block header
BLOCK Header
Hash of previous
block header
Merkle root
Timestamp
Nonce
• Hash of previous block header
• Timestamp : It indicates when the
block was created.
• Merkle root : hash-based data
structure that is a generalization of the
hash list.
• Nonce :Counter used for the Proof of
Work algorithm. Each time you mine,
the nonce increases by 1 .
Merkle tree
Merkle trees are useful in synchronizing data across a distributed data store because
it allows each node in the distributed system to quickly and efficiently identify
records that have changed without having to send all the data to make the
comparison.
Merkle proofs in Bitcoin
Merkle proofs in Ethereum
• Transaction
• Receipts(essentially,
pieces of data showing
the effect of each
transaction)
• State
Merkle proofs in Ethereum
• Has this transaction been included in a particular block? –
Transaction
• Tell me all instances of an event of type X (eg. a crowdfunding
contract reaching its goal) emitted by this address in the past 30
days – Receipts
• What is the current balance of my account? – State
• Does this account exist? – State
• Pretend to run this transaction on this contract. What would
the output be? – State
Source : https://blog.ethereum.org/2015/11/15/merkling-in-ethereum/
Block
BLOCK 1
HEADER
Hash of previous
block header
Merkle root
Block 1
transactions
BLOCK 2
HEADER
Hash of previous
block header
Merkle root
Block 2
transactions
BLOCK 3
HEADER
Hash of previous
block header
Merkle root
Block 3
transactions
Blockchain
• Creating the candidate block
Mining
HASHING ( SHA256 )
Block’s Block header data
Hash of previous block
header
Merkle root
Timestamp
Nonce
No : (
Increment the nonce by 1.
Hash again!
Is hash (A8SBERA….) lower than the
target? (check the leading zeros)
YES! Problem Solved.
Proof of
Work
Difficulty in Bitcoin
• Difficulty is a measure of how difficult it is to find a hash below a given target
• The Bitcoin network has a global block difficulty. Valid blocks must have a
hash below this target. Mining pools also have a pool-specific share diffic
ulty setting a lower limit for shares.
• How often does the network difficulty change?
• Every 2016 blocks.
• What is the formula for difficulty?
• difficulty = difficulty_1_target / current_target
• (target is a 256 bit number)
Difficulty in Ethereum
• parentTimestamp - indicates the timestamp of a previous block
• parentDifficulty - indicates the difficulty of a previous block
• currentTimestamp - indicates the timestamp of a current block
• currentBlockNumber - indicates the number of a current block (previous block number = currentBlock
Number - 1)
• currentDifficulty -- indicates the difficulty of a current block
• Frontier:
• block_diff = parent_diff + parent_diff // 2048 * (1 if block_timestamp - parent_timestamp < 13 else -1)
+ int(2**((block.number // 100000) - 2))
• Homestead:
• block_diff = parent_diff + parent_diff // 2048 * max(1 - (block_timestamp - parent_timestamp) // 10,
-99) + int(2**((block.number // 100000) - 2))
Frontier Homestead Metropolis Serenity
• Block header hash is less than the target
• Block size is within acceptable limits
• Block timestamp is less than two hours in the future.
• The first transaction is a coinbase transaction ( and only the first )
• The coinbase transaction has a valid reward.
• All transactions within the blocks are valid ( also have a checklist on their
own )
Source : https://dev.to/damcosset/blockchain-what-is-mining-2eod
Validate the new block
Node
Time
David  Sandra 5 BTC
Brian  List 3.02 BTC
Mary  Sandra 10 BTC
Lisa  Sandra 10 BTC
Sandra  David 10 BTC
BLOCK #186
Block ID
0x0235de9a6
Previous Block
0x6e257071cec
Transactions
BLOCK #186
Block ID
0x6e257071cec
Previous Block
0x1dcc4de8dec
Transactions
BLOCK #186
Block ID
0x6e257071cec
Previous Block
0x1dcc4de8dec
Transactions
BLOCK #186
Block ID
0x6e257071cec
Previous Block
0x1dcc4de8dec
Transactions
BLOCK #186
Block ID
0x6e257071cec
Previous Block
0x1dcc4de8dec
Transactions
Blockchain network
Blockchain
Lisa  Sandra 10 BTC
Brian  List 5 BTC
Mary  Sandra 10 BTC
…… ……… .. BTC
What does “distributed” mean ?
Distributed: A distributed ledger is a database that is consensually shared and
synchronized across network spread across multiple node
Ledger
Ledger
Ledger
Ledger
Ledger Ledger
node
node
node
nodenode
node
What is Consensus Algorithm?
• Consensus algorithm (consensus protocol/ consensus mechanism)
• Algorithm to reach agreement among the blockchain nodes
• All nodes should agree about the changes in the distributed ledger
• Proof-of-work (PoW), Proof-of-stake, other algorithms
Demo
Ledger
Transaction/Mining/Sync
Ledger
Node 3 Node 1
Node 2
Node 4
Ledger
Ledger
• 1. submit a transaction
• 2. Mining & Validation
• 3. Sync to other node
Ledger
Consensus
Ledger
Node 3 Node 1
Node 2
Node 4
Ledger
Ledger
Ledger
Node 5
• 1. run new node (node 5)
• 2. join the network
• 3. Sync to other node
Consensus
Proof-of-Work (PoW)
• A “Proof-of-work” (PoW) is a piece of data which is
• Difficult to produce
• Easy for others to verify
• Producing a proof-of-work can be a random guessing process
or can be organized in mining pools (join PoW production)
• Example
• Find a number x, such that SHA256(text + x) has 10
leading zeroes.
• 10 zeroes == network difficulty
Proof-of-Work : Problems
• Needs computing power
• Computationally expensive
• Energy intensive
• 51% attack
• Attackers holding more than 50% of the power could potentially
reverse-back transactions (double-spend money) / deny service
• Hashing algorithm types for PoW consensus
• ASIC mineable (e.g. SHA256), CPU mineable (e.g. CryptoNight),
• GPU mineable (e.g. ETHash), CPU + GPU mineable (e.g. Equihash)
Proof-of-Work : Problems (2)
• Transactions speed – average wait time
• Bitcoin : new block mined in ~ 9-10 minutes
• Ethereum : new block mined in ~ 10-15 seconds
• Business needs real-time transactions ( milliseconds)
• Transactions throughput – transactions per second (tps)
• Bitcoin: 2000-3000 / transactions per block  3-5 tps ( up to 7 tps)
• Ethereum: 200-300 / transactions per block  10-15 tps
• Business needs thousands tps (e.g. VISA performs 2000 tps)
Proof-of-Work Cryptocurrencies
• Different cryptocurrencies use different hashing algorithms
• Bitcoin, Bitcoin Cash – SHA256 – ASIC mineable
• Ethereum, Ethereum Classic – ETHash – GPU mineable
• Zcash, Bitcoin Gold – Equihash – CPU and GPU mineable
• Monero – CryptoNight – CPU and GPU mineable
• Litecoin, Dogecoin – Scrypt – GPU mineable
• Dash – X11 – ASIC, CPU and GPU mineable
• Stratis – X13 – ASIC, CPU and GPU mineable
Proof of Stake (PoS)
• PoS is designed to increase network security and reduce resource
wasting
• The creator of the next block is chosen in
• Combination of random selection and wealth
• E.g. holding 1% of the coins gives the chance to verify (mine) 1%
of the “Proof of Stake blocks”
• The “Monopoly Problem”: a monopolist ( holder of the most coins)
could double spend or deny / filter other’s transactions
• Executing a monopoly attack is much more expensive than in
PoW
Popular PoS Cryptocurrencies
•Cardano – cardanohub.org
•Qtum – qtum.org
•PIVX – pivx.org
•BitConnect – bitconnect.co
•Stratis – stratisplatform.com
Proof of Authority
• Proof-of-Authority (PoA) assigns a set of trusted nodes
(authorities) to process transactions and build new blocks
• New blocks need to be signed by the majority of authorities
• Works very well in private blockchain (cross validation)
• Great performance, fast transactions, high throughput
• Examples:
• Ethereum Kovan Testnet – https://kovan.etherscan.io/
• Ethereum Rinkeby Testnet -- https://www.rinkeby.io/
Public / Private Keys
and Transaction
Public / Private Keys and Transaction
Wallet master
key (seed)
Private key Public key address
transaction Signed
transaction
Transaction data
Signature(v, r, s)
Public key :(x, y)
Sign by private key
signed
transaction
verify by address
Valid / invalid
Verify Message Signature in Etherscan
• Verify message signature at https://etherscan.io/verifySig by :
• Signer address (40 hex digits)
• Signature (130 hex digits)
• Original message text
• The result is : valid / invalid
Verifying an Ethereum Signature - Example
import eth_keys, binascii
msg = b'Hi guys, I am Kenneth and left message for signing'
msgSigner = '0xcF77d2Bc22d451657b30b7816F805773Bee23f1c'
signature = eth_keys.keys.Signature(binascii.unhexlify(
'64ee37d70272d7959d098f79b132cedf845d43196e12538334767675c37bec3d56f9f3dc9129afda470e
4ce78ee389e6b199f07141970b0c9dccbda636b644f100'))
signerRecoveredPubKey = signature.recover_public_key_from_msg(msg)
signerRecoveredAddress = signerRecoveredPubKey.to_checksum_address()
print('Signer public key (128 hex digits):', signerRecoveredPubKey)
print('Signer address:', signerRecoveredAddress)
print('Signature valid?:', signerRecoveredAddress == msgSigner)
What is Ethereum
• This is how Ethereum’s website defines itself:
• “Ethereum is a decentralized platform that runs smart
contracts: applications that run exactly as programmed
without any possibility of downtime, censorship, fraud or
third party interference. These apps run on a custom built
blockchain, an enormously powerful shared global
infrastructure that can move value around and represent
the ownership of property.”
Ethereum blockchain network
KOVAN
Ethereum
Wallet
RINKEBY ROPSTEN
Mainnet
Ethereum ID
Network Network ID Note
Main 1
Morden 2 Deprecated
Ropsten 3 POW
Rinkeby 4 POA, supported by geth only
Kovan 42 POA, supported by Parity only
Ethereum Account
Ethereum account
• State
• Accounts
• Contracts Accounts (controlled by code)
• Address
• Balance
• Ether
• Externally Owned Accounts (EOAs: User accounts is controlled by
private keys)
• Address
• Balance
• Ether
Contract account
<code>
<code>
<code>
External owned
account
Ethereum account
• Has an address
• Private key protected by password
• Has an address but NO private key
• Hold/Run code
• Associated with accounts(s)
• Lists incoming transactions
Contract
account<code>
<code>
<code>
External owned
account
Ethereum account
• Account state
• nonce: If the account is an externally
owned account, this number represents
the number of transactions sent from the
account’s address.
• balance: The number of Wei owned by
this address. There are 1e+18 Wei per
Ether. storageRoot: A 256-bit hash of the
root node of a Merkle Patricia tree that
encodes the storage contents of the .
• codeHash: The hash of the EVM
(Ethereum Virtual Machine) code of this
account .
Deploy smart contract
.
Remix : https://remix.ethereum.org/
Simple Bank smart contract
• Deposit
• WithDraw
• Check Balance
• Code: https://bit.ly/2WgxH1h
Simple Bank smart contract
Contracts Accounts- Pros and cons
• Pros
• Contract account can list incoming transactions
• Contract account can be setup as Multisig Accounts
• A Multisig Account can be structured such that it has a daily limit
which you specify, and only if the daily limit is exceeded will
multiple signatures be required
• Cons
• Contract accounts incur a cost whenever you use them.
• Contract accounts can’t initiate new transactions on their own.
MetaMask
• A Ether Wallet
• Chrome、Firefox and Opera Plugin
• Similar to MIST-Browser
• No geth node
• Is a bridge
• Like a “light-client”
• A “Key store” for your private keys
MetaMask
• Team leader : Aaron “kumavis” Davis
• Designer : Christian Jeria
MetaMask
• How to install MetaMask
• How to use Metamask
• Create account
• Export private key
• Export Seeds
• Import Account – Private Key & JSON File
• Transfer Ether
• Buy Ether
• Network
Account
Account – Create Account
Address
Private Key
Main
Ropsten
Kovan
Rinkeby
0xe589….
0xe589….
0xe589….
0xe589….
Account – Network
• Main Ethereum Network
• Ropsten Test Network
• Kovan Test Network
• Rinkeby Test Network
• Localhost 8545
• Custom RPC
MetaMask - network
KOVANRINKEBY
ROPSTEN
Main network
MetaMask – get Testcoin
• Ropsten faucet
• https://faucet.metamask.io/
• Kovan faucet
• https://gitter.im/kovan-testnet/faucet
• Rinkeby faucet
• https://faucet.rinkeby.io/
• Twitter
• Google
• Facebook
ACTIVITY 1:
TRANSFERRING ETHEREUM (10 MINS)
Instructions:
1. Open Ethereum Wallet
2. Get assigned account address
3. Transfer Ether to an assigned address.
Solidity
What is Solidity
.
• Solidity is a contract-oriented, high-level language for
implementing smart contracts. It was influenced by C++,
Python and JavaScript and is designed to target the
Ethereum Virtual Machine (EVM).
Contract EventVariable Function
contract
variable
variable
fuction
fuction
event
Basic Types
.
Name Notes Examples
String Sequence of characters “Hi there!” “Mike”
Bool Boolean value True False
Int Integer, positive or negative. Has no decimal 0 -25000 59158
Unit ‘unsigned’ integer, positive number. Has no decimal 0 25000 989910
Fixed/ufixed ‘Fixed’ point number, Number with decimal after it 20.001 -42.4242 3.14
Address Has methods tied to it for sending money 0x18bae199c8dbae199c8d
MetaCoin
• Send Coin
• Check Balance
• Code: https://bit.ly/2wFl0TC
MetaCoin
.
Course
.
• http://www.blocktechnology.co/courses/
• Blockchain 101
• Bitcoin 101
• Ethereum101
• Build Your Bitcoin Wallet and Website
• Create Your Own Private Ethereum Blockchain and build
Ethereum Dashboard
• Ethereum & Solidity course
• Master web3js
• Build a Token website with React
• Email: Kenneth.hu@Hotmail.com
20190606 blockchain101

Mais conteúdo relacionado

Mais procurados

Bitcoin and Ransomware Analysis
Bitcoin and Ransomware AnalysisBitcoin and Ransomware Analysis
Bitcoin and Ransomware Analysisinder_barara
 
How to develop Decentralized App (ĐApp) on Ethereum
How to develop Decentralized App (ĐApp) on EthereumHow to develop Decentralized App (ĐApp) on Ethereum
How to develop Decentralized App (ĐApp) on EthereumDEV Cafe
 
Introduction to Ethereum
Introduction to EthereumIntroduction to Ethereum
Introduction to EthereumArnold Pham
 
Доклад разработчиков Exonum на третьем митапе сообщества блокчейн-разработчик...
Доклад разработчиков Exonum на третьем митапе сообщества блокчейн-разработчик...Доклад разработчиков Exonum на третьем митапе сообщества блокчейн-разработчик...
Доклад разработчиков Exonum на третьем митапе сообщества блокчейн-разработчик...Дмитрий Плахов
 
Meetup 19/12/2016 - Blockchain-as-a-service voor Antwerpen?
Meetup 19/12/2016 - Blockchain-as-a-service voor Antwerpen?Meetup 19/12/2016 - Blockchain-as-a-service voor Antwerpen?
Meetup 19/12/2016 - Blockchain-as-a-service voor Antwerpen?Digipolis Antwerpen
 
Front-End Development for dApps on Tezos
Front-End Development for dApps on TezosFront-End Development for dApps on Tezos
Front-End Development for dApps on TezosNeven6
 
以比特幣為例的區塊鏈技術介紹 ( Intro to Blockchain using Bitcoin as an example)
以比特幣為例的區塊鏈技術介紹 ( Intro to Blockchain using Bitcoin as an example)以比特幣為例的區塊鏈技術介紹 ( Intro to Blockchain using Bitcoin as an example)
以比特幣為例的區塊鏈技術介紹 ( Intro to Blockchain using Bitcoin as an example)Nicholas Lin
 
Information security in private blockchains
Information security in private blockchainsInformation security in private blockchains
Information security in private blockchainsCoin Sciences Ltd
 
Understanding private blockchains
Understanding private blockchainsUnderstanding private blockchains
Understanding private blockchainsCoin Sciences Ltd
 
Microservices architecture
Microservices architectureMicroservices architecture
Microservices architectureTomasz Tomczyk
 
gething started - ethereum & using the geth golang client
gething started - ethereum & using the geth golang clientgething started - ethereum & using the geth golang client
gething started - ethereum & using the geth golang clientSathish VJ
 
Blockchain Ecosystem and Cryptocurrency Regulations
Blockchain Ecosystem and Cryptocurrency RegulationsBlockchain Ecosystem and Cryptocurrency Regulations
Blockchain Ecosystem and Cryptocurrency RegulationsAmir Rafati
 
Overview of Blockchain Consensus Mechanisms
Overview of Blockchain Consensus MechanismsOverview of Blockchain Consensus Mechanisms
Overview of Blockchain Consensus MechanismsJohannes Ahlmann
 
CBGTBT - Part 3 - Transactions 101
CBGTBT - Part 3 - Transactions 101CBGTBT - Part 3 - Transactions 101
CBGTBT - Part 3 - Transactions 101Blockstrap.com
 
Write Smart Contracts with Truffle Framework
Write Smart Contracts with Truffle FrameworkWrite Smart Contracts with Truffle Framework
Write Smart Contracts with Truffle FrameworkShun Shiku
 
Architecture of the Hyperledger Blockchain Fabric - Christian Cachin - IBM Re...
Architecture of the Hyperledger Blockchain Fabric - Christian Cachin - IBM Re...Architecture of the Hyperledger Blockchain Fabric - Christian Cachin - IBM Re...
Architecture of the Hyperledger Blockchain Fabric - Christian Cachin - IBM Re...Romeo Kienzler
 

Mais procurados (20)

Bitcoin and Ransomware Analysis
Bitcoin and Ransomware AnalysisBitcoin and Ransomware Analysis
Bitcoin and Ransomware Analysis
 
How to develop Decentralized App (ĐApp) on Ethereum
How to develop Decentralized App (ĐApp) on EthereumHow to develop Decentralized App (ĐApp) on Ethereum
How to develop Decentralized App (ĐApp) on Ethereum
 
Introduction to Ethereum
Introduction to EthereumIntroduction to Ethereum
Introduction to Ethereum
 
Доклад разработчиков Exonum на третьем митапе сообщества блокчейн-разработчик...
Доклад разработчиков Exonum на третьем митапе сообщества блокчейн-разработчик...Доклад разработчиков Exonum на третьем митапе сообщества блокчейн-разработчик...
Доклад разработчиков Exonum на третьем митапе сообщества блокчейн-разработчик...
 
Meetup 19/12/2016 - Blockchain-as-a-service voor Antwerpen?
Meetup 19/12/2016 - Blockchain-as-a-service voor Antwerpen?Meetup 19/12/2016 - Blockchain-as-a-service voor Antwerpen?
Meetup 19/12/2016 - Blockchain-as-a-service voor Antwerpen?
 
Cryptocurrencies
CryptocurrenciesCryptocurrencies
Cryptocurrencies
 
Front-End Development for dApps on Tezos
Front-End Development for dApps on TezosFront-End Development for dApps on Tezos
Front-End Development for dApps on Tezos
 
Etherium Intro for techies
Etherium Intro for techiesEtherium Intro for techies
Etherium Intro for techies
 
以比特幣為例的區塊鏈技術介紹 ( Intro to Blockchain using Bitcoin as an example)
以比特幣為例的區塊鏈技術介紹 ( Intro to Blockchain using Bitcoin as an example)以比特幣為例的區塊鏈技術介紹 ( Intro to Blockchain using Bitcoin as an example)
以比特幣為例的區塊鏈技術介紹 ( Intro to Blockchain using Bitcoin as an example)
 
Information security in private blockchains
Information security in private blockchainsInformation security in private blockchains
Information security in private blockchains
 
Understanding private blockchains
Understanding private blockchainsUnderstanding private blockchains
Understanding private blockchains
 
Microservices architecture
Microservices architectureMicroservices architecture
Microservices architecture
 
Ethereum Intro
Ethereum IntroEthereum Intro
Ethereum Intro
 
gething started - ethereum & using the geth golang client
gething started - ethereum & using the geth golang clientgething started - ethereum & using the geth golang client
gething started - ethereum & using the geth golang client
 
Blockchain Ecosystem and Cryptocurrency Regulations
Blockchain Ecosystem and Cryptocurrency RegulationsBlockchain Ecosystem and Cryptocurrency Regulations
Blockchain Ecosystem and Cryptocurrency Regulations
 
Overview of Blockchain Consensus Mechanisms
Overview of Blockchain Consensus MechanismsOverview of Blockchain Consensus Mechanisms
Overview of Blockchain Consensus Mechanisms
 
CBGTBT - Part 3 - Transactions 101
CBGTBT - Part 3 - Transactions 101CBGTBT - Part 3 - Transactions 101
CBGTBT - Part 3 - Transactions 101
 
BLOCKCHAIN TECHNOLOGY
BLOCKCHAIN TECHNOLOGYBLOCKCHAIN TECHNOLOGY
BLOCKCHAIN TECHNOLOGY
 
Write Smart Contracts with Truffle Framework
Write Smart Contracts with Truffle FrameworkWrite Smart Contracts with Truffle Framework
Write Smart Contracts with Truffle Framework
 
Architecture of the Hyperledger Blockchain Fabric - Christian Cachin - IBM Re...
Architecture of the Hyperledger Blockchain Fabric - Christian Cachin - IBM Re...Architecture of the Hyperledger Blockchain Fabric - Christian Cachin - IBM Re...
Architecture of the Hyperledger Blockchain Fabric - Christian Cachin - IBM Re...
 

Semelhante a 20190606 blockchain101

Blockchain 101 - public, tokenized blockchains
Blockchain 101 - public, tokenized blockchainsBlockchain 101 - public, tokenized blockchains
Blockchain 101 - public, tokenized blockchainsBrett Colbert
 
Node.js Blockchain Implementation
Node.js Blockchain ImplementationNode.js Blockchain Implementation
Node.js Blockchain ImplementationGlobalLogic Ukraine
 
Consensus Algorithms - Nakov @ jProfessionals - Jan 2018
Consensus Algorithms - Nakov @ jProfessionals - Jan 2018Consensus Algorithms - Nakov @ jProfessionals - Jan 2018
Consensus Algorithms - Nakov @ jProfessionals - Jan 2018Svetlin Nakov
 
20180711 blockchain presentation in Blockchain&Dapps
20180711 blockchain presentation in Blockchain&Dapps20180711 blockchain presentation in Blockchain&Dapps
20180711 blockchain presentation in Blockchain&DappsHu Kenneth
 
Indjic fintech module 6
Indjic fintech module 6Indjic fintech module 6
Indjic fintech module 6Drago Indjic
 
Block chain by harsh biltu agarwal
Block chain by harsh biltu agarwalBlock chain by harsh biltu agarwal
Block chain by harsh biltu agarwalN V Jagadeesh Kumar
 
Blockchain - Presentacion Betabeers Galicia 10/12/2014
Blockchain - Presentacion Betabeers Galicia 10/12/2014Blockchain - Presentacion Betabeers Galicia 10/12/2014
Blockchain - Presentacion Betabeers Galicia 10/12/2014WeKCo Coworking
 
Bitcoin - Understanding and Assessing potential Opportunities
Bitcoin - Understanding and Assessing potential OpportunitiesBitcoin - Understanding and Assessing potential Opportunities
Bitcoin - Understanding and Assessing potential OpportunitiesQuasarVentures
 
Blockchain Technologies for Data Science
Blockchain Technologies for Data ScienceBlockchain Technologies for Data Science
Blockchain Technologies for Data ScienceBruno Gonçalves
 
BlockchainConf.tech - Build a private blockchain workshop
BlockchainConf.tech - Build a private blockchain workshopBlockchainConf.tech - Build a private blockchain workshop
BlockchainConf.tech - Build a private blockchain workshopPad Kankipati
 
BCHGraz - Meetup #8 - Intro & Ethereum
 BCHGraz - Meetup #8 - Intro & Ethereum BCHGraz - Meetup #8 - Intro & Ethereum
BCHGraz - Meetup #8 - Intro & EthereumBlockchainHub Graz
 
Bitcoin and blockchain engineering
Bitcoin and blockchain engineeringBitcoin and blockchain engineering
Bitcoin and blockchain engineeringGregory Bataille
 
Understanding Blockchain
Understanding BlockchainUnderstanding Blockchain
Understanding BlockchainTony Willenberg
 
Ethereum Mining How To
Ethereum Mining How ToEthereum Mining How To
Ethereum Mining How ToNugroho Gito
 
Bruno Lowagie (iText) #cfoconferenz
Bruno Lowagie (iText) #cfoconferenzBruno Lowagie (iText) #cfoconferenz
Bruno Lowagie (iText) #cfoconferenzFDMagazine
 
Bitcoin, Banking and the Blockchain
Bitcoin, Banking and the BlockchainBitcoin, Banking and the Blockchain
Bitcoin, Banking and the Blockchainseancarmody
 
Blockchain and Cryptocurrencies
Blockchain and CryptocurrenciesBlockchain and Cryptocurrencies
Blockchain and CryptocurrenciesnimeshQ
 
Blockchain technology
Blockchain technologyBlockchain technology
Blockchain technologyNavin Kumar
 

Semelhante a 20190606 blockchain101 (20)

Blockchain 101 - public, tokenized blockchains
Blockchain 101 - public, tokenized blockchainsBlockchain 101 - public, tokenized blockchains
Blockchain 101 - public, tokenized blockchains
 
Node.js Blockchain Implementation
Node.js Blockchain ImplementationNode.js Blockchain Implementation
Node.js Blockchain Implementation
 
Consensus Algorithms - Nakov @ jProfessionals - Jan 2018
Consensus Algorithms - Nakov @ jProfessionals - Jan 2018Consensus Algorithms - Nakov @ jProfessionals - Jan 2018
Consensus Algorithms - Nakov @ jProfessionals - Jan 2018
 
20180711 blockchain presentation in Blockchain&Dapps
20180711 blockchain presentation in Blockchain&Dapps20180711 blockchain presentation in Blockchain&Dapps
20180711 blockchain presentation in Blockchain&Dapps
 
Indjic fintech module 6
Indjic fintech module 6Indjic fintech module 6
Indjic fintech module 6
 
Block chain by harsh biltu agarwal
Block chain by harsh biltu agarwalBlock chain by harsh biltu agarwal
Block chain by harsh biltu agarwal
 
Blockchain - Presentacion Betabeers Galicia 10/12/2014
Blockchain - Presentacion Betabeers Galicia 10/12/2014Blockchain - Presentacion Betabeers Galicia 10/12/2014
Blockchain - Presentacion Betabeers Galicia 10/12/2014
 
01 what is blockchain
01 what is blockchain01 what is blockchain
01 what is blockchain
 
Bitcoin - Understanding and Assessing potential Opportunities
Bitcoin - Understanding and Assessing potential OpportunitiesBitcoin - Understanding and Assessing potential Opportunities
Bitcoin - Understanding and Assessing potential Opportunities
 
Blockchain Technologies for Data Science
Blockchain Technologies for Data ScienceBlockchain Technologies for Data Science
Blockchain Technologies for Data Science
 
BlockchainConf.tech - Build a private blockchain workshop
BlockchainConf.tech - Build a private blockchain workshopBlockchainConf.tech - Build a private blockchain workshop
BlockchainConf.tech - Build a private blockchain workshop
 
BCHGraz - Meetup #8 - Intro & Ethereum
 BCHGraz - Meetup #8 - Intro & Ethereum BCHGraz - Meetup #8 - Intro & Ethereum
BCHGraz - Meetup #8 - Intro & Ethereum
 
Bitcoin and blockchain engineering
Bitcoin and blockchain engineeringBitcoin and blockchain engineering
Bitcoin and blockchain engineering
 
Blockchain Fundamentals
Blockchain FundamentalsBlockchain Fundamentals
Blockchain Fundamentals
 
Understanding Blockchain
Understanding BlockchainUnderstanding Blockchain
Understanding Blockchain
 
Ethereum Mining How To
Ethereum Mining How ToEthereum Mining How To
Ethereum Mining How To
 
Bruno Lowagie (iText) #cfoconferenz
Bruno Lowagie (iText) #cfoconferenzBruno Lowagie (iText) #cfoconferenz
Bruno Lowagie (iText) #cfoconferenz
 
Bitcoin, Banking and the Blockchain
Bitcoin, Banking and the BlockchainBitcoin, Banking and the Blockchain
Bitcoin, Banking and the Blockchain
 
Blockchain and Cryptocurrencies
Blockchain and CryptocurrenciesBlockchain and Cryptocurrencies
Blockchain and Cryptocurrencies
 
Blockchain technology
Blockchain technologyBlockchain technology
Blockchain technology
 

Mais de Hu Kenneth

20221110 MetaCoin
20221110 MetaCoin20221110 MetaCoin
20221110 MetaCoinHu Kenneth
 
NFT Drop review.pdf
NFT Drop review.pdfNFT Drop review.pdf
NFT Drop review.pdfHu Kenneth
 
AMA: all you need to know about Launching successful NFT collections
AMA: all you need to know about Launching successful NFT collectionsAMA: all you need to know about Launching successful NFT collections
AMA: all you need to know about Launching successful NFT collectionsHu Kenneth
 
Angular&node js upload file
Angular&node js upload fileAngular&node js upload file
Angular&node js upload fileHu Kenneth
 
20201006 meta_coin 六角學院
20201006 meta_coin 六角學院20201006 meta_coin 六角學院
20201006 meta_coin 六角學院Hu Kenneth
 
區塊鏈創新基地 - 區塊鏈
區塊鏈創新基地 - 區塊鏈區塊鏈創新基地 - 區塊鏈
區塊鏈創新基地 - 區塊鏈Hu Kenneth
 
2019 blockchain&dapps v2
2019 blockchain&dapps v22019 blockchain&dapps v2
2019 blockchain&dapps v2Hu Kenneth
 
Ethereum for developer 16th Nov 2018
Ethereum for developer 16th Nov 2018Ethereum for developer 16th Nov 2018
Ethereum for developer 16th Nov 2018Hu Kenneth
 
20180707 blockchain
20180707 blockchain 20180707 blockchain
20180707 blockchain Hu Kenneth
 
Blockchain And dapps meetup introduction
Blockchain And dapps meetup introductionBlockchain And dapps meetup introduction
Blockchain And dapps meetup introductionHu Kenneth
 
Integration at the consumer end
Integration at the consumer endIntegration at the consumer end
Integration at the consumer endHu Kenneth
 
Kenneth simple bitcoinwebsite
Kenneth simple bitcoinwebsiteKenneth simple bitcoinwebsite
Kenneth simple bitcoinwebsiteHu Kenneth
 
Ethereum dapps20180120
Ethereum dapps20180120Ethereum dapps20180120
Ethereum dapps20180120Hu Kenneth
 
2017/12/28 分享南進國家工作
2017/12/28 分享南進國家工作2017/12/28 分享南進國家工作
2017/12/28 分享南進國家工作Hu Kenneth
 
Ethereum dapps20171205
Ethereum dapps20171205Ethereum dapps20171205
Ethereum dapps20171205Hu Kenneth
 
Ethereum Dapps
Ethereum Dapps Ethereum Dapps
Ethereum Dapps Hu Kenneth
 
Ethereum blockchain dapps demo
Ethereum blockchain  dapps demoEthereum blockchain  dapps demo
Ethereum blockchain dapps demoHu Kenneth
 
M202 MongoDB Advanced Deployment and Operations
M202 MongoDB Advanced Deployment and OperationsM202 MongoDB Advanced Deployment and Operations
M202 MongoDB Advanced Deployment and OperationsHu Kenneth
 
M102 MongoDB for DBAs
M102 MongoDB for DBAsM102 MongoDB for DBAs
M102 MongoDB for DBAsHu Kenneth
 

Mais de Hu Kenneth (20)

20221110 MetaCoin
20221110 MetaCoin20221110 MetaCoin
20221110 MetaCoin
 
NFT Drop review.pdf
NFT Drop review.pdfNFT Drop review.pdf
NFT Drop review.pdf
 
AMA: all you need to know about Launching successful NFT collections
AMA: all you need to know about Launching successful NFT collectionsAMA: all you need to know about Launching successful NFT collections
AMA: all you need to know about Launching successful NFT collections
 
Angular&node js upload file
Angular&node js upload fileAngular&node js upload file
Angular&node js upload file
 
20201006 meta_coin 六角學院
20201006 meta_coin 六角學院20201006 meta_coin 六角學院
20201006 meta_coin 六角學院
 
區塊鏈創新基地 - 區塊鏈
區塊鏈創新基地 - 區塊鏈區塊鏈創新基地 - 區塊鏈
區塊鏈創新基地 - 區塊鏈
 
Stablecoin
StablecoinStablecoin
Stablecoin
 
2019 blockchain&dapps v2
2019 blockchain&dapps v22019 blockchain&dapps v2
2019 blockchain&dapps v2
 
Ethereum for developer 16th Nov 2018
Ethereum for developer 16th Nov 2018Ethereum for developer 16th Nov 2018
Ethereum for developer 16th Nov 2018
 
20180707 blockchain
20180707 blockchain 20180707 blockchain
20180707 blockchain
 
Blockchain And dapps meetup introduction
Blockchain And dapps meetup introductionBlockchain And dapps meetup introduction
Blockchain And dapps meetup introduction
 
Integration at the consumer end
Integration at the consumer endIntegration at the consumer end
Integration at the consumer end
 
Kenneth simple bitcoinwebsite
Kenneth simple bitcoinwebsiteKenneth simple bitcoinwebsite
Kenneth simple bitcoinwebsite
 
Ethereum dapps20180120
Ethereum dapps20180120Ethereum dapps20180120
Ethereum dapps20180120
 
2017/12/28 分享南進國家工作
2017/12/28 分享南進國家工作2017/12/28 分享南進國家工作
2017/12/28 分享南進國家工作
 
Ethereum dapps20171205
Ethereum dapps20171205Ethereum dapps20171205
Ethereum dapps20171205
 
Ethereum Dapps
Ethereum Dapps Ethereum Dapps
Ethereum Dapps
 
Ethereum blockchain dapps demo
Ethereum blockchain  dapps demoEthereum blockchain  dapps demo
Ethereum blockchain dapps demo
 
M202 MongoDB Advanced Deployment and Operations
M202 MongoDB Advanced Deployment and OperationsM202 MongoDB Advanced Deployment and Operations
M202 MongoDB Advanced Deployment and Operations
 
M102 MongoDB for DBAs
M102 MongoDB for DBAsM102 MongoDB for DBAs
M102 MongoDB for DBAs
 

Último

"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 

Último (20)

"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 

20190606 blockchain101

  • 1.
  • 2. Kenneth Hu • CTO at Baypay Inc • I am enthusiast, not expert. • Ethereum, Bitcoin, • Email: Kenneth.hu@Hotmail.com • Meetup • Blockchain&Dapps meetup • Singapore IOTA meetup • Trainer • Institute of Blockchain (previous) • 0xAcademy • BlockTec
  • 3. Agenda • Blockchain • Consensus • Public/Private Key • Ethereum • Ethereum account • MetaMask • Solidity • MetaCoin
  • 4. What is Blockchain • Blockchain = Chain of Data Block Distributed Ledger Secure Transactions are verified by the entire network Decentralized (no owner) Immutable Peer-to-Peer Network Nodes should ledger of facts + history of updates
  • 6. What is transaction? Kenneth Alice $30 SGD Transaction: “ is a transfer of value”
  • 7. Ledger : “a collection of financial accounts or transactions” Ledger Kenneth Alice #30 Amy Jen #50 Immutable : The ledger cannot be changed. Ever! What is ledger?What is Immutable?
  • 8. What is block? BLOCK Block Header Hash of previous block header Merkle root Timestamp Nonce Transactions Block : A block records some or all of the most recent transactions. Thus a block is like a page of a ledger or record book.
  • 10. Block header BLOCK Header Hash of previous block header Merkle root Timestamp Nonce • Hash of previous block header • Timestamp : It indicates when the block was created. • Merkle root : hash-based data structure that is a generalization of the hash list. • Nonce :Counter used for the Proof of Work algorithm. Each time you mine, the nonce increases by 1 .
  • 11. Merkle tree Merkle trees are useful in synchronizing data across a distributed data store because it allows each node in the distributed system to quickly and efficiently identify records that have changed without having to send all the data to make the comparison.
  • 12. Merkle proofs in Bitcoin
  • 13. Merkle proofs in Ethereum • Transaction • Receipts(essentially, pieces of data showing the effect of each transaction) • State
  • 14. Merkle proofs in Ethereum • Has this transaction been included in a particular block? – Transaction • Tell me all instances of an event of type X (eg. a crowdfunding contract reaching its goal) emitted by this address in the past 30 days – Receipts • What is the current balance of my account? – State • Does this account exist? – State • Pretend to run this transaction on this contract. What would the output be? – State Source : https://blog.ethereum.org/2015/11/15/merkling-in-ethereum/
  • 15. Block
  • 16. BLOCK 1 HEADER Hash of previous block header Merkle root Block 1 transactions BLOCK 2 HEADER Hash of previous block header Merkle root Block 2 transactions BLOCK 3 HEADER Hash of previous block header Merkle root Block 3 transactions Blockchain
  • 17. • Creating the candidate block Mining HASHING ( SHA256 ) Block’s Block header data Hash of previous block header Merkle root Timestamp Nonce No : ( Increment the nonce by 1. Hash again! Is hash (A8SBERA….) lower than the target? (check the leading zeros) YES! Problem Solved. Proof of Work
  • 18. Difficulty in Bitcoin • Difficulty is a measure of how difficult it is to find a hash below a given target • The Bitcoin network has a global block difficulty. Valid blocks must have a hash below this target. Mining pools also have a pool-specific share diffic ulty setting a lower limit for shares. • How often does the network difficulty change? • Every 2016 blocks. • What is the formula for difficulty? • difficulty = difficulty_1_target / current_target • (target is a 256 bit number)
  • 19. Difficulty in Ethereum • parentTimestamp - indicates the timestamp of a previous block • parentDifficulty - indicates the difficulty of a previous block • currentTimestamp - indicates the timestamp of a current block • currentBlockNumber - indicates the number of a current block (previous block number = currentBlock Number - 1) • currentDifficulty -- indicates the difficulty of a current block • Frontier: • block_diff = parent_diff + parent_diff // 2048 * (1 if block_timestamp - parent_timestamp < 13 else -1) + int(2**((block.number // 100000) - 2)) • Homestead: • block_diff = parent_diff + parent_diff // 2048 * max(1 - (block_timestamp - parent_timestamp) // 10, -99) + int(2**((block.number // 100000) - 2)) Frontier Homestead Metropolis Serenity
  • 20. • Block header hash is less than the target • Block size is within acceptable limits • Block timestamp is less than two hours in the future. • The first transaction is a coinbase transaction ( and only the first ) • The coinbase transaction has a valid reward. • All transactions within the blocks are valid ( also have a checklist on their own ) Source : https://dev.to/damcosset/blockchain-what-is-mining-2eod Validate the new block
  • 21. Node Time David  Sandra 5 BTC Brian  List 3.02 BTC Mary  Sandra 10 BTC Lisa  Sandra 10 BTC Sandra  David 10 BTC BLOCK #186 Block ID 0x0235de9a6 Previous Block 0x6e257071cec Transactions BLOCK #186 Block ID 0x6e257071cec Previous Block 0x1dcc4de8dec Transactions BLOCK #186 Block ID 0x6e257071cec Previous Block 0x1dcc4de8dec Transactions BLOCK #186 Block ID 0x6e257071cec Previous Block 0x1dcc4de8dec Transactions BLOCK #186 Block ID 0x6e257071cec Previous Block 0x1dcc4de8dec Transactions Blockchain network Blockchain Lisa  Sandra 10 BTC Brian  List 5 BTC Mary  Sandra 10 BTC …… ……… .. BTC
  • 22. What does “distributed” mean ? Distributed: A distributed ledger is a database that is consensually shared and synchronized across network spread across multiple node Ledger Ledger Ledger Ledger Ledger Ledger node node node nodenode node
  • 23. What is Consensus Algorithm? • Consensus algorithm (consensus protocol/ consensus mechanism) • Algorithm to reach agreement among the blockchain nodes • All nodes should agree about the changes in the distributed ledger • Proof-of-work (PoW), Proof-of-stake, other algorithms
  • 24. Demo
  • 25. Ledger Transaction/Mining/Sync Ledger Node 3 Node 1 Node 2 Node 4 Ledger Ledger • 1. submit a transaction • 2. Mining & Validation • 3. Sync to other node
  • 26. Ledger Consensus Ledger Node 3 Node 1 Node 2 Node 4 Ledger Ledger Ledger Node 5 • 1. run new node (node 5) • 2. join the network • 3. Sync to other node
  • 28. Proof-of-Work (PoW) • A “Proof-of-work” (PoW) is a piece of data which is • Difficult to produce • Easy for others to verify • Producing a proof-of-work can be a random guessing process or can be organized in mining pools (join PoW production) • Example • Find a number x, such that SHA256(text + x) has 10 leading zeroes. • 10 zeroes == network difficulty
  • 29. Proof-of-Work : Problems • Needs computing power • Computationally expensive • Energy intensive • 51% attack • Attackers holding more than 50% of the power could potentially reverse-back transactions (double-spend money) / deny service • Hashing algorithm types for PoW consensus • ASIC mineable (e.g. SHA256), CPU mineable (e.g. CryptoNight), • GPU mineable (e.g. ETHash), CPU + GPU mineable (e.g. Equihash)
  • 30. Proof-of-Work : Problems (2) • Transactions speed – average wait time • Bitcoin : new block mined in ~ 9-10 minutes • Ethereum : new block mined in ~ 10-15 seconds • Business needs real-time transactions ( milliseconds) • Transactions throughput – transactions per second (tps) • Bitcoin: 2000-3000 / transactions per block  3-5 tps ( up to 7 tps) • Ethereum: 200-300 / transactions per block  10-15 tps • Business needs thousands tps (e.g. VISA performs 2000 tps)
  • 31. Proof-of-Work Cryptocurrencies • Different cryptocurrencies use different hashing algorithms • Bitcoin, Bitcoin Cash – SHA256 – ASIC mineable • Ethereum, Ethereum Classic – ETHash – GPU mineable • Zcash, Bitcoin Gold – Equihash – CPU and GPU mineable • Monero – CryptoNight – CPU and GPU mineable • Litecoin, Dogecoin – Scrypt – GPU mineable • Dash – X11 – ASIC, CPU and GPU mineable • Stratis – X13 – ASIC, CPU and GPU mineable
  • 32. Proof of Stake (PoS) • PoS is designed to increase network security and reduce resource wasting • The creator of the next block is chosen in • Combination of random selection and wealth • E.g. holding 1% of the coins gives the chance to verify (mine) 1% of the “Proof of Stake blocks” • The “Monopoly Problem”: a monopolist ( holder of the most coins) could double spend or deny / filter other’s transactions • Executing a monopoly attack is much more expensive than in PoW
  • 33. Popular PoS Cryptocurrencies •Cardano – cardanohub.org •Qtum – qtum.org •PIVX – pivx.org •BitConnect – bitconnect.co •Stratis – stratisplatform.com
  • 34. Proof of Authority • Proof-of-Authority (PoA) assigns a set of trusted nodes (authorities) to process transactions and build new blocks • New blocks need to be signed by the majority of authorities • Works very well in private blockchain (cross validation) • Great performance, fast transactions, high throughput • Examples: • Ethereum Kovan Testnet – https://kovan.etherscan.io/ • Ethereum Rinkeby Testnet -- https://www.rinkeby.io/
  • 35. Public / Private Keys and Transaction
  • 36. Public / Private Keys and Transaction Wallet master key (seed) Private key Public key address transaction Signed transaction Transaction data Signature(v, r, s) Public key :(x, y) Sign by private key signed transaction verify by address Valid / invalid
  • 37. Verify Message Signature in Etherscan • Verify message signature at https://etherscan.io/verifySig by : • Signer address (40 hex digits) • Signature (130 hex digits) • Original message text • The result is : valid / invalid
  • 38. Verifying an Ethereum Signature - Example import eth_keys, binascii msg = b'Hi guys, I am Kenneth and left message for signing' msgSigner = '0xcF77d2Bc22d451657b30b7816F805773Bee23f1c' signature = eth_keys.keys.Signature(binascii.unhexlify( '64ee37d70272d7959d098f79b132cedf845d43196e12538334767675c37bec3d56f9f3dc9129afda470e 4ce78ee389e6b199f07141970b0c9dccbda636b644f100')) signerRecoveredPubKey = signature.recover_public_key_from_msg(msg) signerRecoveredAddress = signerRecoveredPubKey.to_checksum_address() print('Signer public key (128 hex digits):', signerRecoveredPubKey) print('Signer address:', signerRecoveredAddress) print('Signature valid?:', signerRecoveredAddress == msgSigner)
  • 39. What is Ethereum • This is how Ethereum’s website defines itself: • “Ethereum is a decentralized platform that runs smart contracts: applications that run exactly as programmed without any possibility of downtime, censorship, fraud or third party interference. These apps run on a custom built blockchain, an enormously powerful shared global infrastructure that can move value around and represent the ownership of property.”
  • 41. Ethereum ID Network Network ID Note Main 1 Morden 2 Deprecated Ropsten 3 POW Rinkeby 4 POA, supported by geth only Kovan 42 POA, supported by Parity only
  • 43. Ethereum account • State • Accounts • Contracts Accounts (controlled by code) • Address • Balance • Ether • Externally Owned Accounts (EOAs: User accounts is controlled by private keys) • Address • Balance • Ether Contract account <code> <code> <code> External owned account
  • 44. Ethereum account • Has an address • Private key protected by password • Has an address but NO private key • Hold/Run code • Associated with accounts(s) • Lists incoming transactions Contract account<code> <code> <code> External owned account
  • 45. Ethereum account • Account state • nonce: If the account is an externally owned account, this number represents the number of transactions sent from the account’s address. • balance: The number of Wei owned by this address. There are 1e+18 Wei per Ether. storageRoot: A 256-bit hash of the root node of a Merkle Patricia tree that encodes the storage contents of the . • codeHash: The hash of the EVM (Ethereum Virtual Machine) code of this account .
  • 46. Deploy smart contract . Remix : https://remix.ethereum.org/
  • 47. Simple Bank smart contract • Deposit • WithDraw • Check Balance • Code: https://bit.ly/2WgxH1h
  • 48. Simple Bank smart contract
  • 49. Contracts Accounts- Pros and cons • Pros • Contract account can list incoming transactions • Contract account can be setup as Multisig Accounts • A Multisig Account can be structured such that it has a daily limit which you specify, and only if the daily limit is exceeded will multiple signatures be required • Cons • Contract accounts incur a cost whenever you use them. • Contract accounts can’t initiate new transactions on their own.
  • 50. MetaMask • A Ether Wallet • Chrome、Firefox and Opera Plugin • Similar to MIST-Browser • No geth node • Is a bridge • Like a “light-client” • A “Key store” for your private keys
  • 51. MetaMask • Team leader : Aaron “kumavis” Davis • Designer : Christian Jeria
  • 52. MetaMask • How to install MetaMask • How to use Metamask • Create account • Export private key • Export Seeds • Import Account – Private Key & JSON File • Transfer Ether • Buy Ether • Network
  • 54. Account – Create Account Address Private Key Main Ropsten Kovan Rinkeby 0xe589…. 0xe589…. 0xe589…. 0xe589….
  • 55. Account – Network • Main Ethereum Network • Ropsten Test Network • Kovan Test Network • Rinkeby Test Network • Localhost 8545 • Custom RPC
  • 57. MetaMask – get Testcoin • Ropsten faucet • https://faucet.metamask.io/ • Kovan faucet • https://gitter.im/kovan-testnet/faucet • Rinkeby faucet • https://faucet.rinkeby.io/ • Twitter • Google • Facebook
  • 58. ACTIVITY 1: TRANSFERRING ETHEREUM (10 MINS) Instructions: 1. Open Ethereum Wallet 2. Get assigned account address 3. Transfer Ether to an assigned address.
  • 60. What is Solidity . • Solidity is a contract-oriented, high-level language for implementing smart contracts. It was influenced by C++, Python and JavaScript and is designed to target the Ethereum Virtual Machine (EVM). Contract EventVariable Function contract variable variable fuction fuction event
  • 61. Basic Types . Name Notes Examples String Sequence of characters “Hi there!” “Mike” Bool Boolean value True False Int Integer, positive or negative. Has no decimal 0 -25000 59158 Unit ‘unsigned’ integer, positive number. Has no decimal 0 25000 989910 Fixed/ufixed ‘Fixed’ point number, Number with decimal after it 20.001 -42.4242 3.14 Address Has methods tied to it for sending money 0x18bae199c8dbae199c8d
  • 62. MetaCoin • Send Coin • Check Balance • Code: https://bit.ly/2wFl0TC
  • 64. Course . • http://www.blocktechnology.co/courses/ • Blockchain 101 • Bitcoin 101 • Ethereum101 • Build Your Bitcoin Wallet and Website • Create Your Own Private Ethereum Blockchain and build Ethereum Dashboard • Ethereum & Solidity course • Master web3js • Build a Token website with React • Email: Kenneth.hu@Hotmail.com

Notas do Editor

  1. 快速比较大量数据 对每组数据排序后构建默克尔树结构。当两个默克尔树根相同时,则意味着所代表的两组数据必然相同。否则,必然不同。 由于 Hash 计算的过程可以十分快速,预处理可以在短时间内完成。利用默克尔树结构能带来巨大的比较性能优势。 快速定位修改 例如图例中,如果 D1 中数据被修改,会影响到 N1,N4 和 Root。 因此,一旦发现某个节点如 Root 的数值发生变化,沿着 Root --> N4 --> N1,最多通过 O(lgn) 时间即可快速定位到实际发生改变的数据块 D1。
  2. https://blog.ethereum.org/2015/11/15/merkling-in-ethereum/
  3. https://blog.ethereum.org/2015/11/15/merkling-in-ethereum/
  4. https://blog.csdn.net/u013695144/article/details/38585343
  5. https://blog.csdn.net/u013695144/article/details/38585343 Frontier(前沿),Homestead(家园),Metropolis(大都会),Serenity(宁静)。以太坊目前处于第三阶段——Metropolis的Byzantium(拜占庭)版本。然而,以太坊现如今存在一个难度炸弹(difficulty bomb)——一种使加密货币挖矿变得更加困难的协议——这是自从Frontier阶段开始引入到以太坊区块链中的。 http://www.o-o-o.link/article/9410.html Frontier(前沿)实验阶段 Homestead(家园)加入了难度炸弹 Byzantium(大都会)拆除了难度炸弹,修改区块奖励 Serenity(宁静) POS https://www.jianshu.com/p/16e840880c66
  6. https://iancoleman.io/bip39/ https://etherscan.io/verifySig