Get constant value

Get the value of a constant inside a contract.

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

Get the value of a constant inside a contract

Attempt to fetch the value of a constant inside a contract. The contract is identified with [Stacks Address] and [Contract Name] in the URL path. The constant is identified with [Constant Name].

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

Path Parameters

contract_address
Required
string

Stacks address

contract_name
Required
string

Contract name

constant_name
Required
string

Constant name

Query Parameters

tipstring

The Stacks chain tip to query from. If tip == latest, the query will be run from the latest known tip (includes unconfirmed state).

Status codeDescription
200Success
400Failed to retrieve constant value from contract
/v2/constant_val/{contract_address}/{contract_name}/{constant_name}

curl -X POST "http://localhost:20443/v2/constant_val/string/string/string?tip=string"

Response of get constant val request

{
  "data": "string"
}