Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Truffle Quick Start Guide

You're reading from   Truffle Quick Start Guide Learn the fundamentals of Ethereum development

Arrow left icon
Product type Paperback
Published in Jun 2018
Publisher Packt
ISBN-13 9781789132540
Length 170 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
 Bhaskar Bhaskar
Author Profile Icon Bhaskar
Bhaskar
Arrow right icon
View More author details
Toc

What is web3?


We mentioned web3 briefly in Chapter 1, Truffle for Decentralized Applications, and we even used it without fully understanding it. The purpose of Chapter 1Truffle for Decentralized Applications, was to get a fully functional and working Dapp on a local blockchain so you could understand the power of Truffle.

Now, it's time to get more granular.

Web3 is a collection of APIs that allows JavaScript to access blockchain-based data and perform common Ethereum functions such as getting all accounts in a particular network, getting the balance of an account, or getting the particular block number.

Let's take a look at some examples:

var balance =web3.eth.getBalance("0x407d73d8a49eeb85d32cf465507dd71d507100c1");
console.log(balance); // instanceof BigNumberconsole.log(balance.toString(10)); // '1000000000000'console.log(balance.toNumber()); // 1000000000000

The web3.eth.getBalance function takes a string as an input. Particularly, this string should be a valid Ethereum address. The example...

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 £13.99/month. Cancel anytime
Visually different images