javascript toolset for ethereum smart contract development

23
ETHEREUM FOR JAVASCRIPT DEVELOPERS GreeceJS #21 @panosjee Panos Papadopoulos Founder GreeceJS

Upload: bugsense

Post on 22-Jan-2018

110 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Javascript toolset for Ethereum Smart Contract development

ETHEREUMF O R J A V A S C R I P T D E V E L O P E R S

GreeceJS #21 @panosjee

Panos Papadopoulos Founder GreeceJS

Page 2: Javascript toolset for Ethereum Smart Contract development

I am a software engineer that joined the other side of the Force

I am a Partner at Marathon VC

I was a founder at BugSense and Greece JS

Hello!I Am Panos

You can contact me at @panosjee

Page 3: Javascript toolset for Ethereum Smart Contract development

Ethereum aims to be the global, decentralised, unstoppable, uncensorable computer.

(Using blockchain and ponies of course)

ETHEREUM

Page 4: Javascript toolset for Ethereum Smart Contract development

I should have ICO’ed back then

Page 5: Javascript toolset for Ethereum Smart Contract development

The crazy 2017 Ethereum rally

Page 6: Javascript toolset for Ethereum Smart Contract development

THE BLOCKCHAINIn case you are living under a rock

But way more complex in the case of Ethereum

Page 7: Javascript toolset for Ethereum Smart Contract development

Every 14 seconds the results of the programs execution are shared and verified across all the nodes of the network. The

new state is written in the blockchain.

Ethereum programs are called Smart Contracts and are usually written in

Solidity, Viper and LLL. Smart Contracts can be accessed via the web thanks to

web3.js

Ethereum listens to other nodes and executes

program that compile to Ethereum Virtual Machine

Users run an Ethereum client, usually geth (the

official client written in Go)

Ethereum for dummies

Nodes

EVM

SmartContracts

EtherSmart Contract execution and

storage costs. The cost is called gas and can be

purchased for Ether the native currency of the network

Page 8: Javascript toolset for Ethereum Smart Contract development

Enterprise Ethereum is an official effort to bring private Ethereum networks to the corporate world.

Corporate friendly14 seconds block generation makes for quick transactions and “fast” socially scalable programs.

Fast

Elliptical cryptography used for wallets, PoW to secure blockchain (might change to PoS)

SecureEthereum creates a computing platform that cannot be stopped or altered

Uncensorable

Ethereum is one the most well performing crypto-currencies of 2017.

Asset

Ethereum has a large enthusiastic community building blocks and dapps

Community

ETHEREUM CORE FEATURES

Page 9: Javascript toolset for Ethereum Smart Contract development

The Ether issuance model

Page 10: Javascript toolset for Ethereum Smart Contract development

What is the use case for smart contracts?Automate lawyers and trusted 3rd parties out of existence. Think processes that require trust:- Financial instruments- Voting- Tickets- Registries - Ballots- Marketplaces- Scams aka ICOs

Page 11: Javascript toolset for Ethereum Smart Contract development

The main toolset includes the official smart contract language solidity and web3.js

npm install solcnpm install web3npm install soliumnpm install trufflenpm install ethereumjs-testrpc

Oh and Meteor is a thing for the Ethereum community.

ToolsA wallet stores your private & public keys that generate addresses and sign your transactions.At a minimum you need a wallet to store & send Ether, interact & deploy smart contracts. Holding your keys makes you sovereign.

Popular wallets:- MyEtherWallet- Mist- Coinbase (exchange)

WalletRunning your node is educational, useful and wasteful (good luck syncing).

Geth is the official clientParity has f***d up several times.Implementations in Python, JS, C++, Java. Use at your own risk.Clients expose console, JSON-RPC, logs.

Node (or not)

WHAT YOU NEED TO START

Page 12: Javascript toolset for Ethereum Smart Contract development

““Writing smart contracts on

Ethereum is a pleasure and the tools are great”

No one, 2017

Page 13: Javascript toolset for Ethereum Smart Contract development

LET’S ICO GreeceJS

