blockchain - introduction and authoring smart contracts
TRANSCRIPT
1
Vikas [email protected] Slack Channel : www.tinyurl.com/letsdoblockchainwww.meetup.com/Blockchain-Revolution
Blockchain & Authoring Smart Contracts
Offline Slack Channel : www.tinyurl.com/letsdoblockchain
Agenda
● Introduction● Smart Contracts● Test RPC and Geth● Truffle● Dapp
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.
Offline Slack Channel : www.tinyurl.com/letsdoblockchain
What is in Block
Header, Transaction Count, Block Content
Transaction
Input Output
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?
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
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
Offline Slack Channel : www.tinyurl.com/letsdoblockchain
Bitcoin – Digitally Signed
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.
Offline Slack Channel : www.tinyurl.com/letsdoblockchain
What is Better with Ethereum
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
Offline Slack Channel : www.tinyurl.com/letsdoblockchain
Smart Contract – Online Browser
Offline Slack Channel : www.tinyurl.com/letsdoblockchain
Smart Contract – Mist
Offline Slack Channel : www.tinyurl.com/letsdoblockchain
Different Needs Different Clients
● When Developing● Ethereum JS TestRPC
● When Deploying:● Geth● Webthree● Others
17
TRUFFLE
Offline Slack Channel : www.tinyurl.com/letsdoblockchain
TruffleWhat is Truffle
● Development Environment
● Testing Framework
● Asset Pipeline
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.
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
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.
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.
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
Offline Slack Channel : www.tinyurl.com/letsdoblockchain
Thanks