Using Infura with web3j

Signing up

The Infura service by ConsenSys, provides Ethereum clients running in the cloud, so you don’t have to run one yourself to work with Ethereum.

When you sign up to the service you are provided with a token you can use to connect to the relevant Ethereum network:

Main Ethereum Network:<your-token>
Test Ethereum Network (Rinkeby):<your-token>
Test Ethereum Network (Kovan):<your-token>
Test Ethereum Network (Ropsten):<your-token>

For obtaining ether to use in these networks, you can refer to Ethereum testnets


The web3j infura module provides an Infura HTTP client (InfuraHttpService) which provides support for the Infura specific Infura-Ethereum-Preferred-Client header. This allows you to specify whether you want a Geth or Parity client to respond to your request. You can create the client just like the regular HTTPClient:

Web3j web3 = HttpService("<your-token>"));
Web3ClientVersion web3ClientVersion = web3.web3ClientVersion().send();

If you want to test a number of the JSON-RPC calls against Infura, update the integration test CoreIT with your Infura URL & run it.

For further information, refer to the Infura docs.


In order to transact with Infura nodes, you will need to create and sign transactions offline before sending them, as Infura nodes have no visibility of your encrypted Ethereum key files, which are required to unlock accounts via the Personal Geth/Parity admin commands.

Refer to the Offline transaction signing and Management APIs sections for further details.