uport-project / uport-credentials

Library for integrating uPort into node server side applications
Apache License 2.0
136 stars 46 forks source link

ethjs-provider-http error #147

Closed sandramarianegeorge closed 5 years ago

sandramarianegeorge commented 6 years ago

Hi, I am getting the following error in my Uport mobile app : new Error('[ethjs-provider-http] the HttpProvider instance requires that the host be specified (e.g. new HttpProvider("http://localhost:8545") or via service like infura new HttpProvider("http://ropsten.infura.io"))'

Can you suggest a fix for this?

aijdissanayake commented 5 years ago

@sandramarianegeorge any luck?

only1sham commented 5 years ago

Anyone from uPort looking into this issue? Even I'm getting this error. Any suggestion would be really appreciated.

leoslr commented 5 years ago

Hello, I have the same problem, does anyone have a solution ?

jasheal commented 5 years ago

Thanks you for reporting. Can you provide full steps taken to reproduce the issue?

leoslr commented 5 years ago

Hello Jason,

First of all thank you for taking the time to helping us.

For me, this error occured while doing the following :

I'm following the uPort tutorial "signing transaction example" from the uport website. https://developer.uport.me/credentials/transactions It works well.

Then I tried to do the same but calling a smart contract function instead of just transfering ethereum. In order to change the txObject content I looked up the Credentials.ts file in the uport-credentials repository. The createTxRequest function have an example concerning smart contract call ; I followed the example and used similar parameters : const txObject = { to: '0x75eDFb82F1008ebD28247AC7B3A183063Eaf2b1e', fn: "getValue(uint256 '2')", } The address is one of a smart contract that is deployed on the rinkeby blockchain. The function getValue is in this smart contract and take a uint256 as parameter. Also this specific call i.e. getValue(2) works fine when I test it on remix IDE. I've also tried to add a value field and to use slightly different syntaxes but I kept having the same error.

The whole process describe in the figure from the tutorial works well except at the 8th step : On my mobile phone i have the error discussed in this topic. On my command line tool I receive an error saying "processing_error" which seems to mean that something went wrong when trying to submit the transaction to the blockchain according to https://github.com/uport-project/specs/blob/develop/flows/tx.md

Let me know if you need more details.

ajunge commented 5 years ago

Hi @leoslr. I think you need to un-quote the 2. Since it it's a uint256.

leoslr commented 5 years ago

Hello @ajunge thank you for your answer. I already tried doing this but it didn't work.

Edit : Even with the most basic smart contract function call (a get function without any parameters for example) this error occurs.

simonas-notcat commented 5 years ago

@sandramarianegeorge @leoslr the problem here is that you are not specifying network id in the request message. There are two ways of doing that:

    const txObject = { 
      to: '0x75eDFb82F1008ebD28247AC7B3A183063Eaf2b1e', 
      net: '0x4',
      fn: 'getValue(uint256 2)', 
    }

or using MNID

    const mnid = require('mnid')
    const txObject = { 
      to: mnid.encode({
        address: '0x75eDFb82F1008ebD28247AC7B3A183063Eaf2b1e',
        network: '0x4'
      }),
      fn: 'getValue(uint256 2)', 
    }

We need to have better error handling in the app, so that we do not confuse developers.