SlideShare a Scribd company logo
SMART
CONTRACT
林修平
CONTRACT
• What’s a contract?
• voluntary arrangement between two or more parties
• legally binding agreement
• buying, selling, renting, leasing, insurance, investment, etc.
• actively or inactively perform
“SMART” CONTRACT
• How to perform : self-enforcing , self executing
• preliminary: terms matched
• “SMART”? How?
• Smart Contract in real-life:
• vending machine
• U-bike, on-line gambling
• what’s the difference between smart contract and automated
service?
“SMART” CONTRACT
smart contract on blockchain
• What differences does it make?
• value of Blockchain
• whom to trust?
• a person?
• a company?
https://en.wikipedia.org/wiki/Financial_crisis_of_2007–08
• government?
https://en.wikipedia.org/wiki/Watergate_scandal
• or program and mathematics?
• its totally up to you
• reach an agreement with untrustful party
smart contract on blockchain
• https://www.thenewslens.com/article/11796
• a washing machine that can buy detergent itself if needed
• without blockchain
• cash flow :
• online payment -> companies that sells detergent -> transportation companies
• what’s the cost?
• time, efforts on checking status and verify
• what if something went wrong?
• how long does it take to find out the problem?
• who will find out the problem?
• how long do I have to wait?
smart contract on blockchain
• https://www.thenewslens.com/article/11796
• a washing machine that can buy detergent itself if needed
• with blockchain
• cash flow :
• online payment -> companies that sells detergent -> transportation companies
• what’s the cost?
• transaction fee
• what if something went wrong?
• how long does it take to find out the problem?
• who will find out the problem?
• how long do I have to wait?
smart contract on blockchain
BLOCKCHAIN + IOT
• IOT
• a device connecting to Internet?
• machine to machine
• how does it make sure it is not talking to a malicious node?
• can try
• how to make sure what it says is true?
• share same information
• distributed?
• can an IOT device provide such capability in its storage unit?
• decentralized?
BLOCKCHAIN + IOT?
• main problems in IOT
• Security
• hardware resource
BLOCKCHAIN + IOT?
CHALLENGE
CHALLENGE
• External Information
• Liquidity
• has no control beyond ledgers
• say you start a bet on tomorrow’s game score…
• how do you provide the score to smart contract?
• fetch the source from outside?
• which source to trust?
• can everyone fetch from the same source?
• will it expire? disappear? change from time to time?
• for now, smart contracts on blockchain can not fetch external information itself
• provided by third party
CHALLENGE
• External Information
• Liquidity
• has no control beyond ledgers
• suppose you start an insurance contract with insurance
company, is the money you pay monthly going to stay in there
indefinitely?
• no, like deposit in a bank, the company will make the best
out of the money which means the money will only be
there when something happened…
• then, how can the terms in smart contract be enforced?
CHALLENGE
• External Information
• Liquidity
• has no control beyond ledgers
• How do you enforce in the real world? probably by litigation
• but how is smart contract different from legacy contract?
Ethereum smart contract
Ethereum smart contract
• Turing Complete
• conditional branching
• loop
• ability to change arbitrary amount of memory
Ethereum smart contract
• Bitcoin
• Turing incompleteness
• OP_IF, OP_NOTIF, OP_ELSE, OP_ENDIF
• stateless
• stack-based language
• no loop
• made purposely
• prevent costly and infinite computation
Ethereum smart contract
• Turing Complete
• conditional branching
• loop
• ability to change arbitrary amount of memory
• powerful
• how to deal with malicious code, e.g. infinite loop?
• gas
• each operation has a price(gas)
• pay for gas where user decides how much to pay per unit gas
• pay with ether
Ethereum smart contract
• How does it work?
• 1. write your contract
Ethereum smart contract
• How does it work?
• 1. write your contract
• 2. compile it to byte code
Ethereum smart contract
• How does it work?
• 1. write your contract
• 2. compile it to byte
code
• 3. broadcasted and
mined
Ethereum smart contract
• How does it work?
• 1. write your contract
• 2. compile it to byte
code
• 3. broadcasted and
mined
• 4. invoke transaction
Ethereum smart contract
• contract language
• Serpent
• python-like
• Solidity
• javascript-like
Ethereum smart contract
• How does it work?
• 1. write your contract
• 2. compile it to byte code
• 3. broadcasted and mined
• 4. invoke transaction
https://ethereum.github.io/browser-solidity/
https://github.com/ethereum/go-
ethereum/wiki/Building-Ethereum
https://github.com/ethereum/mist/releases
living example : DAO
living example : DAO
• Decentralized Autonomous Organization
• by slock.it
• crowdfunding
• vote by your share
• profit by your share
• child DAO
• to prevent abuse of majority voting
living example : DAO
• Recursive calling vulnerability
• propose a split -> execute the split -> withdraw
• propose a split -> execute the split -> propose a split ->
execute the split -> withdraw
living example : DAO
• function splitDAO
problem1
problem2
living example : DAO
• function withdrawRewardFor
problem1
living example : DAO
• function payOut
problem1
• address.call.value(amount)
• supply with enough gas
• if address refers to a contract, it triggers fallback function
• do what whatever you want as long as enough gas remaining
• call to splitDAO again in fallback function
living example : DAO
• function splitDAO
problem2
• cleans up his/her balance after sending the money
living example : DAO
• counter measure :
• use address.send(amount)
• 2300 gas
• don’t execute address.call.value(amount) to untrusted code
• limit gas in address.call.value(amount)
• address.call.gas(gas_amount).value(amount)
• cleans up the balance before sending money
• then check if sending succed, if not ,rollback
living example : DAO
• what happens after?
• votes for hard fork
• choose to stay, becomes ETC
• choose to fork, becomes ETH
• Ethereum foundation, token holders, immutability believers
• too much money to fail? lawsuits?
• what do you believe?

