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
Mastering Blockchain

You're reading from   Mastering Blockchain Deeper insights into decentralization, cryptography, Bitcoin, and popular Blockchain frameworks

Arrow left icon
Product type Paperback
Published in Mar 2017
Publisher Packt
ISBN-13 9781787125445
Length 540 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Imran Bashir Imran Bashir
Author Profile Icon Imran Bashir
Imran Bashir
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Blockchain 101 FREE CHAPTER 2. Decentralization 3. Cryptography and Technical Foundations 4. Bitcoin 5. Alternative Coins 6. Smart Contracts 7. Ethereum 101 8. Ethereum Development 9. Hyperledger 10. Alternative Blockchains 11. Blockchain-Outside of Currencies 12. Scalability and Other Challenges 13. Current Landscape and Whats Next

Introducing Web3


Web3 is a JavaScript library that can be used to communicate with an Ethereum node via RPC communication. Web3 works by exposing methods that have been enabled over RPC. This allows the development of user interfaces that make use of the web3 library in order to interact with the contracts deployed over the blockchain.

In order to expose the methods via geth, the following command can be used:

$ geth --datadir .ethereum/privatenet/ --networkid 786 --rpc --rpcapi 'web3,eth,debug' --rpcport 8001 --rpccorsdomain 'http://localhost:7777'

Note the --rpcapi flag that allows the web3, eth and debug methods.

This is a powerful library and can be explored further by attaching a geth instance. Later in the section, you will be introduced to the concepts and techniques of making use of web3 via JavaScript/HTML frontends.

The geth instance can be attached using the following command:

$ geth attach ipc:.ethereum/privatenet/geth.ipc

Once the geth JavaScript console is running, web3 can be...

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 $19.99/month. Cancel anytime