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.



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


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
  • 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

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)
geth attach https://pmainnet.infura.io (parity)

  • 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.