eth_newBlockFilter - Celo
This method creates a filter to notify when new blocks arrive on the Celo network. With Celo's ~1-second block times, this filter updates rapidly.
This method creates a filter and returns a filter ID. It takes no parameters.
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_newBlockFilter",
"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_newBlockFilter',
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_newBlockFilter",
"params": []
}
response = requests.post(url, headers={"Content-Type": "application/json"}, json=payload)
print(response.json())Response Example
response.json
json{
"jsonrpc": "2.0",
"id": "getblock.io",
"result": "0x1"
}Response Definition
| Field | Type | Description |
|---|---|---|
| result | string | Filter ID |
Use Cases
- Monitor new block production
- Track network activity
- Trigger actions on new blocks
- Build block explorers
Error Handling
| Error Code | Description |
|---|---|
| -32603 | Internal error |
SDK Integration
ethers.js
javascriptconst { ethers } = require('ethers');
const provider = new ethers.JsonRpcProvider('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/');
provider.on('block', (blockNumber) => {
console.log('New block:', blockNumber);
});