0

I am trying to connect web3j object to the mainnet using geth. I can't use infura because i am working with replay transaction observable function which doesn't work with infura. To connect with the testnet we use port 8545, what port number should we use to connect to the mainnet. Also, is it necessary that all the blockchain should be allowed to synchronize before I start using the mainnet?

0

You can run geth with any port you like, and connect with web3j to that port. The network geth connects to is not defined by the port it exposes for rpcapi:

https://github.com/ethereum/go-ethereum/wiki/Command-Line-Options

API AND CONSOLE OPTIONS:
  --rpc                  Enable the HTTP-RPC server
  --rpcaddr value        HTTP-RPC server listening interface (default: "localhost")
  --rpcport value        HTTP-RPC server listening port (default: 8545)

so you can use the same 8545 as for mainnet or, if you like, establish your own internal convention and always run geth with another port, like 8747, when connecting to testnet.

  • Is complete synchronisation necessary before running the code? – mahamzaidi Sep 29 '18 at 13:17
  • Depends on your code. If you mean "deploy the code", then, AFAIK, syncing with at least --syncmode=fast helps to speed up the process and make it more reliable, but --syncmode=light is enough too. – Utgarda Sep 29 '18 at 13:54
  • No, i just want to use a replay transaction function which replays transaction history between 2 blocks. – mahamzaidi Sep 29 '18 at 13:55
  • I believe it's still a yes. I synced before events worked for me. Check related question: ethereum.stackexchange.com/q/29681/11501 – Utgarda Sep 29 '18 at 14:12

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.