Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Ethereum Smart Contract Development

You're reading from   Ethereum Smart Contract Development Build blockchain-based decentralized applications using solidity

Arrow left icon
Product type Paperback
Published in Feb 2018
Publisher Packt
ISBN-13 9781788473040
Length 288 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Mayukh Mukhopadhyay Mayukh Mukhopadhyay
Author Profile Icon Mayukh Mukhopadhyay
Mayukh Mukhopadhyay
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Blockchain Basics FREE CHAPTER 2. Grokking Ethereum 3. Hello World of Smart Contracts 4. A Noob's Guide to DApps and DAO 5. Deep-Diving into Smart Contracts 6. Solidity in Depth 7. Primer on Web3.js 8. Developing a Cryptocurrency from Scratch 9. Enterprise Use Cases 10. BaaS and the Dark Web Market 11. Advanced Topics and the Road Ahead 12. Other Books You May Enjoy

Running a smart contract using Web3.js


In this section, we will do a hands-on tutorial. So put on your lab coats! We will do the following right now:

  1. Install Web3.js from GitHub.
  2. Install an HTTP server and get it up and running.
  3. Write a quick-and-dirty JavaScript smart contract using Web3.js.
  4. Open geth and attach our private blockchain with Web3.js.
  5. Open a web browser to launch our smart contract using Web3.js.
  6. Open Mist to validate the outcome of our smart contract.

To install Web3.js from GitHub on Windows, we require the git bash kernel. Once we have installed the git bash kernel, we can clone the Web3.js GitHub path and download the HTTP server using the following command:

> git clone https://github.com/ethereum/web3.js.git> install -g http-server

The outcome is as follows:

Figure 7.4: Web3.js and http-server installation from GitHub

Once the HTTP server is installed, we can kick-start the server with the http-server command. To kill the server instance, we need to press Ctrl + C. Now we...

lock icon The rest of the chapter is locked
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 AU $24.99/month. Cancel anytime