cfx_getLogs
Returns logs matching the filter provided.
- CURL
 
curl --request POST \
     --url https://main.confluxrpc.com \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "id": 1,
  "jsonrpc": "2.0",
  "params": [{}],
  "method": "cfx_getLogs"
}'
Params
filter required
Schema
type : object
address address
oneOf- RpcAddress
 - (RpcAddress,...)[]
 
type : stringPattern :^(NET\d+|CFX|CFXTEST)(:TYPE\..*|):[ABCDEFGHJKMNPRSTUVWXYZ0123456789]{42}$type : arrayitems[x]RpcAddresstype : stringPattern :^(NET\d+|CFX|CFXTEST)(:TYPE\..*|):[ABCDEFGHJKMNPRSTUVWXYZ0123456789]{42}$
blockHashes blockHashes
type : arrayitems[x]H256type : stringPattern :^0x[0-9,a-f,A-F]{64}$
fromBlock fromBlock
type : stringPattern :^0x([1-9a-f][0-9a-f]{0,15}|0)$fromEpoch fromEpoch
oneOf- U64
 - string
 
type : stringPattern :^0x([1-9a-f][0-9a-f]{0,15}|0)$type : stringPossible values :earliestlatest_checkpointlatest_finalizedlatest_confirmedlatest_statelatest_mined
toBlock toBlock
type : stringPattern :^0x([1-9a-f][0-9a-f]{0,15}|0)$toEpoch toEpoch
oneOf- U64
 - string
 
type : stringPattern :^0x([1-9a-f][0-9a-f]{0,15}|0)$type : stringPossible values :earliestlatest_checkpointlatest_finalizedlatest_confirmedlatest_statelatest_mined
topics topics
type : arrayitems[x]H256 XOR (H256,...)[]oneOf- H256
 - (H256,...)[]
 
type : stringPattern :^0x[0-9,a-f,A-F]{64}$type : arrayitems[x]H256type : stringPattern :^0x[0-9,a-f,A-F]{64}$
Result
Schema
type : array
items[x]objecttype : objectaddress address
type : stringPattern :^(NET\d+|CFX|CFXTEST)(:TYPE\..*|):[ABCDEFGHJKMNPRSTUVWXYZ0123456789]{42}$blockHash blockHash
type : stringPattern :^0x[0-9,a-f,A-F]{64}$data data
type : stringPattern :^0x[0-9a-f]*$epochNumber epochNumber
type : stringPattern :^0x([1-9a-f][0-9a-f]{0,63}|0)$logIndex logIndex
type : stringPattern :^0x([1-9a-f][0-9a-f]{0,63}|0)$space space
type : stringPossible values :nativeethereum
topics topics
type : arrayitems[x]H256type : stringPattern :^0x[0-9,a-f,A-F]{64}$
transactionHash transactionHash
type : stringPattern :^0x[0-9,a-f,A-F]{64}$transactionIndex transactionIndex
type : stringPattern :^0x([1-9a-f][0-9a-f]{0,63}|0)$transactionLogIndex transactionLogIndex
type : stringPattern :^0x([1-9a-f][0-9a-f]{0,63}|0)$
Examples
- cfx_getLogs
 - cfx_getLogs
 - cfx_getLogs
 - cfx_getLogs
 - cfx_getLogs
 - cfx_getLogs
 - cfx_getLogs
 - cfx_getLogs
 - cfx_getLogs
 
