Let's write some JavaScript

Now, let's write some JavaScript and make use of the web3 library. Don't worry if you are not familiar with web3, you will see more of that in Chapter 2, Web3 and Solidity in Truffle. For now, you will interact with web3 just enough to get a fully working Dapp.

In app.js, paste the following code:

import { default as Web3} from 'web3';import { default as contract } from 'truffle-contract'import taskMasterArtifacts from '../../build/contracts/TaskMaster.json'

By pasting in the preceding code, you just imported the following:

  • Your CSS file, for Webpack bundling and build purposes (not important for now)
  • web3—this is to connect with Ethereum blockchains
  • truffle-contractan Ethereum contract abstraction for the browser ...

Get Truffle Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.