Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Mastering Blockchain

You're reading from  Mastering Blockchain

Product type Book
Published in Mar 2017
Publisher Packt
ISBN-13 9781787125445
Pages 540 pages
Edition 1st Edition
Languages
Concepts

Table of Contents (20) Chapters

Mastering Blockchain
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
1. Blockchain 101 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 $15.99/month. Cancel anytime}