blockchain and smart contracts
TRANSCRIPT
![Page 1: Blockchain and Smart Contracts](https://reader033.vdocuments.mx/reader033/viewer/2022050914/5a6d414e7f8b9a04428b50a7/html5/thumbnails/1.jpg)
BLOCKCHAIN AND SMART CONTRACTS
Introduction for Software Developers and Architects
![Page 2: Blockchain and Smart Contracts](https://reader033.vdocuments.mx/reader033/viewer/2022050914/5a6d414e7f8b9a04428b50a7/html5/thumbnails/2.jpg)
WHY BLOCKCHAIN IS A BIG DEAL
“Bitcoin is a technological tour de force.” – Bill Gates
”I think the fact that within the bitcoin universe an algorithm replaces the function of the government …[that] is actually pretty cool.” - Al Gore
“[Bitcoin] is a remarkable cryptographic achievement… The ability to create something which is not duplicable in the digital world has enormous value…Lot’s of people will build businesses on top of that.” - Eric Schmidt
![Page 3: Blockchain and Smart Contracts](https://reader033.vdocuments.mx/reader033/viewer/2022050914/5a6d414e7f8b9a04428b50a7/html5/thumbnails/3.jpg)
BLOCKCHAIN IS
Ledger of facts
Ledger of facts replicated across large number of computers
Ledger of facts replicated across large number of computers connected as peer-to-peer network
Ledger of facts replicated across large number of computers connected as peer-to-peer network that implements consensus algorithm that can securely identify sender and receiver of facts
FACTS
Monetary
transaction
Content
hash
Signature
Asset
informationOwnership
Agreement
Contract
![Page 4: Blockchain and Smart Contracts](https://reader033.vdocuments.mx/reader033/viewer/2022050914/5a6d414e7f8b9a04428b50a7/html5/thumbnails/4.jpg)
IS IT JUST ANOTHER SHARED DATABASE?
![Page 5: Blockchain and Smart Contracts](https://reader033.vdocuments.mx/reader033/viewer/2022050914/5a6d414e7f8b9a04428b50a7/html5/thumbnails/5.jpg)
NOT JUST ANOTHER DATABASE
Multiple WritersNon-trusting
writersDisintermediation
Interaction
between
transactions
Conflict
resolution
![Page 6: Blockchain and Smart Contracts](https://reader033.vdocuments.mx/reader033/viewer/2022050914/5a6d414e7f8b9a04428b50a7/html5/thumbnails/6.jpg)
HOW?Blocks
Decentralized consensus
Byzantine fault tolerance.
![Page 7: Blockchain and Smart Contracts](https://reader033.vdocuments.mx/reader033/viewer/2022050914/5a6d414e7f8b9a04428b50a7/html5/thumbnails/7.jpg)
CHAIN OF TRANSACTIONS
![Page 8: Blockchain and Smart Contracts](https://reader033.vdocuments.mx/reader033/viewer/2022050914/5a6d414e7f8b9a04428b50a7/html5/thumbnails/8.jpg)
TIMESTAMPS
![Page 9: Blockchain and Smart Contracts](https://reader033.vdocuments.mx/reader033/viewer/2022050914/5a6d414e7f8b9a04428b50a7/html5/thumbnails/9.jpg)
RECORDING TRANSACTION
![Page 10: Blockchain and Smart Contracts](https://reader033.vdocuments.mx/reader033/viewer/2022050914/5a6d414e7f8b9a04428b50a7/html5/thumbnails/10.jpg)
SMART CONTRACTS
Introduction to Smart Contracts
![Page 11: Blockchain and Smart Contracts](https://reader033.vdocuments.mx/reader033/viewer/2022050914/5a6d414e7f8b9a04428b50a7/html5/thumbnails/11.jpg)
EXAMPLE OF A CONTRACT
![Page 12: Blockchain and Smart Contracts](https://reader033.vdocuments.mx/reader033/viewer/2022050914/5a6d414e7f8b9a04428b50a7/html5/thumbnails/12.jpg)
EXAMPLE OF SMART CONTRACT
![Page 13: Blockchain and Smart Contracts](https://reader033.vdocuments.mx/reader033/viewer/2022050914/5a6d414e7f8b9a04428b50a7/html5/thumbnails/13.jpg)
SMART CONTRACT USE CASES
ICODigital
Identity
Public
records
SecuritiesInternational
tradeDerivatives
Mortgages Land title Supply chain
![Page 14: Blockchain and Smart Contracts](https://reader033.vdocuments.mx/reader033/viewer/2022050914/5a6d414e7f8b9a04428b50a7/html5/thumbnails/14.jpg)
HANDS-ON INTRODUCTION
TO SMART CONTRACTS
With Etherium and Solidity
![Page 15: Blockchain and Smart Contracts](https://reader033.vdocuments.mx/reader033/viewer/2022050914/5a6d414e7f8b9a04428b50a7/html5/thumbnails/15.jpg)
DEVELOPING SMART CONTRACT WITH TRUFFLE
Write Code
Create
deployment
script
Migrate/Deploy
![Page 16: Blockchain and Smart Contracts](https://reader033.vdocuments.mx/reader033/viewer/2022050914/5a6d414e7f8b9a04428b50a7/html5/thumbnails/16.jpg)
PREREQUISITES •$ sudo npm install -g truffle
•$ mkdir solidity-experiments
•$ cd solidity-experiments/
•$ truffle init
Truffle
Framework
•$ sudo npm install -g ethereumjs-testrpc
•$ testrpc &
Etherium
test network
•module.exports = {• networks: {• development: {• host: "localhost",• port: 8545,• network_id: "*" // Match any network id• }• }•}
Configure
truffle.js
![Page 17: Blockchain and Smart Contracts](https://reader033.vdocuments.mx/reader033/viewer/2022050914/5a6d414e7f8b9a04428b50a7/html5/thumbnails/17.jpg)
HELLO WORLD CONTRACT (SOLIDITY CODE)
pragma solidity ^0.4.4;
contract Hello {function Hello() public {
// constructor}
function sayHello() public pure returns (string) {
//console.log("sayHello() function called...");
return 'Hello World!';}
}
![Page 18: Blockchain and Smart Contracts](https://reader033.vdocuments.mx/reader033/viewer/2022050914/5a6d414e7f8b9a04428b50a7/html5/thumbnails/18.jpg)
DEPLOYMENT SCRIPT
var Hello1 = artifacts.require("./Hello.sol");
module.exports = function(deployer) {
deployer.deploy(Hello1);};
![Page 19: Blockchain and Smart Contracts](https://reader033.vdocuments.mx/reader033/viewer/2022050914/5a6d414e7f8b9a04428b50a7/html5/thumbnails/19.jpg)
CONTRACT DEPLOYMENT$ truffle consoletruffle(development)> truffle migrate --resetUsing network 'development'.
Running migration: 1_initial_migration.jsDeploying Migrations......
0xb6bbeaaf3649ecb38d548cba96f681682dad9e0225726924fbee3ce36eff94e3Migrations: 0xc08c46796ba0edc0bebbbd0d90868c010055cb0e
Saving successful migration to network......
0x16fe364b9f2c3e8f07fa1ebd6b84b8ad9b4e750d8698a7e920d824ebd019dd80Saving artifacts...Running migration: 2_deploy_contracts.jsDeploying Hello......
0xfe120836b2d7395bd988104feff018fe352f93555f71003bbf1a64671cca9ba1Hello: 0x2b649a87d20ce1ac3b6a0218e911165fa0f095f0
Saving successful migration to network......
0x1a09073a3b3f7996f3d63a81a99d8cd09198ad7b467f35f7ddc500a4291332b9Saving artifacts...truffle(development)>
![Page 20: Blockchain and Smart Contracts](https://reader033.vdocuments.mx/reader033/viewer/2022050914/5a6d414e7f8b9a04428b50a7/html5/thumbnails/20.jpg)
CONTRACT TEST
truffle(development)> var he = Hello.at(Hello.address)Undefined
truffle(development)> he.sayHello()'Hello World!'
![Page 21: Blockchain and Smart Contracts](https://reader033.vdocuments.mx/reader033/viewer/2022050914/5a6d414e7f8b9a04428b50a7/html5/thumbnails/21.jpg)
STAY IN TOUCHGene Leybzon https://www.linkedin.com/in/leybzon/
https://www.meetup.com/members/9074420/
https://www.Leybzon.com
![Page 22: Blockchain and Smart Contracts](https://reader033.vdocuments.mx/reader033/viewer/2022050914/5a6d414e7f8b9a04428b50a7/html5/thumbnails/22.jpg)
ANNOUNCEMENTS
Blockchain and Crypto "Unconference" this Sunday 1/28 from 3-5PM in room Z301 at the GSB Stanford