More Related Content

What's hot

How does a blockchain work?
How does a blockchain work?How does a blockchain work?
How does a blockchain work?
Deloitte UK
 
Introduction to Blockchain and Smart Contracts
Introduction to Blockchain and Smart ContractsIntroduction to Blockchain and Smart Contracts
Introduction to Blockchain and Smart Contracts
Techracers
 
Types of blockchain
Types of blockchainTypes of blockchain
Types of blockchain
Darwin Labs
 
Ethereum Mining How To
Ethereum Mining How ToEthereum Mining How To
Ethereum Mining How To
Nugroho Gito
 
What is A Smart Contract? | Smart Contracts Tutorial | Smart Contracts in Blo...
What is A Smart Contract? | Smart Contracts Tutorial | Smart Contracts in Blo...What is A Smart Contract? | Smart Contracts Tutorial | Smart Contracts in Blo...
What is A Smart Contract? | Smart Contracts Tutorial | Smart Contracts in Blo...
Simplilearn
 
Blockchain Interview Questions And Answers | Blockchain Technology Interview ...
Blockchain Interview Questions And Answers | Blockchain Technology Interview ...Blockchain Interview Questions And Answers | Blockchain Technology Interview ...
Blockchain Interview Questions And Answers | Blockchain Technology Interview ...
Simplilearn
 
Consensus Algorithms.pptx
Consensus Algorithms.pptxConsensus Algorithms.pptx
Consensus Algorithms.pptx
Rajapriya82
 
Ethereum Tutorial - Ethereum Explained | What is Ethereum? | Ethereum Explain...
Ethereum Tutorial - Ethereum Explained | What is Ethereum? | Ethereum Explain...Ethereum Tutorial - Ethereum Explained | What is Ethereum? | Ethereum Explain...
Ethereum Tutorial - Ethereum Explained | What is Ethereum? | Ethereum Explain...
Simplilearn
 
Blockchain 101 | Blockchain Tutorial | Blockchain Smart Contracts | Blockchai...
Blockchain 101 | Blockchain Tutorial | Blockchain Smart Contracts | Blockchai...Blockchain 101 | Blockchain Tutorial | Blockchain Smart Contracts | Blockchai...
Blockchain 101 | Blockchain Tutorial | Blockchain Smart Contracts | Blockchai...
Edureka!
 
►TOP 13 • Blockchain Use Cases
►TOP 13 • Blockchain Use Cases ►TOP 13 • Blockchain Use Cases
►TOP 13 • Blockchain Use Cases
Andrea Soto
 
Blockchain Technology | Blockchain Explained | Blockchain Tutorial | Blockcha...
Blockchain Technology | Blockchain Explained | Blockchain Tutorial | Blockcha...Blockchain Technology | Blockchain Explained | Blockchain Tutorial | Blockcha...
Blockchain Technology | Blockchain Explained | Blockchain Tutorial | Blockcha...
Edureka!
 
Blockchain Smart Contract v5
Blockchain   Smart Contract v5Blockchain   Smart Contract v5
Blockchain Smart Contract v5
MD SAQUIB KHAN
 
