Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Mastering Ethereum

You're reading from  Mastering Ethereum

Product type Book
Published in Apr 2019
Publisher Packt
ISBN-13 9781789531374
Pages 490 pages
Edition 1st Edition
Languages
Concepts
Author (1):
Merunas Grincalaitis Merunas Grincalaitis
Profile icon Merunas Grincalaitis

Table of Contents (17) Chapters

Preface Section 1: Blockchain - Ethereum Refresher
Blockchain Architecture Ethereum Ecosystems Ethereum Assets Section 2: Decentralized Application Development Workflow
Mastering Smart Contracts Mastering dApps Tools, Frameworks, Components, and Services Deployment on Testnet Various dApps Integrations Decentralized Exchanges Workflow Section 3: Ethereum Implementations
Machine Learning on the Ethereum Blockchain Creating a Blockchain-based Social Media Platform Creating a Blockchain-Based E-Commerce Marketplace Other Books You May Enjoy

Various dApps Integrations

This chapter is about improving your existing dApps and smart contracts with new techniques that will make them faster, better, and more efficient. What's interesting is that most dApps can be improved with a few tricks. You'll discover new aspects of dApp development, including creating your own oracles and backends that work with smart contracts. First, you'll start by improving your React skills, and then we'll move to the backend so that you learn how to create better centralized backends for hybrid dApps that require intensive resources to work properly. After that, we'll go back to the frontend to learn how to build stronger dApps with web3.js. To cover all the areas related to your dApps, you'll build oracles with your recently acquired knowledge about servers, which are the main components to take into consideration...

Better React applications

You're familiar with the workflow that's required to create a React application. However, many aspects of newer dApps are harder to control. This includes things such as smart contract connectivity, processing data for your functions in Solidity, and creating components that scale.

Organizing components properly

When your application starts growing, you want to make sure your code base is clean enough to support new improvements without having to rewrite the entire system later on. To do so, you'll start by separating your components into different files so that you can keep your content ordered properly.

For instance, take a look at this file named index.js:

import React from &apos...

Scalable Node.js backends with NGINX

Node.js is one of the most powerful tools when it comes to creating command-line applications, servers, real-time backends, and all sorts of tools for developing web applications. The beauty of it is that Node.js is JavaScript on the server, which combines nicely with your React frontend for JavaScript everywhere. Even though it's centralized, you'll use it plenty of times for decentralized projects where you just can't get by with the limitations of the Ethereum blockchain. You see, Solidity and Vyper are severely limited: you can't do much besides basic function-based code. At some point or another, you'll have to use a centralized backend for advanced applications such as those that require a dashboard.

At least until decentralized hosting and storage solutions drastically improve, we'll have to get by with...

Better web3.js dApps

web3.js is the most used utility for communicating with smart contracts in your web applications to convert them into decentralized applications. It's capable of managing endless transactions and works automatically once set up.

The problem comes from the fact that many web3.js applications are not optimized, at least not as well as possible. Because we're dealing with smart contracts, inevitably the code gets confusing really quickly, making maintenance harder over the medium-long term. That's why it's important that you study systems to create better web3.js dApps from the start to learn tips and tricks that will make you a better programmer when it comes to interacting with smart contracts.

You'll be working with a lot of dApps using web3, so why not learn the best way of doing things to save you headaches in the long run while...

Building your own Oracles

Oracles are external applications that help your smart contract receive information from the outer world to perform some functions outside of what's possible inside Solidity or Vyper. How they work is simple: you create a centralized server that calls specific functions of your smart contract when needed.

They are used to generate random numbers, to provide live price data, and to show information from websites. As you know, smart contracts can't generate random numbers because there can't be any uncertainty regarding being able to avoid unexpected situations in the blockchain.

In this section, you'll learn how to create an Oracle to generate a random number between 1 and 100 for a game on the blockchain. There are already oracles doing these tasks, namely Oraclize, which has been used for a long time with Solidity.

...

Improving your development workflow

When it comes to creating smart contracts and decentralized applications, a common problem is that we must work in the most efficient way possible to create the highest quality code so that we don't spend unnecessary hours on fixing problems that shouldn't be there in the first place.

In my personal experience, the best applications that I've created were born from exhaustive planning beforehand. It may feel unnecessary, but the more you work, the more you realize how much time you can save by getting your ideas in place with a clear plan that describes each element of your idea.

Have you worked on projects where you're constantly getting into problems such as bugs or confusion? That's probably because you didn't do enough planning. In this section, you'll learn how to plan your applications to set up projects...

Summary

You just completed one of the most important chapters of this book, since we talked about optimization and efficiency, two things that are essential for every project you work on. We started by building better React applications, where you learned to optimize the way you create frontend applications using this powerful framework, along with interesting tips to properly structure your components.

Then you learned to create centralized Node.js applications with NGINX that you can use for hybrid projects where smart contracts are just not enough, including all the steps from idea to code to deployment on a VPS server with an HTTPS certificate. After that, you explored several web3.js improvements to create stronger frontends with subscriptions to events, helper functions, and promises that can be better controlled.

You've gone through one of the most interesting topics...

lock icon The rest of the chapter is locked
You have been reading a chapter from
Mastering Ethereum
Published in: Apr 2019 Publisher: Packt ISBN-13: 9781789531374
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}