Building Ethereum DApps: Decentralized Applications on the Ethereum Blockchain
Summary

Building Ethereum Dapps introduces you to decentralized applications based on the Ethereum blockchain platform. In this book, you'll learn the principles of Dapps development by rolling up your sleeves and actually building a few!

Foreword by Thomas Bertani.

Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.

About the Technology

Imagine unbreakably secure applications that handle personal and business transactions without any central agency controlling the process. Decentralized applications, or Dapps, do just this, shifting power to users. The Ethereum blockchain platform provides the tools you need to build Dapps, including an innovative "smart contracts" model and Solidity, a Dapp-aware JavaScript-like programming language.

About the Book

Building Ethereum Dapps teaches Dapps development on the Ethereum blockchain platform. You'll begin with a mental model of how Dapps operate, and then dive into designing and implementing smart contracts in Ethereum's Solidity language. You'll explore Ethereum smart contract development tools, like Truffle and Web3, and pick up best practices for design and security. Practical exercises throughout give you valuable hands-on experience.

What's inside

  • Ethereum's key components
  • Implementing smart contracts in Solidity
  • Communicating with a smart contract in Web3
  • Developing Dapps with Truffle
  • Best practices for design and security improvement

About the Reader

For developers with intermediate experience in JavaScript or an OO language. Familiarity with blockchain concepts is helpful.

About the Author

Roberto Infante is a software development consultant who specializes in finance. He currently works on financial risk management systems and on blockchain technology.

Table of Contents

    PART 1
  1. A first look at decentralized applications
  2. Understanding the blockchain
  3. The Ethereum platform
  4. Deploying your first smart contract
  5. PART 2
  6. Programming smart contracts in Solidity
  7. Writing more complex smart contracts
  8. Generalizing functionality with abstract contracts and interfaces
  9. Managing smart contracts with Web3.js
  10. PART 3
  11. The Ethereum ecosystem
  12. Unit testing contracts with Mocha
  13. Improving the development cycle with Truffle
  14. Putting it all together: Building a complete voting Dapp
  15. PART 4
  16. Making a Dapp production ready
  17. Security considerations
  18. Conclusions
1128580894
Building Ethereum DApps: Decentralized Applications on the Ethereum Blockchain
Summary

Building Ethereum Dapps introduces you to decentralized applications based on the Ethereum blockchain platform. In this book, you'll learn the principles of Dapps development by rolling up your sleeves and actually building a few!

Foreword by Thomas Bertani.

Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.

About the Technology

Imagine unbreakably secure applications that handle personal and business transactions without any central agency controlling the process. Decentralized applications, or Dapps, do just this, shifting power to users. The Ethereum blockchain platform provides the tools you need to build Dapps, including an innovative "smart contracts" model and Solidity, a Dapp-aware JavaScript-like programming language.

About the Book

Building Ethereum Dapps teaches Dapps development on the Ethereum blockchain platform. You'll begin with a mental model of how Dapps operate, and then dive into designing and implementing smart contracts in Ethereum's Solidity language. You'll explore Ethereum smart contract development tools, like Truffle and Web3, and pick up best practices for design and security. Practical exercises throughout give you valuable hands-on experience.

What's inside

  • Ethereum's key components
  • Implementing smart contracts in Solidity
  • Communicating with a smart contract in Web3
  • Developing Dapps with Truffle
  • Best practices for design and security improvement

About the Reader

For developers with intermediate experience in JavaScript or an OO language. Familiarity with blockchain concepts is helpful.

About the Author

Roberto Infante is a software development consultant who specializes in finance. He currently works on financial risk management systems and on blockchain technology.

Table of Contents

    PART 1
  1. A first look at decentralized applications
  2. Understanding the blockchain
  3. The Ethereum platform
  4. Deploying your first smart contract
  5. PART 2
  6. Programming smart contracts in Solidity
  7. Writing more complex smart contracts
  8. Generalizing functionality with abstract contracts and interfaces
  9. Managing smart contracts with Web3.js
  10. PART 3
  11. The Ethereum ecosystem
  12. Unit testing contracts with Mocha
  13. Improving the development cycle with Truffle
  14. Putting it all together: Building a complete voting Dapp
  15. PART 4
  16. Making a Dapp production ready
  17. Security considerations
  18. Conclusions
39.99 In Stock
Building Ethereum DApps: Decentralized Applications on the Ethereum Blockchain

Building Ethereum DApps: Decentralized Applications on the Ethereum Blockchain

by Roberto Infante
Building Ethereum DApps: Decentralized Applications on the Ethereum Blockchain

Building Ethereum DApps: Decentralized Applications on the Ethereum Blockchain

by Roberto Infante

Paperback(1st Edition)

$39.99 
  • SHIP THIS ITEM
    In stock. Ships in 6-10 days.
  • PICK UP IN STORE

    Your local store may have stock of this item.

Related collections and offers


Overview

Summary

Building Ethereum Dapps introduces you to decentralized applications based on the Ethereum blockchain platform. In this book, you'll learn the principles of Dapps development by rolling up your sleeves and actually building a few!

Foreword by Thomas Bertani.

Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.

About the Technology

Imagine unbreakably secure applications that handle personal and business transactions without any central agency controlling the process. Decentralized applications, or Dapps, do just this, shifting power to users. The Ethereum blockchain platform provides the tools you need to build Dapps, including an innovative "smart contracts" model and Solidity, a Dapp-aware JavaScript-like programming language.

About the Book

Building Ethereum Dapps teaches Dapps development on the Ethereum blockchain platform. You'll begin with a mental model of how Dapps operate, and then dive into designing and implementing smart contracts in Ethereum's Solidity language. You'll explore Ethereum smart contract development tools, like Truffle and Web3, and pick up best practices for design and security. Practical exercises throughout give you valuable hands-on experience.

What's inside

  • Ethereum's key components
  • Implementing smart contracts in Solidity
  • Communicating with a smart contract in Web3
  • Developing Dapps with Truffle
  • Best practices for design and security improvement

About the Reader

For developers with intermediate experience in JavaScript or an OO language. Familiarity with blockchain concepts is helpful.

About the Author

Roberto Infante is a software development consultant who specializes in finance. He currently works on financial risk management systems and on blockchain technology.

Table of Contents

    PART 1
  1. A first look at decentralized applications
  2. Understanding the blockchain
  3. The Ethereum platform
  4. Deploying your first smart contract
  5. PART 2
  6. Programming smart contracts in Solidity
  7. Writing more complex smart contracts
  8. Generalizing functionality with abstract contracts and interfaces
  9. Managing smart contracts with Web3.js
  10. PART 3
  11. The Ethereum ecosystem
  12. Unit testing contracts with Mocha
  13. Improving the development cycle with Truffle
  14. Putting it all together: Building a complete voting Dapp
  15. PART 4
  16. Making a Dapp production ready
  17. Security considerations
  18. Conclusions

Product Details

ISBN-13: 9781617295157
Publisher: Manning
Publication date: 03/09/2019
Edition description: 1st Edition
Pages: 504
Product dimensions: 7.40(w) x 9.10(h) x 1.10(d)

About the Author

Roberto Infante is a software development consultant who specializes in finance. He currently works on financial risk management systems and on blockchain technology.

Table of Contents

Foreword xvii

Preface xix

Acknowledgments xx

About this book xxii

About the author xxvi

About the cover illustration xxvii

Part 1 1

1 A first look at decentralized applications 3

1.1 What is a Dapp? 4

Dapps vs. conventional centralized applications 6

Structural view: Anatomy of a Dapp 10

Transactional view: Through the lifecycle of a transaction 15

Some Dapp terminology 17

1.2 Good and bad Dapps 20

Good use cases 20

Pointless Dapps 24

1.3 A five-minute Dapp implementation 25

Building SimpleCoin, a basic cryptocurrency 25

Running the contract 28

Interacting with the contract 29

2 Understanding the blockchain 33

2.1 A deeper look at decentralized applications 34

Inside an Ethereum node 34

Revisiting the lifecycle of a transaction 35

Development view: Deploying the voting smart contract 37

2.2 What technologies make Dapps viable? 39

Blockchain technologies 39

Ethereum technologies 51

2.3 Ethereum's history and governance 56

Who created Ethereum? 56

Who controls Ethereum's development? 59

3 The Ethereum platform 62

