Reader small image

You're reading from  Truffle Quick Start Guide

Product typeBook
Published inJun 2018
Reading LevelIntermediate
PublisherPackt
ISBN-139781789132540
Edition1st Edition
Languages
Tools
Concepts
Right arrow
Author (1)
Nikhil Bhaskar
Nikhil Bhaskar
author image
Nikhil Bhaskar

Nikhil Bhaskar is the founder and CEO of Ulixir Inca newly founded tech company that builds decentralized and traditional software. He completed B9lab's Ethereum Developer Course, and he is now a certified Ethereum developer. Aside from running Ulixir, he spends his time traveling and eating. He is a bit of a digital nomad; this year, he's lived in five countries and plans to live in six more before the year ends.
Read more about Nikhil Bhaskar

Right arrow

Technical requirements

Truffle and Angular

Let's build a small Dapp using Truffle and Angular 4/5.

This is not meant to be a tutorial on the inner workings of Angular. If you are not familiar with Angular, I suggest you read up on it first; here is a good place to start: https://angular.io/tutorial.

Once you have a basic understanding of Angular, you are ready to begin this section.

Let's get started.

Like any good app, we need a robust and maintainable boilerplate before we start writing code. I've already set one up. Let's dive into the boilerplate.

angular-truffle-starter-dapp

Truffle and React

Let's build a small Dapp using Truffle and React.

This is not meant to be a tutorial on the inner workings of React. If you are not familiar with React, I suggest you read up on it first—here is a good place to start: https://reactjs.org/tutorial/tutorial.html.

Once you have a basic understanding of React, you are ready to begin this section.

Let's get started.

The Truffle and React starter

As usual, let's start with a starter. You can get the Truffle and React starter right here: https://github.com/truffle-box/react-box.

If you skipped the Angular chapter, you need to do the following first. Inside your truffle-practice folder, create a new folder called chapter5.

Now that you have...

Truffle and Node

If you skipped the Angular chapter, you need to do the following first:

  • Inside your truffle-practice folder, create a new folder called chapter5

Now, let's get started with Truffle and Node. First, create a new folder called truffle-node.

Inside the truffle-node folder, we need to initialize a Truffle project.

So, run the following command in your Terminal, while inside the truffle-node folder:

truffle init

Your truffle-node folder structure should now look like this:

.
├── contracts
├── migrations
├── test
├── truffle-config.js
└── truffle.js

To "run" this Truffle project, we need to have a JavaScript file to run as well as a package.json file that states our dependencies. To generate the package.json file, simply run npm init in your Terminal...

Summary

This was quite the chapter! We got our hands dirty with Angular, React, and Node. As you have seen, we did nothing new with web3 or Truffle. We simply interacted with them the way we have done before, with the only difference being that we were inside of Angular, React, and Node environments.

Being able to integrate Truffle and web3 with modern JavaScript frameworks is key to becoming a well-versed and seasoned smart contract developer. You're well on your way!

See you in the next chapter, where you will learn an essential skill that is useful not only when writing smart contracts, but production-level software in general—unit tests.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Truffle Quick Start Guide
Published in: Jun 2018Publisher: PacktISBN-13: 9781789132540
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.
undefined
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

Author (1)

author image
Nikhil Bhaskar

Nikhil Bhaskar is the founder and CEO of Ulixir Inca newly founded tech company that builds decentralized and traditional software. He completed B9lab's Ethereum Developer Course, and he is now a certified Ethereum developer. Aside from running Ulixir, he spends his time traveling and eating. He is a bit of a digital nomad; this year, he's lived in five countries and plans to live in six more before the year ends.
Read more about Nikhil Bhaskar