Pump

Throw decentralisation buzz works

Release whitepaper

Dump

Cash out

Bro down

Page 14: Javascript toolset for Ethereum Smart Contract development

testrpc is a Node.js based Ethereum client for testing and development. It uses ethereumjs to simulate full client behavior and make developing Ethereum applications much faster. It also includes all popular RPC functions and features (like events) and can be run deterministically to make development a breeze.

Sanity tip: use -db to keep accounts after restarts

Tools: ethereum-jsonrpcInstall, sync & run a full client is a hassle (but also the point)

Page 15: Javascript toolset for Ethereum Smart Contract development

This is probably the most portable and most convenient way to install Solidity locally.

A platform-independent JavaScript library is provided by compiling the C++ source into JavaScript using Emscripten. It can be used in projects directly (such as Remix). Please refer to the solc-js repository for instructions.

Tools: solc-jsThe fastest way to install the Solidity compiler

Page 16: Javascript toolset for Ethereum Smart Contract development

To make your app work on Ethereum, you can use the web3 object provided by the web3.js library. Under the hood it communicates to a local node through RPC calls. web3.js works with any Ethereum node, which exposes an RPC layer.

Tools: web3.jsThe library that exposes Ethereum to rest of us

web3 runs in the browser. If web3 is loaded and can access Ethereum keys then you can run any Dapp in your browser.

The most common way to inject web3 into a window and be able to control an Ethereum wallet is the Metamask Chrome plugin.

Page 17: Javascript toolset for Ethereum Smart Contract development

MetaMask is a bridge that allows you to visit the distributed web of tomorrow in your browser today. It allows you to run Ethereum dApps right in your browser without running a full Ethereum node. (because Mist sucks)

MetaMask includes a secure identity vault, providing a user interface (duh) to manage your identities on different sites and sign blockchain transactions.

Bonus: IPFS Station Chrome plugin allows you to access IPFS urls seamlessly from your local IPFS node, and take a look at its stats.

Tools: MetamaskMake Chrome Ethereum-aware

Page 18: Javascript toolset for Ethereum Smart Contract development

Truffle is the most popular development framework for Ethereum.

Truffle gives structure to your smart contract and help you compile, test, deploy and migrate.

EthPM is the package manager for Smart Contracts B-E-W-A-R-E

You can write tests in both JS and Solidity. When it comes to “trusted” computing you cannot escape tests!

Tools: TruffleLet’s use some JS skills to manage Solidity dapps life cycle

candy maple cake sugar pudding cream honey rich smooth crumble sweet treat

Page 19: Javascript toolset for Ethereum Smart Contract development

Version pragma: Solidity upgrades break things, make sure the target is right!

Functions execute code internally or externally

Function Modifiers aka decorators

Events change the state, therefore you pay for their execution. Events are dispatched signals the smart contracts can fire. DApps, or anything connected to Ethereum JSON-RPC API, can listen to these events and act accordingly. Event can be indexed, so that the event history is searchable later.

event Deposit(address from, uint value);

Anatomy of a smart contract

Demo Time!

Page 20: Javascript toolset for Ethereum Smart Contract development

Deploy a smart contract

Choose a network (testrpc, testnets: [morden, ropsten, kovan, rinkeby], live)

Have enough gas to pay for deployment

When you deploy you become the owner of the contract unless if specified otherwise

Contract is deployed at an address. App.contracts.GreeceJSToken.deployed().then

ABI (Application Binary Interface) is generated without you cannot interact with web3.js.

ENS (Ethereum Naming System) to the rescue.

Store your web3.js at Swarm or IPFS

Page 21: Javascript toolset for Ethereum Smart Contract development

Tools: Remix

Page 22: Javascript toolset for Ethereum Smart Contract development

Tools: EtherscanBlockchain browser- Transaction explorer- Block explorer- Inspect smart contracts- Monitor addresses- See logs

Page 23: Javascript toolset for Ethereum Smart Contract development

Thanks!Let’s talk @panosjee [email protected]

Any questions?