curl --request POST \
--url https://rpc.testnet.tempo.xyz/ \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"method": "eth_getFilterLogs",
"params": [
"0x1"
],
"id": 1
}
'{
"jsonrpc": "<string>",
"id": 123,
"result": [
{}
]
}curl --request POST \
--url https://rpc.testnet.tempo.xyz/ \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"method": "eth_getFilterLogs",
"params": [
"0x1"
],
"id": 1
}
'{
"jsonrpc": "<string>",
"id": 123,
"result": [
{}
]
}eth_getFilterChanges, this returns all matching logs, not just new ones since the last poll.
filterId — the filter ID returned from eth_newFilterresult — array of log objects matching the filter:
address — contract address that emitted the logtopics — array of indexed log parametersdata — non-indexed log parametersblockNumber — block number containing the logblockHash — hash of the blocktransactionHash — hash of the transaction that emitted the logtransactionIndex — index of the transaction in the blocklogIndex — position of the log in the blockremoved — true if the log was removed due to a chain reorganizationeth_getFilterLogs code examplesconst ethers = require('ethers');
const NODE_URL = "CHAINSTACK_NODE_URL";
const provider = new ethers.JsonRpcProvider(NODE_URL);
// pathUSD token address
const PATHUSD = "0x20c0000000000000000000000000000000000000";
const TRANSFER_TOPIC = ethers.id("Transfer(address,address,uint256)");
const getFilterLogs = async () => {
// Create a log filter
const filterId = await provider.send("eth_newFilter", [{
address: PATHUSD,
topics: [TRANSFER_TOPIC],
fromBlock: "0x560000"
}]);
console.log(`Created filter: ${filterId}`);
// Get all matching logs
const logs = await provider.send("eth_getFilterLogs", [filterId]);
console.log(`Found ${logs.length} Transfer events`);
for (const log of logs.slice(0, 5)) {
console.log(`\nBlock ${parseInt(log.blockNumber, 16)}:`);
console.log(` Tx: ${log.transactionHash}`);
console.log(` From: 0x${log.topics[1].slice(26)}`);
console.log(` To: 0x${log.topics[2].slice(26)}`);
}
// Clean up
await provider.send("eth_uninstallFilter", [filterId]);
};
getFilterLogs();
Was this page helpful?