eth_blockNumber
Returns the number of the most recent block.
Parameters
Section titled “Parameters”None.
Returns
Section titled “Returns”QUANTITY — Integer of the current block number the client is on.
Request
Section titled “Request”curl -X POST https://eth-mainnet.blockreq.com/v1/rpc/public \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'Response
Section titled “Response”{ "jsonrpc": "2.0", "id": 1, "result": "0x134e82a"}Code Examples
Section titled “Code Examples”JavaScript (ethers.js v6)
Section titled “JavaScript (ethers.js v6)”import { JsonRpcProvider } from "ethers";const provider = new JsonRpcProvider("https://eth-mainnet.blockreq.com/v1/rpc/YOUR_API_KEY");const blockNumber = await provider.getBlockNumber();console.log("Latest block:", blockNumber);Python (web3.py)
Section titled “Python (web3.py)”from web3 import Web3w3 = Web3(Web3.HTTPProvider("https://eth-mainnet.blockreq.com/v1/rpc/YOUR_API_KEY"))print("Latest block:", w3.eth.block_number)RU Cost
Section titled “RU Cost”| Method | Cost |
|---|---|
| eth_blockNumber | 5 RU |