List Contracts Logs
Search the logs across many contracts with multiple contract calls. Chained logs are not
included but can be found by calling /api/v1/contracts/{contractId}/results/{timestamp}
or /api/v1/contracts/results/{transactionId}. When searching by topic a timestamp parameter must be supplied
and span a time range of at most seven days.
Ordering
The order is governed by the combination of timestamp and index values. If the index param is omitted, the order is determined by the timestamp only.
Note: The default order for this API is currently DESC
Filtering
When filtering there are some restrictions enforced to ensure correctness and scalability.
The table below defines the restrictions and support for the endpoint
| Query Param | Comparison Operator | Support | Description | Example |
|---|---|---|---|---|
| index | eq | Y | Single occurrence only. Requires the presence of timestamp | ?index=X |
| ne | N | |||
| lt(e) | Y | Single occurrence only. Requires the presence of timestamp | ?index=lte:X | |
| gt(e) | Y | Single occurrence only. Requires the presence of timestamp | ?index=gte:X | |
| timestamp | eq | Y | Single occurrence only. | ?timestamp=Y |
| ne | N | |||
| lt(e) | Y | Single occurrence only. Optional second timestamp gt(e) | ?timestamp=lte:Y | |
| gt(e) | Y | Single occurrence only. Optional second timestamp lt(e) | ?timestamp=gte:Y |
Both filters must be a single occurrence of gt(e) or lt(e) which provide a lower and or upper boundary for search.
curl --request GET \
--url https://{network}.hedera.validationcloud.io/v1/{API_KEY}/api/v1/contracts/results/logsimport requests
url = "https://{network}.hedera.validationcloud.io/v1/{API_KEY}/api/v1/contracts/results/logs"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://{network}.hedera.validationcloud.io/v1/{API_KEY}/api/v1/contracts/results/logs', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{network}.hedera.validationcloud.io/v1/{API_KEY}/api/v1/contracts/results/logs",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://{network}.hedera.validationcloud.io/v1/{API_KEY}/api/v1/contracts/results/logs"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://{network}.hedera.validationcloud.io/v1/{API_KEY}/api/v1/contracts/results/logs")
.asString();require 'uri'
require 'net/http'
url = URI("https://{network}.hedera.validationcloud.io/v1/{API_KEY}/api/v1/contracts/results/logs")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"logs": [
{
"address": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"bloom": "0x549358c4c2e573e02410ef7b5a5ffa5f36dd7398",
"contract_id": "0.1.2",
"data": "0x00000000000000000000000000000000000000000000000000000000000000fa",
"index": 0,
"topics": [
"0xf4757a49b326036464bec6fe419a4ae38c8a02ce3e68bf0809674f6aab8ad300"
],
"block_hash": "0x553f9311833391c0a3b2f9ed64540a89f2190a511986cd94889f1c0cf7fa63e898b1c6730f14a61755d1fb4ca05fb073",
"block_number": 10,
"root_contract_id": "0.1.2",
"timestamp": "1586567700.453054000",
"transaction_hash": "0x397022d1e5baeb89d0ab66e6bf602640610e6fb7e55d78638db861e2c6339aa9",
"transaction_index": 1
}
]
}{
"_status": {
"messages": [
{
"message": "Invalid parameter: account.id"
},
{
"message": "Invalid Transaction id. Please use \\shard.realm.num-sss-nnn\\ format where sss are seconds and nnn are nanoseconds"
}
]
}
}120 Compute Units.
Query Parameters
Contract log index
^((eq|gt|gte|lt|lte):)?\d{1,10}$The maximum number of items to return
1 <= x <= 100The order in which items are listed
asc, desc The consensus timestamp in seconds.nanoseconds format with an optional comparison operator
^((eq|gt|gte|lt|lte|ne):)?\d{1,10}(.\d{1,9})?$The first topic associated with a contract log. Requires a timestamp range also be populated.
^(0x)?[0-9A-Fa-f]{1,64}$The second topic associated with a contract log. Requires a timestamp range also be populated.
^(0x)?[0-9A-Fa-f]{1,64}$The third topic associated with a contract log. Requires a timestamp range also be populated.
^(0x)?[0-9A-Fa-f]{1,64}$The fourth topic associated with a contract log. Requires a timestamp range also be populated.
^(0x)?[0-9A-Fa-f]{1,64}$Response
OK
Show child attributes
Show child attributes
curl --request GET \
--url https://{network}.hedera.validationcloud.io/v1/{API_KEY}/api/v1/contracts/results/logsimport requests
url = "https://{network}.hedera.validationcloud.io/v1/{API_KEY}/api/v1/contracts/results/logs"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://{network}.hedera.validationcloud.io/v1/{API_KEY}/api/v1/contracts/results/logs', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{network}.hedera.validationcloud.io/v1/{API_KEY}/api/v1/contracts/results/logs",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://{network}.hedera.validationcloud.io/v1/{API_KEY}/api/v1/contracts/results/logs"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://{network}.hedera.validationcloud.io/v1/{API_KEY}/api/v1/contracts/results/logs")
.asString();require 'uri'
require 'net/http'
url = URI("https://{network}.hedera.validationcloud.io/v1/{API_KEY}/api/v1/contracts/results/logs")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"logs": [
{
"address": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"bloom": "0x549358c4c2e573e02410ef7b5a5ffa5f36dd7398",
"contract_id": "0.1.2",
"data": "0x00000000000000000000000000000000000000000000000000000000000000fa",
"index": 0,
"topics": [
"0xf4757a49b326036464bec6fe419a4ae38c8a02ce3e68bf0809674f6aab8ad300"
],
"block_hash": "0x553f9311833391c0a3b2f9ed64540a89f2190a511986cd94889f1c0cf7fa63e898b1c6730f14a61755d1fb4ca05fb073",
"block_number": 10,
"root_contract_id": "0.1.2",
"timestamp": "1586567700.453054000",
"transaction_hash": "0x397022d1e5baeb89d0ab66e6bf602640610e6fb7e55d78638db861e2c6339aa9",
"transaction_index": 1
}
]
}{
"_status": {
"messages": [
{
"message": "Invalid parameter: account.id"
},
{
"message": "Invalid Transaction id. Please use \\shard.realm.num-sss-nnn\\ format where sss are seconds and nnn are nanoseconds"
}
]
}
}