Introduction to Blockchain
Introduction to BlockchainIntroduction to Blockchain
Introduction to Blockchain
Jordan Harris
 
Blockchain concepts
Blockchain conceptsBlockchain concepts
Blockchain concepts
Murughan Palaniachari
 
Blockchain - HyperLedger Fabric
Blockchain - HyperLedger FabricBlockchain - HyperLedger Fabric
Blockchain - HyperLedger Fabric
Araf Karsh Hamid
 
Blockchain Explained | Blockchain Simplified | Blockchain Technology | Blockc...
Blockchain Explained | Blockchain Simplified | Blockchain Technology | Blockc...Blockchain Explained | Blockchain Simplified | Blockchain Technology | Blockc...
Blockchain Explained | Blockchain Simplified | Blockchain Technology | Blockc...
Edureka!
 
Basic introduction in blockchain, smart contracts, permissioned ledgers
Basic introduction in blockchain, smart contracts, permissioned ledgersBasic introduction in blockchain, smart contracts, permissioned ledgers
Basic introduction in blockchain, smart contracts, permissioned ledgers
Koen Vingerhoets
 
Ethereum Blockchain with Smart contract and ERC20
Ethereum Blockchain with Smart contract and ERC20Ethereum Blockchain with Smart contract and ERC20
Ethereum Blockchain with Smart contract and ERC20
Truong Nguyen
 
Blockchain Technology
Blockchain TechnologyBlockchain Technology
Blockchain Technology
PalakGulati10
 
Blockchain Digital Transformation Presentation
Blockchain Digital Transformation PresentationBlockchain Digital Transformation Presentation
Blockchain Digital Transformation Presentation
101 Blockchains
 

What's hot (20)

How does a blockchain work?
How does a blockchain work?How does a blockchain work?
How does a blockchain work?
 
Introduction to Blockchain and Smart Contracts
Introduction to Blockchain and Smart ContractsIntroduction to Blockchain and Smart Contracts
Introduction to Blockchain and Smart Contracts
 
Types of blockchain
Types of blockchainTypes of blockchain
Types of blockchain
 
Ethereum Mining How To
Ethereum Mining How ToEthereum Mining How To
Ethereum Mining How To
 
What is A Smart Contract? | Smart Contracts Tutorial | Smart Contracts in Blo...
What is A Smart Contract? | Smart Contracts Tutorial | Smart Contracts in Blo...What is A Smart Contract? | Smart Contracts Tutorial | Smart Contracts in Blo...
What is A Smart Contract? | Smart Contracts Tutorial | Smart Contracts in Blo...
 
Blockchain Interview Questions And Answers | Blockchain Technology Interview ...
Blockchain Interview Questions And Answers | Blockchain Technology Interview ...Blockchain Interview Questions And Answers | Blockchain Technology Interview ...
Blockchain Interview Questions And Answers | Blockchain Technology Interview ...
 
Consensus Algorithms.pptx
Consensus Algorithms.pptxConsensus Algorithms.pptx
Consensus Algorithms.pptx
 
Ethereum Tutorial - Ethereum Explained | What is Ethereum? | Ethereum Explain...
Ethereum Tutorial - Ethereum Explained | What is Ethereum? | Ethereum Explain...Ethereum Tutorial - Ethereum Explained | What is Ethereum? | Ethereum Explain...
Ethereum Tutorial - Ethereum Explained | What is Ethereum? | Ethereum Explain...
 
Blockchain 101 | Blockchain Tutorial | Blockchain Smart Contracts | Blockchai...
Blockchain 101 | Blockchain Tutorial | Blockchain Smart Contracts | Blockchai...Blockchain 101 | Blockchain Tutorial | Blockchain Smart Contracts | Blockchai...
Blockchain 101 | Blockchain Tutorial | Blockchain Smart Contracts | Blockchai...
 
►TOP 13 • Blockchain Use Cases
►TOP 13 • Blockchain Use Cases ►TOP 13 • Blockchain Use Cases
►TOP 13 • Blockchain Use Cases
 
Blockchain Technology | Blockchain Explained | Blockchain Tutorial | Blockcha...
Blockchain Technology | Blockchain Explained | Blockchain Tutorial | Blockcha...Blockchain Technology | Blockchain Explained | Blockchain Tutorial | Blockcha...
Blockchain Technology | Blockchain Explained | Blockchain Tutorial | Blockcha...
 
Blockchain Smart Contract v5
Blockchain   Smart Contract v5Blockchain   Smart Contract v5
Blockchain Smart Contract v5
 
