10

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

1

2 Answers 2

4

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
2
  • 1
    @mesqueeb check my answer below
    – 0xsegfault
    Commented Aug 8, 2018 at 7:54
  • 1
    web3.eth.blockNumber does not work, but you can do it asynchronously: web3.eth.getBlockNumber().then(res => console.log(res)) Commented Oct 1, 2018 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)

2
  • I get this error Fatal: Failed to start the JavaScript console: api modules: invalid character 'h' in literal true (expecting 'r')
    – JBrouwer
    Commented Sep 6, 2018 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 Commented Oct 1, 2018 at 22:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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