use of org.bcos.web3j.protocol.infura.InfuraHttpService in project web3sdk by FISCO-BCOS.
the class WalletSendFunds method getEthereumClient.
private Web3j getEthereumClient() {
String clientAddress = console.readLine("Please confirm address of running Ethereum client you wish to send " + "the transfer request to [" + HttpService.DEFAULT_URL + "]: ").trim();
Web3j web3j;
if (clientAddress.equals("")) {
web3j = Web3j.build(new HttpService());
} else if (clientAddress.contains("infura.io")) {
web3j = Web3j.build(new InfuraHttpService(clientAddress));
} else {
web3j = Web3j.build(new HttpService(clientAddress));
}
try {
Web3ClientVersion web3ClientVersion = web3j.web3ClientVersion().sendAsync().get();
if (web3ClientVersion.hasError()) {
exitError("Unable to process response from client: " + web3ClientVersion.getError());
} else {
console.printf("Connected successfully to client: %s%n", web3ClientVersion.getWeb3ClientVersion());
return web3j;
}
} catch (InterruptedException | ExecutionException e) {
exitError("Problem encountered verifying client: " + e.getMessage());
}
throw new RuntimeException("Application exit failure");
}
Aggregations