Introduction to Blockchain
Introduction to BlockchainIntroduction to Blockchain
Introduction to Blockchain
 
Blockchain concepts
Blockchain conceptsBlockchain concepts
Blockchain concepts
 
Blockchain - HyperLedger Fabric
Blockchain - HyperLedger FabricBlockchain - HyperLedger Fabric
Blockchain - HyperLedger Fabric
 
Blockchain Explained | Blockchain Simplified | Blockchain Technology | Blockc...
Blockchain Explained | Blockchain Simplified | Blockchain Technology | Blockc...Blockchain Explained | Blockchain Simplified | Blockchain Technology | Blockc...
Blockchain Explained | Blockchain Simplified | Blockchain Technology | Blockc...
 
Basic introduction in blockchain, smart contracts, permissioned ledgers
Basic introduction in blockchain, smart contracts, permissioned ledgersBasic introduction in blockchain, smart contracts, permissioned ledgers
Basic introduction in blockchain, smart contracts, permissioned ledgers
 
Ethereum Blockchain with Smart contract and ERC20
Ethereum Blockchain with Smart contract and ERC20Ethereum Blockchain with Smart contract and ERC20
Ethereum Blockchain with Smart contract and ERC20
 
Blockchain Technology
Blockchain TechnologyBlockchain Technology
Blockchain Technology
 
Blockchain Digital Transformation Presentation
Blockchain Digital Transformation PresentationBlockchain Digital Transformation Presentation
Blockchain Digital Transformation Presentation
 

Viewers also liked

部署並執行以太坊智能合約
部署並執行以太坊智能合約部署並執行以太坊智能合約
部署並執行以太坊智能合約
Nicholas Lin
 
以太坊智能合約撰寫簡單教學
以太坊智能合約撰寫簡單教學以太坊智能合約撰寫簡單教學
以太坊智能合約撰寫簡單教學
Nicholas Lin
 
智能合約結合區塊鏈簡介
智能合約結合區塊鏈簡介智能合約結合區塊鏈簡介
智能合約結合區塊鏈簡介
Nicholas Lin
 
Solidity Simple Tutorial EN
Solidity Simple Tutorial ENSolidity Simple Tutorial EN
Solidity Simple Tutorial EN
Nicholas Lin
 
Blockchain Smart Contracts - getting from hype to reality
Blockchain Smart Contracts - getting from hype to reality Blockchain Smart Contracts - getting from hype to reality
Blockchain Smart Contracts - getting from hype to reality
Capgemini
 
區塊鏈智能合約應用於點數平台之架構
區塊鏈智能合約應用於點數平台之架構區塊鏈智能合約應用於點數平台之架構
區塊鏈智能合約應用於點數平台之架構
Nicholas Lin
 
CopyRightContractDemo
CopyRightContractDemoCopyRightContractDemo
CopyRightContractDemo
Nicholas Lin
 
Defining Smart Contracts
Defining Smart ContractsDefining Smart Contracts
Defining Smart Contracts
Tim Swanson
 
