a gentle introduction to blockchain with ethereum

36
A Gentle Introduction To Blockchain With Ethereum Johann Romefort, Tech Evangelist at Stylight Twitter: @romefort Blog: http://romefort.net LinkedIn: http://linkedin.com/in/romefort Email: [email protected]

Upload: johann-romefort

Post on 21-Jan-2018

119 views

Category:

Technology


5 download

TRANSCRIPT

Page 1: A Gentle introduction to Blockchain with Ethereum

A Gentle Introduction To Blockchain With Ethereum

Johann Romefort, Tech Evangelist at Stylight

Twitter: @romefortBlog: http://romefort.netLinkedIn: http://linkedin.com/in/romefortEmail: [email protected]

Page 2: A Gentle introduction to Blockchain with Ethereum

Agenda

● The Trust Industry● Disruptive Nature of Blockchain● Ethereum● Demo!

Page 3: A Gentle introduction to Blockchain with Ethereum

What Is the Buzz about Blockchain

Page 4: A Gentle introduction to Blockchain with Ethereum
Page 5: A Gentle introduction to Blockchain with Ethereum

The History of Trust and Exchange of Value

Page 6: A Gentle introduction to Blockchain with Ethereum

3500 Years Ago: The Signet Ring

Signet rings have been used since as far back as 3500 BC when the people of Mesopotamia began using them as a method of authenticity. Each was unique to one person.

Page 7: A Gentle introduction to Blockchain with Ethereum

Today: 3rd-Party Trust Guarantors

● Banks

● Insurance

● Land registries

● Governments

● Credit companies

● Legal Agencies

Page 8: A Gentle introduction to Blockchain with Ethereum

Trust Comes at a Price

● Operational Costs● Risk● Time ● Centralization

Page 9: A Gentle introduction to Blockchain with Ethereum

3rd-Party Trust Is Fragile and Disrupted

● 2008 financial meltdown● Government surveillance● Elections● Social media giants● Data breaches

Page 10: A Gentle introduction to Blockchain with Ethereum

The Edelman Trust Barometer

Source: https://www.scribd.com/document/336621519/2017-Edelman-Trust-Barometer-Executive-Summary

Page 11: A Gentle introduction to Blockchain with Ethereum

The Double-Spending Problem

● You need to make sure the ownership of the item of value is moving from A to B

● In a digital world this is a problem as assets can be copied.

● This is why we needed 3rd party which we can trust and can ensure the validity of the transaction

Page 12: A Gentle introduction to Blockchain with Ethereum

Until January 3rd, 2009

First blockchain implementation deployed under the name:

“Bitcoin: A Peer-to-Peer Electronic Cash System”

By Satoshi Nakamoto

Page 13: A Gentle introduction to Blockchain with Ethereum

The Distributed and Transparent Nature of

Blockchain

Page 14: A Gentle introduction to Blockchain with Ethereum

What is Blockchain?● It’s an immutable distributed public ledger● All transactions are timestamped and recorded

into blocks● Distributed database with no single point of

failure● Can’t be controlled by authorities such as

government due to its decentralized nature● Solve the double-spending problem without

need for 3rd party of trust.

Page 15: A Gentle introduction to Blockchain with Ethereum

What is a Hash?● Mathematical function which turns data into a

fingerprint of that data called ● You can’t deduce the data from the hash.● The same data will have the same Hash.● Slightly different data will have a totally different hash

Page 16: A Gentle introduction to Blockchain with Ethereum

What about Ethereum?

● It’s the second largest Blockchain implementation

● It can be a seen as a blockchain of second generation

● It contains new features such as Smart Contracts

Page 17: A Gentle introduction to Blockchain with Ethereum

What’s a Block?

● Bundle transactions● Contains previous block hash● All blocks are linked through their hashes● You can’t change the data in one block

without breaking the chain● Unless you mine it all over again

Page 18: A Gentle introduction to Blockchain with Ethereum

What’s a transaction?

● An operation that writes data on the blockchain● Each transaction incurs a fee● Simple transaction sending ETH from one address to

another● More complicated transactions involve Smart Contracts

Page 19: A Gentle introduction to Blockchain with Ethereum

Smart Contracts● Introduced in Ethereum Blockchain

● Run code directly on the blockchain

● Each smart contract has its own wallet

● Smart Contracts can invoke each others

● Written in Solidity

Page 20: A Gentle introduction to Blockchain with Ethereum

Enabling New kinds of Organizations

● DAO: Decentralized

Autonomous

Organization

● New type of

organization governed

by multiple smart

contracts

● Token holders can be

granted the right to

vote for example

Page 21: A Gentle introduction to Blockchain with Ethereum

Developing with Ethereum

Page 22: A Gentle introduction to Blockchain with Ethereum

Many chains available

● Main Net: This is the production network - Don’t use it for development purposes!

● Rinkeby: https://www.rinkeby.io/#stats○ PoA (Proof of Authority)

○ Immune to Spam attacks

○ Supported by geth only

○ Request ether through faucet: https://faucet.rinkeby.io/

● Ropsten: Best reproduce the current prod. Env.○ Subject to Spam

○ Ether can be mined or requested

● Solo Network

Page 23: A Gentle introduction to Blockchain with Ethereum
Page 24: A Gentle introduction to Blockchain with Ethereum

Truffle - development framework for Ethereum

Page 25: A Gentle introduction to Blockchain with Ethereum

Setting up our development environment

npm install -g truffle

npm install -g ganache-cli

truffle init

ganache-cli -p 7545

Page 26: A Gentle introduction to Blockchain with Ethereum

Ganache run a local EVM (Ethereum Virtual Machine)

Also:

● Create accounts ● their private keys● Fund the accounts

with 100ETH

Page 27: A Gentle introduction to Blockchain with Ethereum

Our first Smart Contract: HelloWorld.sol

Page 28: A Gentle introduction to Blockchain with Ethereum

Write the migration

Save this in migrations/2_deploy

Page 29: A Gentle introduction to Blockchain with Ethereum

Adjust truffle.jsYou can also get rid of the truffle-config.js file // depending on your platform

Page 30: A Gentle introduction to Blockchain with Ethereum

Let’s compile and deploy our contract

truffle compiletruffle migrate --network development

Compile will compile our Solidity code to bytecode (the code that the Ethereum Virtual

Machine (EVM) understands), in our case, Ganache emulates the EVM.

Migrate will deploy the code to the blockchain, in our case, the blockchain could be found in

the network “development” we set earlier in the “truffle-config.js” file.

Page 31: A Gentle introduction to Blockchain with Ethereum

Migration in progress...

Page 32: A Gentle introduction to Blockchain with Ethereum

Using Truffle console

Page 33: A Gentle introduction to Blockchain with Ethereum

Interact with the Contract

1/get an instance

2/get the contract address

3/get the message var content

Page 34: A Gentle introduction to Blockchain with Ethereum

If you prefer a GUI

Page 35: A Gentle introduction to Blockchain with Ethereum

Questions?

Page 36: A Gentle introduction to Blockchain with Ethereum