0

I'm using web3 in an android app and I'm to get the provider to be able to call the function within the web3 library to work but fails. This is the error i get
Attempt to invoke virtual method'java.lang.Stringorg.web3j.protocol.core.methods.response.Web3ClientVersion.getWeb3ClientVersion()

My Code:

    //connect to the ethereum client node
    Start_Connect();
    // show client details
    Web3ClientVersion client = null;
    try {
        client = web3j
                .web3ClientVersion()
                .sendAsync()
                .get();
    } catch (InterruptedException e) {
        e.printStackTrace();
    } catch (ExecutionException e) {
        e.printStackTrace();
    }
    Log.d(TAG, "Connected to " + client.getWeb3ClientVersion() + "\n");


        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();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.