Я использую ganache-cli для помощи в подключении к узлу ethereum в приложении для Android, но всякий раз, когда я пытаюсь подключиться к узлу, приложение разрывается.
Я объявлял IP и запись в файле web3jContraints ия назвал его моим классом Login, но поскольку узел не подключен, приложение прерывается всякий раз, когда возникает необходимость вызвать функцию из библиотеки.
//connect the moible device to the ethereum client node
public void Start_Connect() {
clientUrl = argsToUrl();
web3j = Web3jFactory.build(new HttpService(clientUrl));
}
//connection port and ip
public String argsToUrl() {
String ip = web3jconstants.CLIENT_IP;
String port = web3jconstants.CLIENT_PORT;
return String.format("http://%s:%s", ip, port);
}
//get the coinbase of the ethereum wallet
public static EthCoinbase getCoinbase(Web3j web3j) throws InterruptedException, ExecutionException {
return web3j
.ethCoinbase()
.sendAsync()
.get();
}
//code for the connection web3constraint file
public class web3jconstants {
//connection port
public static final String CLIENT_IP = "127.0.0.1";//"10.97.174.70";
public static final String CLIENT_PORT = "8545";