eth_getLogs

Returns an array of all logs matching a given filter object.

This method will use 80 Compute Units.


Reference: Here

Parameters

  1. Object - The filter options:

  • fromBlock: QUANTITY|TAG - (optional, default: "latest") Integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions.

  • toBlock: QUANTITY|TAG - (optional, default: "latest") Integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions.

  • address: DATA|Array, 20 Bytes - (optional) Contract address or a list of addresses from which logs should originate.

  • topics: Array of DATA, - (optional) Array of 32 Bytes DATA topics. Topics are order-dependent. Each topic can also be an array of DATA with "or" options.

  • blockhash: DATA, 32 Bytes - (optional, future) With the addition of EIP-234, blockHash will be a new filter option which restricts the logs returned to the single block with the 32-byte hash blockHash. Using blockHash is equivalent to fromBlock = toBlock = the block number with hash blockHash. If blockHash is present in in the filter criteria, then neither fromBlock nor toBlock are allowed.

params: [
  {
    topics: [
      "0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b",
    ],
  },
]

Returns

See eth_getFilterChanges:

Array - Array of log objects, or an empty array if nothing has changed since last poll.

  • For filters created with eth_newBlockFilter the return are block hashes (DATA, 32 Bytes), e.g. ["0x3454645634534..."].

  • For filters created with eth_newPendingTransactionFilter the return are transaction hashes (DATA, 32 Bytes), e.g. ["0x6345343454645..."].

  • For filters created with eth_newFilter logs are objects with following params:

    • removed: TAG - true when the log was removed, due to a chain reorganization. false if its a valid log.

    • logIndex: QUANTITY - integer of the log index position in the block. null when its pending log.

    • transactionIndex: QUANTITY - integer of the transactions index position log was created from. null when its pending log.

    • transactionHash: DATA, 32 Bytes - hash of the transactions this log was created from. null when its pending log.

    • blockHash: DATA, 32 Bytes - hash of the block where this log was in. null when its pending. null when its pending log.

    • blockNumber: QUANTITY - the block number where this log was in. null when its pending. null when its pending log.

    • address: DATA, 20 Bytes - address from which this log originated.

    • data: DATA - contains one or more 32 Bytes non-indexed arguments of the log.

    • topics: Array of DATA - Array of 0 to 4 32 Bytes DATA of indexed log arguments. (In solidity: The first topic is the hash of the signature of the event (e.g. Deposit(address,bytes32,uint256)), except you declared the event with the anonymous specifier.)

// Result
{
	"jsonrpc": "2.0",
	"id": 74,
	"result": [
		{
			"address": "0x39b14c544b76ab81289a92c3e96e909f3d36daa3",
			"topics": [
				"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
				"0x0000000000000000000000000000000000000000000000000000000000000000",
				"0x000000000000000000000000f5859e60e0210312c2904aa4feea07e036a45043",
				"0x000000000000000000000000000000000000000000000000000000000394b952"
			],
			"data": "0x",
			"blockNumber": "0x869c48a",
			"transactionHash": "0xfb303b400389c4913eef3eda5af1405cb15b20758b20b8d53e9136fae660ce8a",
			"transactionIndex": "0x3",
			"blockHash": "0x7ade95363a59c4196a41407c704527aafdb561b271195a958bfabbff67a9d683",
			"logIndex": "0x4"
		},
		{
			"address": "0x715a73f6c71ab9cb32c7cc1aa95967a1b5da468d",
			"topics": [
				"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
				"0x0000000000000000000000000000000000000000000000000000000000000000",
				"0x000000000000000000000000f1654bf66d01bc507f3e52634bd950eabe0f619a",
				"0x000000000000000000000000000000000000000000000000000000000218cb1d"
			],
			"data": "0x",
			"blockNumber": "0x869c48a",
			"transactionHash": "0xe653b36cfdc06f436182dc2887239657073c1dea2c83832753b08f9326551d0d",
			"transactionIndex": "0x8",
			"blockHash": "0x7ade95363a59c4196a41407c704527aafdb561b271195a958bfabbff67a9d683",
			"logIndex": "0xd"
		},
		{
			"address": "0xbecd9b5f373877881d91cbdbaf013d97eb532154",
			"topics": [
				"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
				"0x0000000000000000000000000000000000000000000000000000000000000000",
				"0x0000000000000000000000008bb8fb70414118d34500f012a72a1b0a0a9d276d"
			],
			"data": "0x00000000000000000000000000000000000000000000003635c9adc5dea00000",
			"blockNumber": "0x869c48a",
			"transactionHash": "0x3857556df3732303fd4493e672dff95a1faca5df2f906c430d527bf6cc5c06c8",
			"transactionIndex": "0x9",
			"blockHash": "0x7ade95363a59c4196a41407c704527aafdb561b271195a958bfabbff67a9d683",
			"logIndex": "0xf"
		}
	]
}
curl https://testnet.somnia.validationcloud.io/v1/<YOUR_API_KEY_HERE> \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"jsonrpc":"2.0","method":"eth_getLogs","params":[{"topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]}],"id":74}'

Last updated

Was this helpful?