Initializing web3j

Let's now focus on the App.java file created in the Maven project

The first step is to initialize a web3j object. We do that by passing in a provider (for example, the endpoint of a third-party or local Ethereum node) to the web3j build function:

Web3j web3j = Web3j.build(new HttpService("https://ropsten.infura.io"));

In this example, we will use the Infura gateway (https://infura.io/) to access the Testnet network. If you remember, in Ethereum, we always need an entry point, which is an RPC/HTTP provider (node) that carries the orders or actions dispatched by the user to the network. Normally, the end user should have a local RPC client connected to the network. However, we directly use an online provider (used also by MetaMask) to avoid needless instructions and to keep communication with the oracle straightforward.

Remember that if you want to use a private network instead, you'll need to use the Ethereum-Bridge API (https://github.com/oraclize/ethereum-bridge) to keep using the Oraclize service.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset