blockchain - introduction and authoring smart contracts

23
1 Vikas Grover [email protected] Offline Slack Channel : www.tinyurl.com/letsdoblockchain www.meetup.com/Blockchain-Revolution Blockchain & Authoring Smart Contracts

Upload: vikas-grover

Post on 16-Apr-2017

353 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Blockchain - Introduction and Authoring Smart Contracts

1

Vikas [email protected] Slack Channel : www.tinyurl.com/letsdoblockchainwww.meetup.com/Blockchain-Revolution

Blockchain & Authoring Smart Contracts

Page 2: Blockchain - Introduction and Authoring Smart Contracts

[email protected]

Offline Slack Channel : www.tinyurl.com/letsdoblockchain

Agenda

● Introduction● Smart Contracts● Test RPC and Geth● Truffle● Dapp

Page 3: Blockchain - Introduction and Authoring Smart Contracts

[email protected]

Offline Slack Channel : www.tinyurl.com/letsdoblockchain

Introduction

Blockchain creates a permanent, digitized chain of transactions, grouped in blocks, allowing virtually anything of value to be tracked and traded, without requiring a central point of control

Blockchain is a peer-to-peer distributed ledger technology for a new generation of transactional applications.

Page 4: Blockchain - Introduction and Authoring Smart Contracts

[email protected]

Offline Slack Channel : www.tinyurl.com/letsdoblockchain

What is in Block

Header, Transaction Count, Block Content

Transaction

Input Output

Page 5: Blockchain - Introduction and Authoring Smart Contracts

[email protected]

Offline Slack Channel : www.tinyurl.com/letsdoblockchain

Public, Private, Consortium/Hybrid

First thing First – Do you even need a Blockchain?

● Database with Shared Access● Who Controls the Functionality?● Public or Private Transactions?● Determining Consensus?

Page 6: Blockchain - Introduction and Authoring Smart Contracts

[email protected]

Offline Slack Channel : www.tinyurl.com/letsdoblockchain

Public, Private, Hybrid

● Public Blockchain: Fully Public, Secured by Cryptocurrencies (Proof of work, Proof of Stake etc), Its for Anyone – Read, Send Transactions, Participate in Consensus Process

● Private Blockchain: Controlled Access, Write permissions are kept centralized to one organization, Read permissions may be public or not (or some part may be public)

● Consortium/Hybrid Blockchain: Pre-selected set of nodes for eg: 15 financial institutions

Page 7: Blockchain - Introduction and Authoring Smart Contracts

[email protected]

Offline Slack Channel : www.tinyurl.com/letsdoblockchain

Public, Private, Hybrid

Public Blockchain● Freedom● Neutrality● Openness

Private Blockchain● Known Validator (51% risk

goes away)● Cheaper Transactions● Privacy

No way that there is going to be One way to do Blockchain

Page 8: Blockchain - Introduction and Authoring Smart Contracts

[email protected]

Offline Slack Channel : www.tinyurl.com/letsdoblockchain

Bitcoin – Digitally Signed

Page 9: Blockchain - Introduction and Authoring Smart Contracts

[email protected]

Offline Slack Channel : www.tinyurl.com/letsdoblockchain

Ethereum

● Founder of Ethereum - Vitalik Buterin (22 year old) won the 2014 World Technology Award for invention of Blockchain.

● Ethereum to build programming tools to make Blockchain power any/everything.

● Ethereum is Dynamic and Programmable. You can implement the way you want. For eg: Using Java Script you can implement almost anything.

Page 10: Blockchain - Introduction and Authoring Smart Contracts

[email protected]

Offline Slack Channel : www.tinyurl.com/letsdoblockchain

What is Better with Ethereum

Page 11: Blockchain - Introduction and Authoring Smart Contracts

[email protected]

Offline Slack Channel : www.tinyurl.com/letsdoblockchain

Smart Contract

Smart contracts are computer protocols that facilitate, verify, or enforce the negotiation or performance of a contract, or that make a contractual clause unnecessary.

Smart contracts usually also have a user interface and often emulate the logic of contractual clauses.

Trust the Bank

Trust the Code

Page 12: Blockchain - Introduction and Authoring Smart Contracts

[email protected]

Offline Slack Channel : www.tinyurl.com/letsdoblockchain

Smart Contract – Online Browser

Page 13: Blockchain - Introduction and Authoring Smart Contracts

[email protected]

Offline Slack Channel : www.tinyurl.com/letsdoblockchain

Smart Contract – Mist

Page 14: Blockchain - Introduction and Authoring Smart Contracts

[email protected]

Offline Slack Channel : www.tinyurl.com/letsdoblockchain

Different Needs Different Clients

● When Developing● Ethereum JS TestRPC

● When Deploying:● Geth● Webthree● Others

Page 15: Blockchain - Introduction and Authoring Smart Contracts

17

TRUFFLE

Page 16: Blockchain - Introduction and Authoring Smart Contracts

[email protected]

Offline Slack Channel : www.tinyurl.com/letsdoblockchain

TruffleWhat is Truffle

● Development Environment

● Testing Framework

● Asset Pipeline

Page 17: Blockchain - Introduction and Authoring Smart Contracts

[email protected]

Offline Slack Channel : www.tinyurl.com/letsdoblockchain

TruffleWhat do you get with Truffle

● Built-in smart contract compilation, linking, deployment and binary management.● Automated contract testing with Mocha and Chai.● Configurable build pipeline with support for custom build processes.● Scriptable deployment & migrations framework● Network management for deploying to many public & private networks.● Interactive console for direct contract communication● Instant rebuilding of assets during development.● External script runner that executes scripts within a Truffle environment.● Support for JavaScript, SASS, ES6 and JSX built-in.

Page 18: Blockchain - Introduction and Authoring Smart Contracts

[email protected]

Offline Slack Channel : www.tinyurl.com/letsdoblockchain

Getting Started with Truffle

● Getting Started● Install Truffle● Commands

● mkdir myproject● cd myproject● truffle init

● app● contracts● migrations● test● truffle.js

● truffle compile

Page 19: Blockchain - Introduction and Authoring Smart Contracts

[email protected]

Offline Slack Channel : www.tinyurl.com/letsdoblockchain

Testing with Truffle

● Automated Testing● Mocha

● Assertion● Chai

● All test files should be located in the ./tests directory. Truffle will only run test files with the following file extensions: .js, .es, .es6, and .jsx. All other files are ignored.

Page 20: Blockchain - Introduction and Authoring Smart Contracts

[email protected]

Offline Slack Channel : www.tinyurl.com/letsdoblockchain

Interacting with SmartContract

● Use Web3● Little Difficult though

● Use Ether Pudding● Chai

● All test files should be located in the ./tests directory. Truffle will only run test files with the following file extensions: .js, .es, .es6, and .jsx. All other files are ignored.

Page 22: Blockchain - Introduction and Authoring Smart Contracts

[email protected]

Offline Slack Channel : www.tinyurl.com/letsdoblockchain

Dapp

● Frontend and Backend● Reactive Programming – callback functions● Web3.js

● version● api● node/getNode● network/getNetwork● ethereum/getEthereum● whisper/getWhisper● isConnected()● setProvider(provider)● CurrentProvider● Etc etc etc

Page 23: Blockchain - Introduction and Authoring Smart Contracts

[email protected]

Offline Slack Channel : www.tinyurl.com/letsdoblockchain

Thanks