For the complete documentation index, see llms.txt. This page is also available as Markdown.

eth_blockNumber - Base

Example code for the eth_blockNumber JSON-RPC method. Complete guide on how to use eth_blockNumber JSON-RPC in GetBlock Web3 documentation.

The eth_blockNumber method returns the number of the most recent block on the Base blockchain. This is a fundamental method for tracking chain progress and is commonly used for synchronization, monitoring, and determining confirmation counts.

Parameters

  • None

Request

cURL
curl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "eth_blockNumber",
    "params": [],
    "id": "getblock.io"
}'
axios.js
const axios = require('axios');

const response = await axios.post('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/', {
    jsonrpc: '2.0',
    method: 'eth_blockNumber',
    params: [],
    id: 'getblock.io'
}, {
    headers: { 'Content-Type': 'application/json' }
});

console.log('Block Number:', parseInt(response.data.result, 16));
requests.py
import requests

response = requests.post(
    'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/',
    headers={'Content-Type': 'application/json'},
    json={
        'jsonrpc': '2.0',
        'method': 'eth_blockNumber',
        'params': [],
        'id': 'getblock.io'
    }
)

result = response.json()
block_number = int(result['result'], 16)
print(f'Block Number: {block_number}')

Response

response.json
{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": "0x12d687f"
}

Response Parameters

Parameter
Type
Description

jsonrpc

string

JSON-RPC protocol version ("2.0")

id

string

Request identifier matching the request

result

string

Hexadecimal representation of the current block number

Use Cases

  • Chain Synchronization: Monitor sync progress by comparing local block number with the network

  • Transaction Confirmation: Calculate confirmation count by subtracting transaction block from current block

  • Event Indexing: Determine starting point for event log queries

  • Health Monitoring: Track block production rate to detect chain issues

  • Block Polling: Implement block-based polling for new transactions or events

Error Handling

Error Code
Message
Description

-32603

Internal error

Node synchronization issue or internal failure

-32600

Invalid request

Malformed JSON-RPC request

Web3 Integration

Last updated

Was this helpful?