const Web3 = require("web3");
async function main() {
const Web3 = require('web3')
const rpcURL = '1DLT-IP-ADDRESS' // Your RPC URL goes here
const web3 = new Web3(rpcURL)
// Query the blockchain
const blockNumber = await web3.eth.getBlockNumber();
// Print the output to console
console.log(blockNumber);
}
main();
const { ethers } = require("ethers");
async function main() {
// Initialize an ethers instance
const provider = new ethers.providers.JsonRpcProvider("1DLT-IP-ADDRESS");
// Query the blockchain
const blockNumber = await provider.getBlockNumber();
// Print the output to console
console.log(blockNumber);
}
main()
curl 1DLT-IP-ADDRESS \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":0}'
#[tokio::main]
async fn main() -> web3::Result {
let transport = web3::transports::Http::new("1DLT-IP-ADDRESS")?;
let web3 = web3::Web3::new(transport);
let block = web3.eth().block_number().await?;
println!("Block number: {}", block);
Ok(())
}
{
"jsonrpc": "2.0",
"id": 0,
"result": "0x14"
}