3.1 Connecting to Ethereum through the wallet 63

Getting started with the Ethereum wallet 63

Performing common operations with the wallet 66

3.2 Smart contracts: The brain of Dapps 68

Accounts 70

Ether 70

Gas 73

Calls and transactions 75

The Ethereum Virtual Machine 76

3.3 Connecting to Ethereum with geth 76

Getting started with geth 78

A first look at the geth interactive console 79

A first look at JSON-RPC 82

Mining with the geth console 87

Other clients 89

3.4 Managing accounts with geth 90

Ethereum accounts 90

Managing accounts with the geth command 91

Managing accounts with Web3 on the geth console 93

Managing accounts with fSON-RPC 95

3.5 Revisiting SimpleCoin's contract 95

Improving SimpleCoin's contract 96

Trying out the amended code 97

How does the coin transfer execute in the Ethereum network? 100

4 A Deploying your first smart contract 103

4.1 Deploying a contract onto the network 104

Ethereum public networks 105

Deploying SimpleCoin with the Ethereum wallet 106

4.2 Interacting with the contract 110

Checking coin balances 111

Transferring coins 111

4.3 Nodeless deployment through MetaMask 114

Installing MetaMask 115

Deploying SimpleCoin through MetaMask 120

Interacting with SimpleCoin through MetaMask 123

Part 2 127

5 Programming smart contracts in Solidify 129

5.1 EVM contract languages 130

LLL 130

Serpent and Viper 131

5.2 High-level contract structure 132

Contract declarations 132

5.3 Solidity language essentials 134

Value types 135

Reference types 139

Global namespace 144

State variables 146

Functions 147

Function modifiers 155

Variable declaration, initialization, and assignment 156

Events 158

Conditional statements 159

5.4 Time to improve and refactor SimpleCoin 159

Implementing an allowance facility 160

Restricting operations only to the contract owner 161

6 Writing more complex smart contracts 166

6.1 Introducing SimpleCrowdsale, a crowdsale contract 167

State variables 169

Constructor 170

Implementing invest() 170

Implementing finalize() 171

Small detour: Introducing inheritance 172

Implementing finalize(), take 2 176

Implementing refund() 177

Eliminating code duplication with inheritance 177

Running SimpleCrowdsale 181

6.2 Extending functionality with inheritance 186

Implementing a new token pricing contract with inheritance 186

Composing functionality with multiple inheritance 190

7 Generalizing functionality with abstract contracts and interfaces 197

7.1 Making a contract abstract 198

Implementing funding limit with inheritance 198

Generalizing funding limit strategy with an abstract contract 202

Improving the token pricing strategy with an abstract contract 203

Reimplementing capped crowdsales with no duplication 204

7.2 Allowing multiple contract implementations with interfaces 208

Setting functional requirements with interfaces 208

Referencing a contract through an interface 209

7.3 Real-world crowdsale contracts 213

7.4 Recap of Solidity's object-oriented features 214

Inheritance 214

Abstract contracts 215

Interfaces 216

A word of caution 217

7.5 Libraries 217

Library function invocation 218

Deployed libraries 218

Library function execution 221

7.6 Making SimpleCoin ERC20 compliant 221

8 Managing smart contracts with Web3.js 225

8.1 Revisiting deployment through geth's interactive console 226

Contract build and deployment process 228

Deploying SimpleCoin through geth's console 229

8.2 Interacting with SimpleCoin through geth's console 233

Checking coin balances 233

Transferring coins 234

Referencing a running contract 235

8.3 Simplifying command-based deployment with Node.js 237

Installing Web3 and sole on Node.js 238

Building and deploying interactively through the Node.js console 240

Creating a build and deployment script 242

Interacting with a contract from Node.js 243

8.4 Deploying on a private network 246

How geth accesses the blockchain 246

Setting up a private test network 247

Deploying SimpleCoin on the private network 252

8.5 Making development more efficient by deploying on mock networks 254

Installing and starting up Ganache 254

Deploying SimpleCoin on Ganache 255

8.6 Smoother interaction with SimpleCoin through a web UI 257

Building a minimalistic web UI for SimpleCoin 257

Running the SimpleCoin web UI 261

Part 3 265

9 The Ethereum ecosystem 267

9.1 The core components 268

