210 likes | 413 Views
SIGCSE Workshop #108 - Programming Smart Contracts in Ethereum Blockchain using Solidity. Debasis Bhattacharya, JD, DBA – UH Maui College, HI Mohammad Azhar , PhD – CUNY BMCC, NY Mario Canul – UH Maui College, HI Saxon Knight – UH Maui College, HI Rajiv Malkan – Lone Star College, TX
E N D
SIGCSE Workshop #108 - Programming Smart Contracts in Ethereum Blockchain using Solidity Debasis Bhattacharya, JD, DBA – UH Maui College, HI Mohammad Azhar, PhD – CUNY BMCC, NY Mario Canul – UH Maui College, HI Saxon Knight – UH Maui College, HI Rajiv Malkan – Lone Star College, TX Takashi Sugimura, PhD – UH Maui College, HI http://maui.hawaii.edu/cybersecurity debasisb@hawaii.edu University of Hawaii Maui College February 27, 2019 Supported by NSF ATE Award # 1700562
Agenda • Module 1 - Cryptocurrencies • Bitcoin Basics, Mining, Consensus, Security – (20 minutes) • Module 2 - Ethereum and Blockchain • Ethereum Basics, Cryptography, Wallets, Transactions – (20 minutes) • Module 3 - Smart Contracts • Smart Contracts and Demo – (15 minutes) • Break – (5 minutes) • Lab - Programming a simple Smart Contract using Solidity – (90 minutes) • Module 4 - Distributed Apps (DApps) • Transition to the classroom (30 minutes) • Next Steps… SIGCSE 2019 Blockchain Workshop #108 - Module 2
Source: https://ubri.ripple.com/faq/ SIGCSE 2019 Blockchain Workshop #108 - Module 2
Demo – Hello World Smart Contracton Remix – Solidity IDE pragma solidity >= 0.4.22 <0.6.0; contract Mortal{ address owner; constructor() public { owner = msg.sender; } function die() public { if(msg.sender == owner) selfdestruct(msg.sender); } } contract Helloworld is Mortal{ string output = "Hello, World!"; function printHello() public view returns (string memory) { return output; } } SIGCSE 2019 Blockchain Workshop #108 - Module 2
Demo Instructions • Copy the code and paste into Remix at https://remix.Ethereum.org • Since it is the latest compiler, click on Start to compile or (Ctrl-S) • Once compiled, click on Run tab • In Run, make sure Environment is set to JavaScript VM • Click on pink button Deploy under Helloworld • A smart contract Helloworld will be deployed in memory • Click on Helloworldsmartcontract at bottom of screen (at memory location in blockchain) to access its functions – die and printHello • Click on printHello function to see output “0: string: Hello, World” • Click on die function to remove smart contract from blockchain SIGCSE 2019 Blockchain Workshop #108 - Module 2
References • Ethereum Overview and Tutorial – Josh Quintal Truffle, 2017 • Solidity Tutorial to Smart Contracts – Intro to Smart Contracts • Installing the Solidity Compiler - Using npm/NodeJS, Docker etc. • Code Examples in Solidity – Voting, Blind Auction, Safe Purchase etc. • Solidity Style Guide – Solidity v0.5.4 • Ethereum Command Line tools (CLI) – Geth and Eth from Ethereum Network • Ethereum Greeter Smart Contract – Sample tutorial from Ethereum • Truffle Suite Download – Download the Truffle Software • Ganache Suite Download – Download the Ganache Software • Setting up a Pet Shop Dapp – Truffle Tutorial • Building React Native Dapps– Truffle Tutorial with Drizzle v1.3+ SIGCSE 2019 Blockchain Workshop #108 - Module 2