Developing Blockchain Applications November 28, 2018 getting started with ethereum
our	goal	today 1. Understand	how	Ethereum	applications	work 2. Understand	the	framework	and	how	projects	are	structured 3. Write	and	deploy	code
few	questions	before	we	start… • Have	you	transacted	ETH? • Do	you	know	what	dapps are? • Have	you	used	a	dapp? • Have	you	written	a	smart	contract	or	developed	a	dapp?
Part	1:	Ethereum	Architecture and	how	do	Ethereum	apps	work?
Some	Definitions… Ethereum Network Collection of nodes that transact Ether and store data Node Any computer running the Ethereum client Ethereum Client Piece of software that communicates with Ethereum Network
Client-Server Architecture
Tale	of	an	ebay	seller… • Can	the	seller	take	their	ratings and	feedback	history	and	join another	online	marketplace? • Should	they	be	able	to? • What’s	the	incentive	for	ebay to	make	this	possible? • An	ebay	seller	with	excellent	ratings • ebay	bans	the	seller	for	violation	of	their	T&Cs • Let’s	assume	that	the	seller	was	not	at	fault	but	they	were banned/suspended	anyway
Centralized	vs.	Decentralized	Apps Centralized (Client-Server) Decentralized (Dapps) Logic Cluster of servers contain the entire logic. All logic is contained in the contract. Once the contract is mined, all nodes have the exact same logic, saved on their copy of the blockchain. Data Integrity Maintained by strict set of rules enforced by the infrastructure, tools, and services. Taken care via redundancy of the nodes in the network.
Dapp Architecture
Dapp Architecture
Metamask Metamask	is	a	Google Chrome	extension	that makes	Chrome	an Ethereum	connected browser. https://metamask.io/
Getting	Metamask • Go	to	https://metamask.io/ • Get	Chrome	Extension • Add	to	Chrome • Launch	Metamask	and	follow	the	setup guide
Funding	Metamask	with	Ether Click Buy
Funding	Metamask	with	Ether
Donating	back	to	Faucet
Mist Browser • https://github.com/eth ereum/mist/releases • Simply download	and install	the executable	for your	OS
Dapp Examples Ethlance Ethlance	is	a	decentralized freelancer	platform	for the	exchange	of	work	for Ether,	rather	than traditional	currencies. https://ethlance.com/
Dapp Examples Swarm	City Swarm	City	is	a	decentralized	P2P	sharing economy.	Some	have	called	it	Uber	or Craigslist	on	the	blockchain.	It	requires users	to	have	a	Swarm	City	Token	in order	to	pay	for	transactions	in	the ecosystem. https://swarm.city/
Dapp Examples WeiFund WeiFund is	a	crouwdsourcing app	on	the Ethereum	Ecosystem. http://weifund.io/
Dapp Architecture
Dapp System	Architecture
IPFS
How	is	Ethereum	different	from	Bitcoin blockchain? Bitcoin Ethereum Bitcoin uses a simple scripting system for transactions. Bitcoin script is simple, stack-based, and is intentionally not Turing-complete, with no loops. Ethereum platform is built with a Turing- complete language. Send bitcoin from Alice to Bob Send ether from Alice to Bob if… • Bob’s balance is less than 2 eth • Date > 2019/01/01
Ethereum	Accounts • External • Contract
Part	2:	Dev	Setup Install	the	tools	and	understand	the	framework
Ecosystem,	tools,	terms,	products… ETH Ethereum networks’ native crypto-currency EVM Ethereum Virtual Machine providing decentralized computation service Swarm Provides P2P file sharing and storage services Whisper Protocol used by nodes to communicate with each other Solidity, Serpent, LLL Smart contract programming languages eth, geth, pyethapp Main ethereum software written in C++, Go, Python respectively.
Serverless	Stack Whisper Encrypted messaging protocol that allows nodes to send messages directly to each other in a secure way; hides sender and receiver identity from snoopers Swarm P2P file sharing, similar to BitTorrent, but rewarded with micropayments of ETH (Storage Layer) Ethereum Virtual Machine (EVM) Runs the contract logic
There	are	many	different	Ethereum	Networks • One	main	Ethereum	network	– used	for	deployment	of	production applications • Test	Networks	– Ropsten,	Rinkeby,	Kovan • Private	Network	on	your	own	computer • Create	your	own	network	and	open	it	for	others	to	use.
Test	Networks Ropsten • Resembles the main network • Uses Proof of Work consensus algorithm • Supported by Geth and Parity • https://ropsten.etherscan.io/ Rinkeby • Uses Proof of Authority; you need to prove your existence (social media) to retrieve ethers • All ethers are already mined and only distributed on demand • Supported by Geth • https://rinkeby.etherscan.io/ Kovan • Uses Proof of Authority; requires Github account • Supported by Parity • https://kovan.etherscan.io/
Tools	we	need Node Packet Manager (npm) NPM is a package manager for Node.js packages and modules Ganache • Ethereum client for testing and development • Runs locally and simulates a full Ethereum client • Fast • Well supported ecosystem of tools Truffle • Dev environment, testing framework, and asset pipeline for Ethereum • Helps deploy contracts to the blockchain • Help connect front-end to your deployed contracts MetaMask • Ethereum light client • Allows you to interact with Dapps via Chrome
Development	workflow 1. Download	and	start	an	ethereum	node 2. Code	and	compile	your	smart	contract 3. Deploy	your	compiled	contract	on	the	network	using	a	framework like	truffle 4. Call	stuff	in	the	contract	using	web3.js
NPM • Download	and	install	Node https://nodejs.org/
Install	Ganache • https://truffleframework.com/ganache
Launch	Ganache
Install	Truffle • https://truffleframework.com/truffle
Part	3:	Code	and	Deploy Code	your	first	smart	contract	and	deploy	it	on	blockchain
Setting	up	your	project Ømkdir HelloEth Øcd HelloEth Øtruffle init
workflow truffle compile This command compiles the contracts in your contracts folder and will create artifacts (JSON files) that contain the bytecode that can be executed on the network. truffle migrate Deploy the contract on your test network. Migrations are scripts that follow a series of steps that are needed to deploy your contracts and setup the projects like you need them to setup. truffle console To inspect the contract
workflow truffle compile This command compliles the contracts in your contracts folder and will create artifacts (JSON files) that contain the bytecode that can be executed on the network. truffle migrate Deploy the contract on your test network. Migrations are scripts that follow a series of steps that are needed to deploy your contracts and setup the projects like you need them to setup. truffle console To inspect the contract
truffle	migrate	--reset
workflow truffle compile This command compliles the contracts in your contracts folder and will create artifacts (JSON files) that contain the bytecode that can be executed on the network. truffle migrate Deploy the contract on your test network. Migrations are scripts that follow a series of steps that are needed to deploy your contracts and setup the projects like you need them to setup. truffle console To inspect the contract
Truffle 3 Truffle 2
Now	that	we	can	call()	our	contract,	let’s	create	a transaction	that	changes	state.
Get	a	list	of	accounts
Get	balance
Summary	of	what	we	did	today 1. Understand	how	Ethereum	applications	work 2. Overview	of	the	framework	and	a	small	sliver	of	tools	in	the ecosystem 3. Wrote	and	deployed	a	smart	contract
Thank you

Developing Blockchain Applications