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 Cookbook

You're reading from   Ethereum Cookbook Over 100 recipes covering Ethereum-based tokens, games, wallets, smart contracts, protocols, and Dapps

Arrow left icon
Product type Paperback
Published in Aug 2018
Publisher Packt
ISBN-13 9781789133998
Length 404 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Manoj P R Manoj P R
Author Profile Icon Manoj P R
Manoj P R
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Getting Started 2. Smart Contract Development FREE CHAPTER 3. Interacting with the Contract 4. The Truffle Suite 5. Tokens and ICOs 6. Games and DAOs 7. Advanced Solidity 8. Smart Contract Security 9. Design Decisions 10. Other Protocols and Applications 11. Miscellaneous 12. Other Books You May Enjoy

Saving time and money with INFURA

If you don't want to set up a full node for you decentralized application, then this is the recipe for you. INFURA provides an infrastructure for Ethereum and you can make use of it for free.

How to do it...

  1. Go to the INFURA signup page (https://infura.io/signup) and enter your name and email.
  2. Once you acknowledge the terms and conditions and have signed up, you will receive an email from INFURA with the providers for each network.
  3. For each network, you will receive an endpoint and an API key:
    • Main Ethereum network: https://mainnet.infura.io/<api-key>
    • Test Ethereum network (Ropsten): https://ropsten.infura.io/<api-key>
    • Test Ethereum network (Rinkeby): https://rinkeby.infura.io/<api-key>
    • Test Ethereum network (INFURAnet): https://infuranet.infura.io/<api-key>

You can interact with the providers just like you do with your local node. You can use JSON RPC, Web3JS, or even the REST API provided by INFURA to interact with the nodes.

  1. Get the current block number with JSON RPC using cURL:

curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc": "2.0", "id": 1, "method": "eth_blockNumber", "params": []}' "https://mainnet.infura.io/<your-api-key>"

This will return the current block number, as follows:

{"jsonrpc":"2.0","id":1,"result":"0x512bab"}
  1. INFURA also provides an easy-to-use REST API interface for JSON RPC commands. You can use the JSON RPC methods as the path to get the result:

https://api.infura.io/v1/jsonrpc/mainnet/eth_blockNumber?token=<your-api-key>

  1. To use INFURA with your web3js application, you can set the endpoints as HTTP providers:
web3 = new Web3(new Web3.providers.HttpProvider ("https://mainnet.infura.io/<your_api_key>"));

There's more...

INFURA also provides support for IPFS and you can use their server as a gateway:

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