Request
curl -X POST --data \
'{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "cfx_getLogs",
    "params": [
        {}
    ]
}' \
-H "Content-Type: application/json" \
localhost:12539
Response
{
  "code": -32016,
  "message": "Error processing request: Filter error: The gap between from_epoch and to_epoch is larger than max_gap (from: 70500000, to: 70587153, max_gap: 1000)"
}
Request
curl -X POST --data \
'{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "cfx_getLogs",
    "params": [
        {
            "fromEpoch": "0x0",
            "toEpoch": "0x99"
        }
    ]
}' \
-H "Content-Type: application/json" \
localhost:12539
Response
[]
Request
curl -X POST --data \
'{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "cfx_getLogs",
    "params": [
        {
            "fromEpoch": "0x41987a1",
            "toEpoch": "0x4198b88",
            "address": [
                "CFXTEST:TYPE.CONTRACT:ACH6VR1546UJ7G81CUX357N0Z4T6MY3SNEMUZ04S6K"
            ]
        }
    ]
}' \
-H "Content-Type: application/json" \
localhost:12539
Response
[
  {
    "address": "CFXTEST:TYPE.CONTRACT:ACH6VR1546UJ7G81CUX357N0Z4T6MY3SNEMUZ04S6K",
    "blockHash": "0xabe3eb80003af0750e263140eae174d434df5b1ab0dfbebe5263d461585f590e",
    "data": "0x0000000000000000000000000000000000000000000000000000000000000064",
    "epochNumber": "0x41987a9",
    "logIndex": "0x0",
    "topics": [
      "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
      "0x0000000000000000000000001e6309dc46a2a4936abda54b69c91d7a3c75a39e",
      "0x0000000000000000000000001e6309dc46a2a4936abda54b69c91d7a3c75a39e"
    ],
    "transactionHash": "0xad1b8a95f43d903a400900e0af752bcf4b684136a125f2dcd4ac5be27e54d5f9",
    "transactionIndex": "0x0",
    "transactionLogIndex": "0x0"
  }
]
Request
curl -X POST --data \
'{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "cfx_getLogs",
    "params": [
        {
            "fromEpoch": "0x41987a1",
            "toEpoch": "0x4198b88",
            "address": [
                "CFXTEST:TYPE.CONTRACT:ACH6VR1546UJ7G81CUX357N0Z4T6MY3SNEMUZ04S6K"
            ],
            "topics": [
                "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
            ]
        }
    ]
}' \
-H "Content-Type: application/json" \
localhost:12539
Response
[
  {
    "address": "CFXTEST:TYPE.CONTRACT:ACH6VR1546UJ7G81CUX357N0Z4T6MY3SNEMUZ04S6K",
    "blockHash": "0xabe3eb80003af0750e263140eae174d434df5b1ab0dfbebe5263d461585f590e",
    "data": "0x0000000000000000000000000000000000000000000000000000000000000064",
    "epochNumber": "0x41987a9",
    "logIndex": "0x0",
    "topics": [
      "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
      "0x0000000000000000000000001e6309dc46a2a4936abda54b69c91d7a3c75a39e",
      "0x0000000000000000000000001e6309dc46a2a4936abda54b69c91d7a3c75a39e"
    ],
    "transactionHash": "0xad1b8a95f43d903a400900e0af752bcf4b684136a125f2dcd4ac5be27e54d5f9",
    "transactionIndex": "0x0",
    "transactionLogIndex": "0x0"
  }
]
Request
curl -X POST --data \
'{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "cfx_getLogs",
    "params": [
        {
            "fromEpoch": "0x41987a1",
            "toEpoch": "0x4198b88",
            "address": [
                "CFXTEST:TYPE.CONTRACT:ACH6VR1546UJ7G81CUX357N0Z4T6MY3SNEMUZ04S6K"
            ],
            "topics": [
                [
                    "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
                ]
            ]
        }
    ]
}' \
-H "Content-Type: application/json" \
localhost:12539
Response
[
  {
    "address": "CFXTEST:TYPE.CONTRACT:ACH6VR1546UJ7G81CUX357N0Z4T6MY3SNEMUZ04S6K",
    "blockHash": "0xabe3eb80003af0750e263140eae174d434df5b1ab0dfbebe5263d461585f590e",
    "data": "0x0000000000000000000000000000000000000000000000000000000000000064",
    "epochNumber": "0x41987a9",
    "logIndex": "0x0",
    "topics": [
      "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
      "0x0000000000000000000000001e6309dc46a2a4936abda54b69c91d7a3c75a39e",
      "0x0000000000000000000000001e6309dc46a2a4936abda54b69c91d7a3c75a39e"
    ],
    "transactionHash": "0xad1b8a95f43d903a400900e0af752bcf4b684136a125f2dcd4ac5be27e54d5f9",
    "transactionIndex": "0x0",
    "transactionLogIndex": "0x0"
  }
]
Request
curl -X POST --data \
'{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "cfx_getLogs",
    "params": [
        {
            "fromEpoch": "0x41987a1",
            "toEpoch": "0x4198b88",
            "address": [
                "CFXTEST:TYPE.CONTRACT:ACH6VR1546UJ7G81CUX357N0Z4T6MY3SNEMUZ04S6K"
            ],
            "topics": [
                "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
            ],
            "blockHashes": [
                "0x331dd5547ab3f30b2864535bdaf560e1db3e3cfb7bcd960f8bf10558cb9a45de",
                "0xabe3eb80003af0750e263140eae174d434df5b1ab0dfbebe5263d461585f590e"
            ]
        }
    ]
}' \
-H "Content-Type: application/json" \
localhost:12539
Response
{
  "code": -32602,
  "message": "Filter must provide one of the following: (1) an epoch range through `fromEpoch` and `toEpoch`, (2) a block number range through `fromBlock` and `toBlock`, (3) a set of block hashes through `blockHashes`"
}
Request
curl -X POST --data \
'{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "cfx_getLogs",
    "params": [
        {
            "fromEpoch": "0x41987a1",
            "toEpoch": "0x4198b88",
            "address": [
                "CFXTEST:TYPE.CONTRACT:ACH6VR1546UJ7G81CUX357N0Z4T6MY3SNEMUZ04S6K"
            ],
            "topics": [
                [
                    "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
                ]
            ],
            "blockHashes": [
                "0x331dd5547ab3f30b2864535bdaf560e1db3e3cfb7bcd960f8bf10558cb9a45de",
                "0xabe3eb80003af0750e263140eae174d434df5b1ab0dfbebe5263d461585f590e"
            ]
        }
    ]
}' \
-H "Content-Type: application/json" \
localhost:12539
Response
{
  "code": -32602,
  "message": "Filter must provide one of the following: (1) an epoch range through `fromEpoch` and `toEpoch`, (2) a block number range through `fromBlock` and `toBlock`, (3) a set of block hashes through `blockHashes`"
}
Request
curl -X POST --data \
'{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "cfx_getLogs",
    "params": [
        {
            "address": [
                "CFXTEST:TYPE.CONTRACT:ACH6VR1546UJ7G81CUX357N0Z4T6MY3SNEMUZ04S6K"
            ],
            "topics": [
                "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
            ],
            "blockHashes": [
                "0x331dd5547ab3f30b2864535bdaf560e1db3e3cfb7bcd960f8bf10558cb9a45de",
                "0xabe3eb80003af0750e263140eae174d434df5b1ab0dfbebe5263d461585f590e"
            ]
        }
    ]
}' \
-H "Content-Type: application/json" \
localhost:12539
Response
[
  {
    "address": "CFXTEST:TYPE.CONTRACT:ACH6VR1546UJ7G81CUX357N0Z4T6MY3SNEMUZ04S6K",
    "blockHash": "0xabe3eb80003af0750e263140eae174d434df5b1ab0dfbebe5263d461585f590e",
    "data": "0x0000000000000000000000000000000000000000000000000000000000000064",
    "epochNumber": "0x41987a9",
    "logIndex": "0x0",
    "topics": [
      "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
      "0x0000000000000000000000001e6309dc46a2a4936abda54b69c91d7a3c75a39e",
      "0x0000000000000000000000001e6309dc46a2a4936abda54b69c91d7a3c75a39e"
    ],
    "transactionHash": "0xad1b8a95f43d903a400900e0af752bcf4b684136a125f2dcd4ac5be27e54d5f9",
    "transactionIndex": "0x0",
    "transactionLogIndex": "0x0"
  }
]
Request
curl -X POST --data \
'{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "cfx_getLogs",
    "params": [
        {
            "address": [
                "CFXTEST:TYPE.CONTRACT:ACH6VR1546UJ7G81CUX357N0Z4T6MY3SNEMUZ04S6K"
            ],
            "topics": [
                [
                    "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
                ]
            ],
            "blockHashes": [
                "0x331dd5547ab3f30b2864535bdaf560e1db3e3cfb7bcd960f8bf10558cb9a45de",
                "0xabe3eb80003af0750e263140eae174d434df5b1ab0dfbebe5263d461585f590e"
            ]
        }
    ]
}' \
-H "Content-Type: application/json" \
localhost:12539
Response
[
  {
    "address": "CFXTEST:TYPE.CONTRACT:ACH6VR1546UJ7G81CUX357N0Z4T6MY3SNEMUZ04S6K",
    "blockHash": "0xabe3eb80003af0750e263140eae174d434df5b1ab0dfbebe5263d461585f590e",
    "data": "0x0000000000000000000000000000000000000000000000000000000000000064",
    "epochNumber": "0x41987a9",
    "logIndex": "0x0",
    "topics": [
      "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
      "0x0000000000000000000000001e6309dc46a2a4936abda54b69c91d7a3c75a39e",
      "0x0000000000000000000000001e6309dc46a2a4936abda54b69c91d7a3c75a39e"
    ],
    "transactionHash": "0xad1b8a95f43d903a400900e0af752bcf4b684136a125f2dcd4ac5be27e54d5f9",
    "transactionIndex": "0x0",
    "transactionLogIndex": "0x0"
  }
]