9

Rather than have a local node on my PC, I'd like to be able to attach the geth cli console to INFURA and then issue requests within geth's java console, e.g. web3.eth.getBalance(<address>)

I signed up for INFURA and received an email with some endpoints to use, but I am unclear what specific commands I should use so that my geth console attaches to one of those endpoints.

Thanks

3

I'm afraid you can't connect to a remote host because geth attach works via ipc.

Try this instead:

> npm install web3
> node 
> Web3 = require("web3");
> web3 = new Web3(new Web3.providers.HttpProvider("https://mainnet.infura.io/<your access key>:8545"));
> web3.eth.blockNumber

Update

Since version 1.4 geth attach supports rpc also however it doesn't work for me:

> geth attach https://mainnet.infura.io/<my access key>:8545
Fatal: Failed to start the JavaScript console: api modules: EOF
|improve this answer|||||
  • 1
    @mesqueeb check my answer below – Samuel Dare Aug 8 '18 at 7:54
  • 1
    web3.eth.blockNumber does not work, but you can do it asynchronously: web3.eth.getBlockNumber().then(res => console.log(res)) – Lane Rettig Oct 1 '18 at 22:58
2

The main infura nodes do not support geth attach. Infura maintains legacy nodes that they use for testing that it works for .

geth attach https://gmainnet.infura.io(geth)
or
geth attach https://pmainnet.infura.io (parity)

|improve this answer|||||
  • I get this error Fatal: Failed to start the JavaScript console: api modules: invalid character 'h' in literal true (expecting 'r') – JBrouwer Sep 6 '18 at 12:30
  • 1
    I get this error: Fatal: Failed to start the JavaScript console: api modules: Post https://gmainnet.infura.io: context deadline exceeded – Lane Rettig Oct 1 '18 at 22:53

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.