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

Ann Kilzer
  • 380
  • 1
  • 16
user2061575
  • 153
  • 2
  • 6

2 Answers2

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
medvedev1088
  • 10,996
  • 5
  • 35
  • 63
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)

0xsegfault
  • 1,260
  • 9
  • 24
  • I get this error Fatal: Failed to start the JavaScript console: api modules: invalid character 'h' in literal true (expecting 'r') – JBrouwer Sep 06 '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 01 '18 at 22:53