以比特幣為例的區塊鏈技術介紹 ( 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
 
Blockchain, smart contracts - introduction
Blockchain, smart contracts - introductionBlockchain, smart contracts - introduction
Blockchain, smart contracts - introduction
Lukasz Jarmulowicz
 
Introduction to blockchain and smart contracts
Introduction to blockchain and smart contractsIntroduction to blockchain and smart contracts
Introduction to blockchain and smart contracts
Validity Labs
 
從開發人員角度十分鐘理解區塊鏈技術
從開發人員角度十分鐘理解區塊鏈技術從開發人員角度十分鐘理解區塊鏈技術
從開發人員角度十分鐘理解區塊鏈技術
Will Huang
 
Blockchain and Smart Contract Long Term Security (updated)
Blockchain and Smart Contract Long Term Security (updated)Blockchain and Smart Contract Long Term Security (updated)
Blockchain and Smart Contract Long Term Security (updated)
Peter Robinson
 
區塊鏈科技趨勢與應用
區塊鏈科技趨勢與應用區塊鏈科技趨勢與應用
區塊鏈科技趨勢與應用
Jacob Lee
 
State Of Smart Contract Platforms from Smart Contract JP
State Of Smart Contract Platforms from Smart Contract JP State Of Smart Contract Platforms from Smart Contract JP
State Of Smart Contract Platforms from Smart Contract JP
Tomoaki Sato
 
Writing smart contracts
Writing smart contractsWriting smart contracts
Writing smart contracts
Marek Kirejczyk
 
BlockChain, Bitcoin and Smart Contracts - Oleg Kudrenko
BlockChain, Bitcoin and Smart Contracts - Oleg KudrenkoBlockChain, Bitcoin and Smart Contracts - Oleg Kudrenko
BlockChain, Bitcoin and Smart Contracts - Oleg Kudrenko
Oleg Kudrenko
 
Hacking Finance: Crypto & Math based Currencies, Smart contracts and Blockch...
Hacking Finance: Crypto & Math based Currencies, Smart contracts  and Blockch...Hacking Finance: Crypto & Math based Currencies, Smart contracts  and Blockch...
Hacking Finance: Crypto & Math based Currencies, Smart contracts and Blockch...
Raffaele Mauro
 
Effacts Academy - Smart Contract Management
Effacts Academy - Smart Contract ManagementEffacts Academy - Smart Contract Management
Effacts Academy - Smart Contract Management
Legal Manager
 
Bitcoin e Smart Contract
Bitcoin e Smart ContractBitcoin e Smart Contract

Viewers also liked (20)

部署並執行以太坊智能合約
部署並執行以太坊智能合約部署並執行以太坊智能合約
部署並執行以太坊智能合約
 
以太坊智能合約撰寫簡單教學
以太坊智能合約撰寫簡單教學以太坊智能合約撰寫簡單教學
以太坊智能合約撰寫簡單教學
 
智能合約結合區塊鏈簡介
智能合約結合區塊鏈簡介智能合約結合區塊鏈簡介
智能合約結合區塊鏈簡介
 
Solidity Simple Tutorial EN
Solidity Simple Tutorial ENSolidity Simple Tutorial EN
Solidity Simple Tutorial EN
 
Blockchain Smart Contracts - getting from hype to reality
Blockchain Smart Contracts - getting from hype to reality Blockchain Smart Contracts - getting from hype to reality
Blockchain Smart Contracts - getting from hype to reality
 
區塊鏈智能合約應用於點數平台之架構
區塊鏈智能合約應用於點數平台之架構區塊鏈智能合約應用於點數平台之架構
區塊鏈智能合約應用於點數平台之架構
 
CopyRightContractDemo
CopyRightContractDemoCopyRightContractDemo
CopyRightContractDemo
 
Defining Smart Contracts
Defining Smart ContractsDefining Smart Contracts
Defining Smart Contracts
 
以比特幣為例的區塊鏈技術介紹 ( 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)
 
Blockchain, smart contracts - introduction
Blockchain, smart contracts - introductionBlockchain, smart contracts - introduction
Blockchain, smart contracts - introduction
 
Introduction to blockchain and smart contracts
Introduction to blockchain and smart contractsIntroduction to blockchain and smart contracts
Introduction to blockchain and smart contracts
 
從開發人員角度十分鐘理解區塊鏈技術
從開發人員角度十分鐘理解區塊鏈技術從開發人員角度十分鐘理解區塊鏈技術
從開發人員角度十分鐘理解區塊鏈技術
 
Blockchain and Smart Contract Long Term Security (updated)
Blockchain and Smart Contract Long Term Security (updated)Blockchain and Smart Contract Long Term Security (updated)
Blockchain and Smart Contract Long Term Security (updated)
 
區塊鏈科技趨勢與應用
區塊鏈科技趨勢與應用區塊鏈科技趨勢與應用
區塊鏈科技趨勢與應用
 
State Of Smart Contract Platforms from Smart Contract JP
State Of Smart Contract Platforms from Smart Contract JP State Of Smart Contract Platforms from Smart Contract JP
State Of Smart Contract Platforms from Smart Contract JP
 
Writing smart contracts
Writing smart contractsWriting smart contracts
Writing smart contracts
 
BlockChain, Bitcoin and Smart Contracts - Oleg Kudrenko
BlockChain, Bitcoin and Smart Contracts - Oleg KudrenkoBlockChain, Bitcoin and Smart Contracts - Oleg Kudrenko
BlockChain, Bitcoin and Smart Contracts - Oleg Kudrenko
 
Hacking Finance: Crypto & Math based Currencies, Smart contracts and Blockch...
Hacking Finance: Crypto & Math based Currencies, Smart contracts  and Blockch...Hacking Finance: Crypto & Math based Currencies, Smart contracts  and Blockch...
Hacking Finance: Crypto & Math based Currencies, Smart contracts and Blockch...
 
Effacts Academy - Smart Contract Management
Effacts Academy - Smart Contract ManagementEffacts Academy - Smart Contract Management
Effacts Academy - Smart Contract Management
 
Bitcoin e Smart Contract
Bitcoin e Smart ContractBitcoin e Smart Contract
Bitcoin e Smart Contract
 

Similar to Intro to smart contract on blockchain en

Smart contractjp smartcontract_about
Smart contractjp smartcontract_aboutSmart contractjp smartcontract_about
Smart contractjp smartcontract_about
Tomoaki Sato
 
Privacy Preserving Paradigms of Blockchain Technology
Privacy Preserving Paradigms of Blockchain TechnologyPrivacy Preserving Paradigms of Blockchain Technology
Privacy Preserving Paradigms of Blockchain Technology
Gokul Alex
 
Blockchain
BlockchainBlockchain
Blockchain
Abhinand Valasseri
 
Blockchain tutorial for MBA
Blockchain tutorial for MBABlockchain tutorial for MBA
Blockchain tutorial for MBA
Blokcert
 
Practical Challenges for Public Blockchains
Practical Challenges for Public BlockchainsPractical Challenges for Public Blockchains
Practical Challenges for Public Blockchains
Johannes Ahlmann
 
Practical Challenges for Public Blockchains
Practical Challenges for Public BlockchainsPractical Challenges for Public Blockchains
Practical Challenges for Public Blockchains
Johannes Ahlmann
 
Blockchain
BlockchainBlockchain
Blockchain
Gopal Goel
 
blockchain and iot: Opportunities and Challanges
blockchain and iot: Opportunities and Challangesblockchain and iot: Opportunities and Challanges
blockchain and iot: Opportunities and Challanges
Chetan Kumar S
 
From 7331 to legal : a selection of blockchain discussion topics
From 7331 to legal : a selection of blockchain discussion topicsFrom 7331 to legal : a selection of blockchain discussion topics
From 7331 to legal : a selection of blockchain discussion topics
Koen Vingerhoets
 
20190316 - CLBFest - 1337 to legal - Koen Vingerhoets
20190316 - CLBFest - 1337 to legal - Koen Vingerhoets20190316 - CLBFest - 1337 to legal - Koen Vingerhoets
20190316 - CLBFest - 1337 to legal - Koen Vingerhoets
Brussels Legal Hackers
 
Is Blockchain Right for You? The Million Dollar Question
Is Blockchain Right for You? The Million Dollar QuestionIs Blockchain Right for You? The Million Dollar Question
Is Blockchain Right for You? The Million Dollar Question
Security Innovation
 
Blockchain
Blockchain Blockchain
Blockchain
Zefren Edior
 
Demystifying Smart Contracts
Demystifying Smart ContractsDemystifying Smart Contracts
Demystifying Smart Contracts
Bernard Peh
 
Blockchain Projects - Core Pillars of Shipping Product, Feb 2018
Blockchain Projects - Core Pillars of Shipping Product, Feb 2018Blockchain Projects - Core Pillars of Shipping Product, Feb 2018
Blockchain Projects - Core Pillars of Shipping Product, Feb 2018
🔗Audrey Chaing
 
What is bitcoin?
What is bitcoin?What is bitcoin?
What is bitcoin?
Suraj Bora
 
Week 4 - DApps, Smart Contracts, and Decentralized Incentive Systems
Week 4 - DApps, Smart Contracts, and Decentralized Incentive SystemsWeek 4 - DApps, Smart Contracts, and Decentralized Incentive Systems
Week 4 - DApps, Smart Contracts, and Decentralized Incentive Systems
Roger Royse
 
Block chain
Block chainBlock chain
Block chain
TejashBansal2
 
Blockchain in enterprise - Challenges, Considerations and Designs
Blockchain in enterprise - Challenges, Considerations and DesignsBlockchain in enterprise - Challenges, Considerations and Designs
Blockchain in enterprise - Challenges, Considerations and Designs
Michael Chi
 
Smart Contract & Ethereum
Smart Contract & EthereumSmart Contract & Ethereum
Smart Contract & Ethereum
Akshay Singh
 
Blockchain & crypto
Blockchain & cryptoBlockchain & crypto
Blockchain & crypto
Atul Mangat
 

Similar to Intro to smart contract on blockchain en (20)

Smart contractjp smartcontract_about
Smart contractjp smartcontract_aboutSmart contractjp smartcontract_about
Smart contractjp smartcontract_about
 
Privacy Preserving Paradigms of Blockchain Technology
Privacy Preserving Paradigms of Blockchain TechnologyPrivacy Preserving Paradigms of Blockchain Technology
Privacy Preserving Paradigms of Blockchain Technology
 
Blockchain
BlockchainBlockchain
Blockchain
 
Blockchain tutorial for MBA
Blockchain tutorial for MBABlockchain tutorial for MBA
Blockchain tutorial for MBA
 
Practical Challenges for Public Blockchains
Practical Challenges for Public BlockchainsPractical Challenges for Public Blockchains
Practical Challenges for Public Blockchains
 
Practical Challenges for Public Blockchains
Practical Challenges for Public BlockchainsPractical Challenges for Public Blockchains
Practical Challenges for Public Blockchains
 
Blockchain
BlockchainBlockchain
Blockchain
 
blockchain and iot: Opportunities and Challanges
blockchain and iot: Opportunities and Challangesblockchain and iot: Opportunities and Challanges
blockchain and iot: Opportunities and Challanges
 
From 7331 to legal : a selection of blockchain discussion topics
From 7331 to legal : a selection of blockchain discussion topicsFrom 7331 to legal : a selection of blockchain discussion topics
From 7331 to legal : a selection of blockchain discussion topics
 
20190316 - CLBFest - 1337 to legal - Koen Vingerhoets
20190316 - CLBFest - 1337 to legal - Koen Vingerhoets20190316 - CLBFest - 1337 to legal - Koen Vingerhoets
20190316 - CLBFest - 1337 to legal - Koen Vingerhoets
 
Is Blockchain Right for You? The Million Dollar Question
Is Blockchain Right for You? The Million Dollar QuestionIs Blockchain Right for You? The Million Dollar Question
Is Blockchain Right for You? The Million Dollar Question
 
Blockchain
Blockchain Blockchain
Blockchain
 
Demystifying Smart Contracts
Demystifying Smart ContractsDemystifying Smart Contracts
Demystifying Smart Contracts
 
Blockchain Projects - Core Pillars of Shipping Product, Feb 2018
Blockchain Projects - Core Pillars of Shipping Product, Feb 2018Blockchain Projects - Core Pillars of Shipping Product, Feb 2018
Blockchain Projects - Core Pillars of Shipping Product, Feb 2018
 
What is bitcoin?
What is bitcoin?What is bitcoin?
What is bitcoin?
 
Week 4 - DApps, Smart Contracts, and Decentralized Incentive Systems
Week 4 - DApps, Smart Contracts, and Decentralized Incentive SystemsWeek 4 - DApps, Smart Contracts, and Decentralized Incentive Systems
Week 4 - DApps, Smart Contracts, and Decentralized Incentive Systems
 
Block chain
Block chainBlock chain
Block chain
 
Blockchain in enterprise - Challenges, Considerations and Designs
Blockchain in enterprise - Challenges, Considerations and DesignsBlockchain in enterprise - Challenges, Considerations and Designs
Blockchain in enterprise - Challenges, Considerations and Designs
 
Smart Contract & Ethereum
Smart Contract & EthereumSmart Contract & Ethereum
Smart Contract & Ethereum
 
Blockchain & crypto
Blockchain & cryptoBlockchain & crypto
Blockchain & crypto
 

Recently uploaded

"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Fwdays
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 

Recently uploaded (20)

"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 

Intro to smart contract on blockchain en

  • 2. CONTRACT • What’s a contract? • voluntary arrangement between two or more parties • legally binding agreement • buying, selling, renting, leasing, insurance, investment, etc. • actively or inactively perform
  • 4. • How to perform : self-enforcing , self executing • preliminary: terms matched • “SMART”? How? • Smart Contract in real-life: • vending machine • U-bike, on-line gambling • what’s the difference between smart contract and automated service? “SMART” CONTRACT
  • 5. smart contract on blockchain
  • 6. • What differences does it make? • value of Blockchain • whom to trust? • a person? • a company? https://en.wikipedia.org/wiki/Financial_crisis_of_2007–08 • government? https://en.wikipedia.org/wiki/Watergate_scandal • or program and mathematics? • its totally up to you • reach an agreement with untrustful party smart contract on blockchain
  • 7. • https://www.thenewslens.com/article/11796 • a washing machine that can buy detergent itself if needed • without blockchain • cash flow : • online payment -> companies that sells detergent -> transportation companies • what’s the cost? • time, efforts on checking status and verify • what if something went wrong? • how long does it take to find out the problem? • who will find out the problem? • how long do I have to wait? smart contract on blockchain
  • 8. • https://www.thenewslens.com/article/11796 • a washing machine that can buy detergent itself if needed • with blockchain • cash flow : • online payment -> companies that sells detergent -> transportation companies • what’s the cost? • transaction fee • what if something went wrong? • how long does it take to find out the problem? • who will find out the problem? • how long do I have to wait? smart contract on blockchain
  • 10. • IOT • a device connecting to Internet? • machine to machine • how does it make sure it is not talking to a malicious node? • can try • how to make sure what it says is true? • share same information • distributed? • can an IOT device provide such capability in its storage unit? • decentralized? BLOCKCHAIN + IOT?
  • 11. • main problems in IOT • Security • hardware resource BLOCKCHAIN + IOT?
  • 13. CHALLENGE • External Information • Liquidity • has no control beyond ledgers • say you start a bet on tomorrow’s game score… • how do you provide the score to smart contract? • fetch the source from outside? • which source to trust? • can everyone fetch from the same source? • will it expire? disappear? change from time to time? • for now, smart contracts on blockchain can not fetch external information itself • provided by third party
  • 14. CHALLENGE • External Information • Liquidity • has no control beyond ledgers • suppose you start an insurance contract with insurance company, is the money you pay monthly going to stay in there indefinitely? • no, like deposit in a bank, the company will make the best out of the money which means the money will only be there when something happened… • then, how can the terms in smart contract be enforced?
  • 15. CHALLENGE • External Information • Liquidity • has no control beyond ledgers • How do you enforce in the real world? probably by litigation • but how is smart contract different from legacy contract?
  • 17. Ethereum smart contract • Turing Complete • conditional branching • loop • ability to change arbitrary amount of memory
  • 18. Ethereum smart contract • Bitcoin • Turing incompleteness • OP_IF, OP_NOTIF, OP_ELSE, OP_ENDIF • stateless • stack-based language • no loop • made purposely • prevent costly and infinite computation
  • 19. Ethereum smart contract • Turing Complete • conditional branching • loop • ability to change arbitrary amount of memory • powerful • how to deal with malicious code, e.g. infinite loop? • gas • each operation has a price(gas) • pay for gas where user decides how much to pay per unit gas • pay with ether
  • 20. Ethereum smart contract • How does it work? • 1. write your contract
  • 21. Ethereum smart contract • How does it work? • 1. write your contract • 2. compile it to byte code
  • 22. Ethereum smart contract • How does it work? • 1. write your contract • 2. compile it to byte code • 3. broadcasted and mined
  • 23. Ethereum smart contract • How does it work? • 1. write your contract • 2. compile it to byte code • 3. broadcasted and mined • 4. invoke transaction
  • 24. Ethereum smart contract • contract language • Serpent • python-like • Solidity • javascript-like
  • 25. Ethereum smart contract • How does it work? • 1. write your contract • 2. compile it to byte code • 3. broadcasted and mined • 4. invoke transaction https://ethereum.github.io/browser-solidity/ https://github.com/ethereum/go- ethereum/wiki/Building-Ethereum https://github.com/ethereum/mist/releases
  • 27. living example : DAO • Decentralized Autonomous Organization • by slock.it • crowdfunding • vote by your share • profit by your share • child DAO • to prevent abuse of majority voting
  • 28. living example : DAO • Recursive calling vulnerability • propose a split -> execute the split -> withdraw • propose a split -> execute the split -> propose a split -> execute the split -> withdraw
  • 29. living example : DAO • function splitDAO problem1 problem2
  • 30. living example : DAO • function withdrawRewardFor problem1
  • 31. living example : DAO • function payOut problem1 • address.call.value(amount) • supply with enough gas • if address refers to a contract, it triggers fallback function • do what whatever you want as long as enough gas remaining • call to splitDAO again in fallback function
  • 32. living example : DAO • function splitDAO problem2 • cleans up his/her balance after sending the money
  • 33. living example : DAO • counter measure : • use address.send(amount) • 2300 gas • don’t execute address.call.value(amount) to untrusted code • limit gas in address.call.value(amount) • address.call.gas(gas_amount).value(amount) • cleans up the balance before sending money • then check if sending succed, if not ,rollback
  • 34. living example : DAO • what happens after? • votes for hard fork • choose to stay, becomes ETC • choose to fork, becomes ETH • Ethereum foundation, token holders, immutability believers • too much money to fail? lawsuits? • what do you believe?