eth_blockNumber - Celo
This method returns the number of the most recent block on the Celo network. This is a fundamental method for tracking blockchain state, monitoring network progress, and determining transaction finality. With Celo's ~1 second block times, this value updates rapidly.
Parameters
- None
Request Example
curl
bashcurl -X POST https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "getblock.io",
"method": "eth_blockNumber",
"params": []
}'request.js
javascriptconst axios = require('axios');
const url = 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/';
const payload = {
jsonrpc: '2.0',
id: 'getblock.io',
method: 'eth_blockNumber',
params: []
};
axios.post(url, payload, {
headers: { 'Content-Type': 'application/json' }
})
.then(response => console.log(response.data))
.catch(error => console.error(error));request.py
pythonimport requests
import json
url = "https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/"
payload = {
"jsonrpc": "2.0",
"id": "getblock.io",
"method": "eth_blockNumber",
"params": []
}
response = requests.post(url, headers={"Content-Type": "application/json"}, json=payload)
print(response.json())main.rs
rustuse reqwest::Client;
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new();
let payload = json!({
"jsonrpc": "2.0",
"id": "getblock.io",
"method": "eth_blockNumber",
"params": []
});
let response = client
.post("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/")
.header("Content-Type", "application/json")
.json(&payload)
.send()
.await?;
let result: serde_json::Value = response.json().await?;
println!("{:#?}", result);
Ok(())
}Response Example
json{
"jsonrpc": "2.0",
"id": "getblock.io",
"result": "0x1d9f2a8"
}Response Parameters Definition
| Parameter | Type | Description |
|---|---|---|
| result | string | Hexadecimal block number (e.g., "0x1d9f2a8" = 31,130,280) |
Use Cases
- Monitor blockchain synchronization status
- Calculate transaction confirmations
- Track network liveness and progress
- Implement block-based polling for updates
- Determine finality for transactions
Error Handling
| Error Code | Description |
|---|---|
| -32603 | Internal error - node processing issues |
| -32000 | Server error - RPC endpoint unavailable |
SDK Integration
ethers.js
javascriptconst { ethers } = require('ethers');
const provider = new ethers.JsonRpcProvider('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/');
const blockNumber = await provider.getBlockNumber();
console.log(blockNumber);viem.js
javascriptimport { createPublicClient, http } from 'viem';
import { celo } from 'viem/chains';
const client = createPublicClient({
chain: celo,
transport: http('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/')
});
const blockNumber = await client.getBlockNumber();
console.log(blockNumber);contractkit.js
javascriptconst { newKit } = require('@celo/contractkit');
const kit = newKit('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/');
const blockNumber = await kit.web3.eth.getBlockNumber();
console.log(blockNumber);