9.2 A bird's-eye view of the full ecosystem 269

9.3 Decentralized address resolution with ENS 271

ENS design 272

Registering a domain name 276

Resolving a domain name 278

9.4 Decentralized content storage 279

Swarm overview 279

Uploading and downloading content to and from Swarm 283

IPFS overview 286

Swarm vs. IPFS 290

9.5 Accessing external data through oracles 290

Feeding oracles 292

Building a data-aware contract with Oraclize 293

Running the data-aware contract 295

9.6 Dapp frameworks and IDEs 296

Development IDEs 296

Development frameworks 296

Testing frameworks 298

Web UI frameworks 298

10 Unit testing contracts with Mocha 300

10.1 Installing Mocha 301

10.2 Setting up SimpleCoin in Mocha 301

10.3 Writing unit tests for SimpleCoin 303

The testing plan 304

Unit testing the constructor 305

Testing whether only authorized callers can invoke a function 309

Testing if input constraints are met 311

Testing invocation from an authorized account with valid input 312

A little challenge 314

The full testing suite 315

11 Improving the development cycle with Truffle 318

11.1 Setting up Truffle 319

11.2 Moving SimpleCoin under Truffle 319

Setting up SimpleCoin in Truffle 319

Compiling SimpleCoin 320

Troubles with Truffle 321

Deploying SimpleCoin onto a mock network client through migrations 323

Deploying SimpleCoin onto a public test or production network 326

Testing SimpleCoin 327

Writing Solidity tests 328

Writing JavaScript tests 329

12 Putting it all together: Building a complete voting Dapp 337

12.1 Defining the requirements of a voting Dapp 338

12.2 The development plan 340

12.3 Starting the Truffle project 341

12.4 Implementing the voting contract 342

Modeling proposal, voter, and workflow 342

Contract state 343

Function modifiers 343

Events 344

Constructor 345

Functions 345

The full voting contract 348

12.5 Compiling and deploying SimpleVoting 348

12.6 Writing unit tests 349

12.7 Creating a web UI 352

Preparing the UI dependencies 352

Setting up a minimalistic web server with Node.js 354

Writing the admin page HTML 354

Writing the admin page JavaScript 358

Writing the voter page HTML 364

Writing the voter page JavaScript 364

Running the admin and voter web pages 365

Deploying to the public network 371

12.8 Food for thought 374

Possible technical improvements 374

Possible functional improvements 375

Part 4 379

13 Making a Dapp production ready 381

13.1 Event logging 382

Retrieving past events 382

Event indexing 384

13.2 Designing an upgradeable library 385

13.3 Designing an upgradeable contract 389

Connecting to the upgraded contract through a proxy 389

Inheriting from an abstract Upgradeable contract 390

14 Security considerations 392

14.1 Understanding general security weak spots 393

Private information 393

Randomness 395

Calling view functions 395

Gas limits 397

14.2 Understanding risks associated with external calls 398

Understanding external call execution types 398

What external function can you call? 400

Is an exception thrown if the external call fails? 401

Which context is the external call executed in? 403

What's the gas object received? 408

What's the gas limit? 408

14.3 How to perform external calls more safely 408

Implementing pull payments 409

Implementing a minimal fallback function 413

Beware of Ether coming to you through selfdestruct() 413

14.4 Avoiding known security attacks 414

Reentrancy 414

Cross-function race conditions 417

Front-running attacks 418

Denial of service based on revert() in fallback 420

Denial of service based on gas limits 420

14.5 General security guidelines 421

15 Conclusions 424

15.1 Evolution of Ethereum 425

Evolution of EVM 425

Evolution of Solidity 425

Evolution of Web3.js 425

Evolution of the consensus algorithm 426

Evolution of the ecosystem 429

15.2 Alternative Ethereum implementations 430

Enterprise Ethereum Alliance 430

Quorum 431

15.3 Beyond the Ethereum blockchain 432

Hyperledger 433

Corda 434

Appendix A Simple-Coin inherited from Ownable 437

Appendix B Full SimpleCrowdsale application 439

Appendix C SimpleCoin Mocha unit testing suite 445

Appendix D SimpleVoting contract 454

Index 459

From the B&N Reads Blog

Customer Reviews