0

Environment Android Studio Infura – Rinkeby test network Web3J Metamask Rinkeby.etherscan.io

I am trying to build an Android app to read and write smart contract by following the medium article: Communicating with an Ethereum Smart Contract via Android https://medium.com/interfacing-with-a-blockchain/communicating-with-an-ethereum-smart-contract-via-android-24ee0dd2c115 Github: https://github.com/EbenezerGH/Greeter-Android-App.git The app is perfectly working if the author’s credential is used as follows:

val credentials = Credentials.create("f9319fe162c31947c0ca8fd649a536b7ca311b5f210afdc48b62fd7d18ce53e4")
val contractAddress = "0x8394cDf176A4A52DA5889f7a99c4f7AD2BF59088"
val url = https://rinkeby.infura.io/v3/01eb8f7b5e514832af8e827c23784d23

But when I used my credentials, it is giving the following error:

java.util.concurrent.ExecutionException: org.web3j.protocol.exceptions.ClientConnectionException: Invalid response received: okhttp3.internal.http.RealResponseBody

My credentials are:

 val credentials = Credentials.create("914e0d54701284133143769df155e9c13d16a4ae82696457444c58d7442760d5")
val contractAddress = "0x33B27EC0BE04B7ab4069F3b46Daa2d83516B4007"
val url = "https://rinkeby.infura.io/v3/ff788aca525342818fa643b0e2e99040"

To create the credentials: Goto metamask.io: Menu->Account Details->Export->Password metamask private key: 914e0d54701284133143769df155e9c13d16a4ae82696457444c58d7442760d5

Updated Experiment2: In the second experiment, I have commented out my rinkeby infura URL and used author's rinkeby URL. This time both reading and writing through smart contract worked well.


     val credentials = Credentials.create("914e0d54701284133143769df155e9c13d16a4ae82696457444c58d7442760d5")
        val contractAddress = "0x33B27EC0BE04B7ab4069F3b46Daa2d83516B4007"
//        val url = "https://rinkeby.infura.io/v3/ff788aca525342818fa643b0e2e99040"

val url = "https://rinkeby.infura.io/v3/01eb8f7b5e514832af8e827c23784d23"

I am creating rinkeby infura test network as follows: Goto: https://infura.io/dashboard/ethereum Enter project name: digitran Obtain the following: project id: ff788aca525342818fa643b0e2e99040 https://rinkeby.infura.io/v3/ff788aca525342818fa643b0e2e99040 wss://rinkeby.infura.io/ws/v3/ff788aca525342818fa643b0e2e99040

Questions

  1. Is this the right way to create rinkeby infura test network?
  2. Why reading the contract is working fine, but writing contract is not working?
  3. What is the meaning of the error “Invalid response received: okhttp3.internal.http.RealResponseBody”?
  4. How to remove this error?
  5. What settings are required in rinkeby infura test network?

The following figure shows the error in Android Studio

enter image description here

6
  • Do u have balance on your rinkeby account
    – Majd TL
    Mar 7 at 14:47
  • yes. i have balance
    – Anbunathan
    Mar 7 at 17:35
  • @Majd TL, go through experiment2. If I use author's rinkeby infura test network URL, everything is working. But if I use the URL, what I have created, then writing is not happening. So there is some issue while creating infura rinkeby test network. What are the steps involved in creating rinkeby infura test network?
    – Anbunathan
    Mar 8 at 15:24
  • hmm that is weird.. in the infura project setting, have u changed anything in the security section? if you delete the project in infura and created a new one? does the same error appear?
    – Majd TL
    Mar 8 at 16:08
  • I will check and come back
    – Anbunathan
    Mar 9 at 16:45

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.