Somnia — web3, net, eth (3/3)
API reference for Somnia. All methods ->
eth_getLogs
Returns an array of all logs matching a given filter object.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):-
object: the filter options:-
fromBlock(string; quantity|tag; optional; default: "latest"): either the block number or one of the following block tags:latest: for the last mined block.earliest: for the lowest numbered block available on the client.pending: for not yet mined transactions.
-
toBlock(string; quantity|tag; optional; default: "latest"): either the block number or one of the following block tags:latest: for the last mined block.earliest: for the lowest numbered block available on the client.pending: for not yet mined transactions.
-
address(array of strings; data, 20 bytes; optional): a contract address or a list of addresses from which logs should originate. -
topics(array of strings; data; optional): an array of 32 bytes data topics. Topics are order-dependent. Each topic can also be an array of data with "or" options. -
blockhash(string; data, 32 bytes; optional; future): with the addition of EIP-234,blockHashwill be a new filter option which restricts the logs returned to the single block with the 32-byte hash blockHash. Using blockHash is equivalent tofromBlock = toBlock = the blocknumber with hash blockHash. IfblockHashis present in the filter criteria, then neitherfromBlocknortoBlockare allowed.
-
-
Returns
removed(string; tag):truewhen the log was removed, due to a chain reorganization;falseif it's a valid log.logIndex(string; quantity): the log index position in the block; null when it's a pending log.transactionIndex(string; quantity): the transactions index position log was created from; null when it's a pending log.transactionHash(string; data, 32 bytes): a hash of the transactions this log was created from; null when it's a pending log.blockHash(string; data, 32 bytes): a hash of the block containing the log; null when it's pending; null when it's a pending log.blockNumber(string; quantity): the number of the block containing the log; null when it's pending; null when it's a pending log.address(string; data, 20 bytes): an address from which this log originated.data(string; data): contains one or more 32 bytes non-indexed arguments of the log.topics(array of strings; data): an 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.)
Request example
curl -X POST https://rpc.ankr.com/somnia_testnet/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "eth_getLogs",
"params": [{
"fromBlock": "0x6D4F10",
"toBlock": "0x6D4F11"
}],
"id": 1
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"address": "0xa2e9ff23495cf4f6c142fa7e109d0c17af799e2b",
"topics": [
"0xe028433ec1ff3b8c839d1a18dc250bba72715735efde55f11debeb85fa863c5a"
],
"data": "0x000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000002a30783131383538624346393563323733453539343339336461324239423333303645453832643242626600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000132000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011726573756c744465736372697074696f6e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000f84a757374206c696b65204d696e64792c20796f75277265207468652070657266656374206265737420667269656e64202d20737570706f72746976652c20656e7465727461696e696e672c20616e6420616c7761797320726561647920666f7220616e20616476656e747572652120f09f8c9f20596f75277265206e6f742061667261696420746f20636861736520796f757220647265616d732c206576656e206966206974206d65616e732074616b696e67207269736b732e20e2ad9020596f75722077697420616e6420636861726d206d616b6520796f7520746865206c696665206f662065766572792070617274792120f09f8ead0000000000000000",
"blockNumber": "0x6d4f10",
"transactionHash": "0x6f9c582354ab7ed53cb3f678e581aa60227f5e088ef69bb211992e37bd839df8",
"transactionIndex": "0x0",
"blockHash": "0x3d0aad15adb3b7a6815a8049eceb19c6fb2492d0f6c6cc9992aa33de5f8d7146",
"logIndex": "0x0"
},
{
"address": "0xa2e9ff23495cf4f6c142fa7e109d0c17af799e2b",
"topics": [
"0xe028433ec1ff3b8c839d1a18dc250bba72715735efde55f11debeb85fa863c5a"
],
"data": "0x000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000002a3078313138353862434639356332373345353934333933646132423942333330364545383264324262660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000573636f726500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000096",
"blockNumber": "0x6d4f10",
"transactionHash": "0x6f9c582354ab7ed53cb3f678e581aa60227f5e088ef69bb211992e37bd839df8",
"transactionIndex": "0x0",
"blockHash": "0x3d0aad15adb3b7a6815a8049eceb19c6fb2492d0f6c6cc9992aa33de5f8d7146",
"logIndex": "0x1"
},
{
"address": "0xa2e9ff23495cf4f6c142fa7e109d0c17af799e2b",
"topics": [
"0xe028433ec1ff3b8c839d1a18dc250bba72715735efde55f11debeb85fa863c5a"
],
"data": "0x000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000002a3078313138353862434639356332373345353934333933646132423942333330364545383264324262660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b726573756c745469746c65000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000017f09f8ea420596f75277265204d696e6479204368656e21000000000000000000",
"blockNumber": "0x6d4f10",
"transactionHash": "0x6f9c582354ab7ed53cb3f678e581aa60227f5e088ef69bb211992e37bd839df8",
"transactionIndex": "0x0",
"blockHash": "0x3d0aad15adb3b7a6815a8049eceb19c6fb2492d0f6c6cc9992aa33de5f8d7146",
"logIndex": "0x2"
}
]
}