1

I'm trying to run a Hedera local node locally, and I'm following the docker set up instructions followed by these instructions to set up a localhost network, but then hoping to change the connection settings to be able to connect to Hedera Testnet, instead of my own private network.

The "network specific configuration" section of the README seems to imply that this is possible:

Network specific configurations can be applied using the -n/--network option when starting/restarting the local node. Pre-configured options are mainnet, previewnet, testnet and local

To create a custom network configuration, create a configs folder in the root of your project, then inside create <config_name>.json config file.

You can apply the configuration using the -n/--network options, e.g. hedera start --network <config_name>

... and the repo does contain configs/testnet.json.

However I'm not sure how to actually use this. How can I configure this project so that when it runs, it connects to the Hedera Testnet instead?


Details: After running docker-compose up -d, I'm able to access both the mirror node REST APIs, as well as the standard JSON-RPC endpoints:

curl http://localhost:5551/api/v1/transactions
{"transactions":[{"bytes":null,"charged_tx_fee":0,"consensus_timestamp":"1682040490.496223130","entity_id":null,"max_fee":"10000","memo_base64":"MTY4MjA0MDQ5MDQ2OSBNb25pdG9yIHBpbmdlciBvbiBiNzgwMWRkM2Y3NTI=","name":"CRYPTOTRANSFER","node":"0.0.3","nonce":0,"parent_consensus_timestamp":null,"result":"SUCCESS","scheduled":false,"staking_reward_transfers":[],"transaction_hash":"PeUl+/RYyqZx59GMkycTLVaCQ6t6QCuAAQfs02srK1qv/PxE5Gq+RBip0V+8Gvlm","transaction_id":"0.0.2-1682040481-853424739","transfers":[{"account":"0.0.2","amount":-1,"is_approval":false},{"account":"0.0.55","amount":1,"is_approval":false}],"valid_duration_seconds":"120","valid_start_timestamp":"1682040481.853424739"},{"bytes":null,"charged_tx_fee":0,"consensus_timestamp":"1682040489.495783796","entity_id":null,
...
curl \
    -H "Content-Type: application/json" \
    -X POST \
    --data '{"jsonrpc":"2.0", "method":"web3_clientVersion", "params":[], "id":1234}' \
    http://localhost:7546/
{"result":"relay/0.20.1","jsonrpc":"2.0","id":1234}
curl \
    -H "Content-Type: application/json" \
    -X POST \
    --data '{"jsonrpc":"2.0", "method":"eth_chainId", "params":[], "id":1234}' \
    http://localhost:7546/   
{"result":"0x12a","jsonrpc":"2.0","id":1234}

Note that the chain ID in the RPC response (298) does not match that of Hedera Testnet (296).

bguiz
  • 27,371
  • 47
  • 154
  • 243

1 Answers1

2

Although it is not described in the README this is not what those network configurations are useful for. Mostly the only one really useful for an individual developer is the local one.

The others are used to duplicate, in your local node on your local machine, the network conditions of the named network (e.g., testnet). So I guess that would be useful if you're developing a wallet and want to make sure it can do things on mainnet without actually talking to mainnet. Start your local node with the mainnet configuration, point your wallet to it, and that'll make sure your chainid and other configuration things in your wallet are correct. If that's useful.

W.r.t. your real question

How can I configure this project so that when it runs, it connects to the Hedera Testnet instead?

That can't happen. Hedera (at least currently, 2023-05) is a permissioned network. The consensus nodes that run on testnet (or mainnet, previewnet) are fixed (in a given release) and they all know about each other. They only talk to each other and won't talk to anyone else (for consensus; obviously anyone can talk to them to submit a transaction or query). So you can't, now, just "join" testnet.

  • That's for the consensus nodes. The output of the consensus nodes, from which you can establish the entire state of the Hedera store and keep track of its evolution as transactions happen, are record stream files which are stored in the cloud. You can set up your own mirror node to pull those files (historical, as well as in real-time as they're written) to keep track of the state of Hedera. And people have done that (including commercially.)
davidbak
  • 5,775
  • 3
  • 34
  • 50
  • Thanks - very useful - One thing I was looking for (unstated in my OP) is whether it is possible to run a Hedera node on Testnet, but disable only the consensus part of it (hashgraph)... but you've answered that as well, in that seems to be exactly what a Hedera Mirror node does! – bguiz May 17 '23 at 01:56