I'm exploring what APIs are available to explore mainnet and testnet and a small task I'm trying to do is to get block height of testnet.
Docs about networks tell that there's a testnet open node: monero-testnet.exan.tech:28081
.
Looking at the basic example of monero-javascript, I see that the following code should probably be enough:
// import library
const monerojs = require("monero-javascript");
// inside an async function
const daemon = await monerojs.connectToDaemonRpc("http://localhost:38081", "superuser", "abctesting123");
const height = await daemon.getHeight();
Well, I'm not sure about login and passphrase, but I tried
const daemon = await monerojs.connectToDaemonRpc("http://monero-testnet.exan.tech:28081", "superuser", "abctesting123");
and got
TypeError: The URL must be of scheme file
(same for http://monero-testnet.exan.tech:28081/json_rpc
)
What exactly am I doing wrong? Is monero-testnet.exan.tech:28081
an endpoint for json-rpc? Are json-rpc and daemon-rpc the same? Is there a public endpoint that I can use with monerojs.connectToDaemonRpc
at all? In fact any pointer to get block height via some public API is welcome.