Skip to content

Search

Searching the Blockchain

STRATO Cirrus Search allows end users to query their smart contracts just like a regualar database. The cirrus endpoint uses PostgREST conventions to query from the Cirrus database.

Common Queries

Listed below are some of the most common and helpful general queries

Find a Contract

We can locate all contracts with a given name by using the endpoint:

curl -X GET "https://<your_ip_address>/cirrus/search/{contractName}" -H  "accept: application/json;charset=utf-8"
The response to the query will be an array with the address of all contracts of that name and their related details. To retrieve details about a specific contract, we can query the contract using contractName but add an additional query parameter that returns only the contract with the matching address:

curl -X GET "https://<your_ip_address>/cirrus/search/cirrus/search/{contractName}?address=eq.{contractAddress}" -H  "accept: application/json;charset=utf-8"

Query Contract Terms

To perform a query on contract terms of a contract, we first need to know what variables are available in the contract. We can do that by querying the specific contract name using one of the methods we just outlined. We can then run custom queries using PostgREST conventions.

As an example, we could query for contracts named SimpleStorage and with x = to 0.

curl -X GET "http://localhost/cirrus/search/SimpleStorage?x=eq.0"

This yields the following response:

[{
  "address":"ea5e32eff6edcfa1da15a124b73c6995096799a7",
  "x":0
}]