Skip to content

Cirrus Search

STRATO Cirrus Search allows end users to query their smart contracts just like a regualar database. Endpoints use PostgREST conventions to query from the Cirrus database.

Find a Contract

We can locate contracts using the endpoint:

curl http://localhost/cirrus/search/{contractName}

Let's query Cirrus for all contracts called Escrow:

curl -X GET "http://localhost/bloc/v2.1/search/Escrow" 
  -H  "accept: application/json;charset=utf-8"

The response is an array with the address of all Escrow contracts.

[
  "ea5e32eff6edcfa1da15a124b73c6995096799a7",
  "c2fe4cd7afff347bedee9f7dd6e02403bca9710d"
]

To perform a query on this contract, we first need to know what variables are available in the contract.

curl -X GET "http://localhost/cirrus/search/Escrow" 
  -H  "accept: application/json;charset=utf-8"

Cirrus will return the contract address and the contract state variables. Here, the contract holds state variables x and address:

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

We can run custom queries using PostgREST conventions.

Don't forget the ? after /cirrus/seach/{contractName}

As an example, we will query for contracts with x = to 0.

curl -X GET 
"http://localhost/cirrus/search/SimpleStorage?x=eq.0"
[{
  "address":"ea5e32eff6edcfa1da15a124b73c6995096799a7",
  "x":0
}]