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:
Test Ethereum Network (Ropsten):

If you need some Ether on testnet to get started, please post a message with your wallet address to the web3j Gitter channel and I’ll send you some.


web3j comes with an Infura HTTP client (InfuraHttpService) so you don’t need to concern yourself with installing an HTTP certificate into your JVM. Upon startup web3j will connect to the Infura endpoint you have specified and downloads the Infura node TLS certificate to a temporary local key store which exists for the duration of your application runtime:

Web3j web3 = InfuraHttpService(""));

Alternatively, if you’d rather install the key permanently in your JVM keystore, see below.

Certificate installation

As the Infura nodes are accessed over TLS, you will need to install the relevant certificates into your Java Virtual Machine’s keystore.

You can obtain the certificate using the Firefox web browser:


Alternatively, you can use SSL (this will only download the first certificate in the chain, which should be adequate).

$ openssl s_client -connect -showcerts </dev/null 2>/dev/null|openssl x509 -outform PEM > infura-morden.pem

Once you have downloaded it, then install it into your keystore (for Windows/Linux hosts the paths will differ slightly):

$ $JAVA_HOME/Contents/Home/jre/bin/keytool -import -noprompt -trustcacerts -alias -file  ~/Downloads/ -keystore $JAVA_HOME/Contents/Home/jre/lib/security/cacerts -storepass changeit


You can now use Infura to work with the Ethereum blockchain.

Web3j web3 = HttpService(""));
Web3ClientVersion web3ClientVersion = web3.web3ClientVersion().sendAsync().get();

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.


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.