Get data variable value

Get the value of a data variable inside a contract.


GET
/v2/constant_val/{contract_address}/{contract_name}/{data_var}

Get the value of a data variable inside a contract

Attempt to vetch a data var from a contract. The contract is identified with [Stacks Address] and [Contract Name] in the URL path. The variable is identified with [Var Name].

In the response, data is the hex serialization of the data variable value.

Path Parameters

contract_address
Required
string

Stacks address

contract_name
Required
string

Contract name

data_var
Required
string

Data variable name

Query Parameters

proofstring

When supplied 0, will return the JSON object without the proof field.

Status codeDescription
200Success
400Failed to retrieve data variable value from contract
/v2/data_var/{contract_address}/{contract_name}/{data_var}

Terminal
$
curl -X GET "http://localhost:20443/v2/data_var/string/string/string"

Response of get constant val request

{
"data": "string",
"proof": "string",
}