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).
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
localone.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 onmainnetwithout actually talking to mainnet. Start your local node with themainnetconfiguration, point your wallet to it, and that'll make sure yourchainidand other configuration things in your wallet are correct. If that's useful.W.r.t. your real question
That can't happen. Hedera (at least currently, 2023-05) is a permissioned network. The consensus nodes that run on
testnet(ormainnet,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.