In this lab, you will query the state of the Hedera network.
- Transport: HTTP
- Protocol: JSON-RPC
- You have already initialised this repo, and you are able to run the "smoke test" without any errors.
What you will accomplish:
- TODO_SEQUENCE_X_ACCOMPLISH
Steps:
- TODO_SEQUENCE_X_STEPS
- In the terminal, start in the root directory of this repo
cd hdc10102LabQueryRpc
code script-hdc10102LabQueryRpc.js
- Open this file and review the code within it
- Find the comment:
// (1) via Hashio endpoints
- You will see the RPC request body being constructed:
- for the
eth_getBlockByNumber
RPC - its first parameter is
latest
, which asks for the most recent block
- for the
- Next,
fetch
is used to make an HTTPPOST
request to the Hashio RPC URL - Finally, the response is displayed:
- full response (data for the entire block)
- block number (one specific field within the block)
- Find the comment:
// (2) via JSON-RPC relay running on localhost
- You will see the RPC request body being re-used
- Next,
fetch
is used to make an HTTPPOST
request to the RPC relay RPC URL- Note that this should already be running in the background on your computer or container
- Finally, the response is displayed as before
- Find the comment:
// (3) via 3rd party RPC endpoints
- The implementation here is left incomplete
- TASK: You will need to copy and adapt the implementation,
from either
(1)
or(2)
above, and such that it performs the same RPC request and displays its response. The only difference is that you must use a different RPC URL, from a 3rd party (thirdPartyRpcUrl
).