curl --request POST \
--url https://fantom-mainnet.core.chainstack.com/4ab982aa70a7baead515ffdb5915df3f \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"method": "eth_newPendingTransactionFilter",
"params": [],
"id": 1
}'
{
"jsonrpc": "<string>",
"id": 123,
"result": [
"<string>"
]
}
curl --request POST \
--url https://fantom-mainnet.core.chainstack.com/4ab982aa70a7baead515ffdb5915df3f \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"method": "eth_newPendingTransactionFilter",
"params": [],
"id": 1
}'
{
"jsonrpc": "<string>",
"id": 123,
"result": [
"<string>"
]
}
eth_newBlockFilter
method is useful for developers who must be notified of new blocks on the blockchain in real-time.
none
result
— a hexadecimal string representing the ID of the newly created filtereth_newPendingTransactionFilter
code examplesweb3.eth.filter
methods have been deprecated and replaced with the web3.eth.subscribe
in web3.js. See web3.js subscriptions.const ethers = require('ethers');
const NODE_URL = "CHAINSTACK_NODE_URL";
const provider = new ethers.JsonRpcProvider(NODE_URL);
const createFilter = async () => {
try {
const filterId = await provider.send('eth_newPendingTransactionFilter', []);
console.log(filterId); // the filter ID returned by eth_newFilter
return filterId
} catch (error) {
console.log(error);
}
};
createFilter();
eth_newPendingTransactionFilter
method is to listen for new pending transactions at predefined intervals and extract specific data from them. For instance, a decentralized application might check for pending transactions every second and identify those that transfer a value greater than a certain amount of the FTM token. This could be useful for real-time monitoring high-value transactions or detecting potential fraud or security threats.The new filter ID.
The response is of type object
.
Was this page helpful?