eth_blockNumber
As a simple example, we can use TypeScript and axios (A typescript library for making API requests) to query the current block number.
Building the Script
touch index.tsimport axios from "axios";
const rpcUrl = "https://rpc.adiri.tel";
const data = {
jsonrpc: "2.0",
method: "eth_blockNumber",
params: [],
id: 1,
};
const headers = {
"Content-Type": "application/json",
};
async function fetchData() {
const response = await axios.post(rpcUrl, data, { headers });
console.log(response.data);
}
fetchData();Running the Script
Response
Last updated