I've been attempting to run a script from my terminal, and have been getting this error:

Error: CONNECTION ERROR: Couldn't connect to node https://mainnet.infura.io.

I've installed Web3j on my local machine, and unless I'm missing something, I've successfully generated a token (though it'd be great if Infura's site had some way to confirm that the digits I previously saved when doing so are correct).

So from here, I tried the the following command:

Web3j web3 = Web3j.build(new InfuraHttpService("https://morden.infura.io/your-token"));

And it's telling me:

syntax error near unexpected token `('

I'm so green that I'm unsure where the specific syntax error may be - or even if running this command was the right step to take. I swapped out "your-token" for the 20 digits I understood my token to be comprised of, to make sure that's clear.

Appreciate any help. Thanks!

  • You gave two unrelated errors. One was about connecting to mainnet.infura.io, and one was a syntax error about code that connects to a completely different domain. Could you pick one issue you want help with and then share your full code and the full error message? – user19510 Feb 23 '18 at 0:26
  • Yes, I need help connecting to the Infura mainnet, evidently, as that's the error being thrown. Here's the script: – Rachel Feb 23 '18 at 0:52
  • I ran 'npm run check-wallets' in my terminal after ssh-ing into our instance. What I believe to be the script itself is below: – Rachel Feb 23 '18 at 1:01
  • { "name": "ourthing-logic-api", "version": "1.0.0", "description": "API with business logic endpoints", "scripts": { "start": "nodemon --watch src/ --watch config/ --exec babel-node -- src/server.js", "lint": "eslint src/", "check-wallets": "babel-node bin/checkWallets.js" }, "repository": { "type": "git", "url": "git+github.com/ourthing/ourthing-logic-api.git" }, ....and then a bunch of dependencies. – Rachel Feb 23 '18 at 1:05
  • How does npm relate? That's for JavaScript code, but you're using Web3j, which is a Java library? – user19510 Feb 23 '18 at 1:07

Your Answer

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

Browse other questions tagged or ask your own question.