The contract state from a contract on the network
curl --request GET \
--url https://api.example.com/api/v1/contracts/{contractIdOrAddress}/stateimport requests
url = "https://api.example.com/api/v1/contracts/{contractIdOrAddress}/state"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/api/v1/contracts/{contractIdOrAddress}/state', 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://api.example.com/api/v1/contracts/{contractIdOrAddress}/state",
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://api.example.com/api/v1/contracts/{contractIdOrAddress}/state"
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://api.example.com/api/v1/contracts/{contractIdOrAddress}/state")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/contracts/{contractIdOrAddress}/state")
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{
"state": [
{
"address": "0000000000000000000000000000000000001f41",
"contract_id": "0.0.2",
"timestamp": "1586567700.453054000",
"slot": "0x00000000000000000000000000000000000000000000000000000000000000fa",
"value": "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925"
}
],
"links": {
"next": null
}
}{
"_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"
}
]
}
}{
"_status": {
"messages": [
{
"message": "Not found"
}
]
}
}Contracts
The contract state from a contract on the network
Returns a list of all contract’s slots. If no timestamp is provided, returns the current state.
GET
/
api
/
v1
/
contracts
/
{contractIdOrAddress}
/
state
The contract state from a contract on the network
curl --request GET \
--url https://api.example.com/api/v1/contracts/{contractIdOrAddress}/stateimport requests
url = "https://api.example.com/api/v1/contracts/{contractIdOrAddress}/state"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/api/v1/contracts/{contractIdOrAddress}/state', 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://api.example.com/api/v1/contracts/{contractIdOrAddress}/state",
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://api.example.com/api/v1/contracts/{contractIdOrAddress}/state"
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://api.example.com/api/v1/contracts/{contractIdOrAddress}/state")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/contracts/{contractIdOrAddress}/state")
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{
"state": [
{
"address": "0000000000000000000000000000000000001f41",
"contract_id": "0.0.2",
"timestamp": "1586567700.453054000",
"slot": "0x00000000000000000000000000000000000000000000000000000000000000fa",
"value": "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925"
}
],
"links": {
"next": null
}
}{
"_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"
}
]
}
}{
"_status": {
"messages": [
{
"message": "Not found"
}
]
}
}Path Parameters
The ID or hex encoded EVM address (with or without 0x prefix) associated with this contract.
Pattern:
^(\d{1,10}\.){0,2}(\d{1,10}|(0x)?[A-Fa-f0-9]{40})$Query Parameters
The maximum number of items to return
Required range:
1 <= x <= 100The order in which items are listed
Available options:
asc, desc The slot's number
Pattern:
^((eq|gte?|lte?)\:)?(0x)?[0-9A-Fa-f]{1,64}$The consensus timestamp of the contract state as a Unix timestamp in seconds.nanoseconds format with an optional comparison operator. See unixtimestamp.com for a simple way to convert a date to the 'seconds' part of the Unix time.
Pattern:
^((eq|gt|gte|lt|lte):)?\d{1,10}(\.\d{1,9})?$Was this page helpful?