eth_newBlockFilter
Creates a filter on Astar to notify when a new block arrives.
Parameters#
This method accepts no parameters.
Request#
{
"jsonrpc": "2.0",
"method": "eth_newBlockFilter",
"params": [],
"id": 1
}
Returns#
| Type | Description |
|---|---|
QUANTITY | Filter ID |
Code Examples#
- cURL
- JavaScript
curl -X POST https://api-astar.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_newBlockFilter",
"params": [],
"id": 1
}'
import { JsonRpcProvider } from 'ethers';
const provider = new JsonRpcProvider('https://api-astar.n.dwellir.com/YOUR_API_KEY');
const filterId = await provider.send('eth_newBlockFilter', []);
// Poll for new blocks
const newBlocks = await provider.send('eth_getFilterChanges', [filterId]);
console.log('New block hashes:', newBlocks);
Related Methods#
eth_getFilterChanges- Poll filtereth_blockNumber- Get current block