constant val - Stacks
Example code for the constant val REST method. Complete guide on how to use constant val REST method in GetBlock Web3 documentation.
Returns the value of a constant defined in a contract, as a hex-encoded Clarity value.
Endpoint
GET /v2/constant_val/{deployer_address}/{contract_name}/{constant_name}Path Parameters
deployer_address
string
The contract deployer's standard address
contract_name
string
The contract name
constant_name
string
The constant name
Example
export STACKS_RPC=https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/
curl "${STACKS_RPC}v2/constant_val/SP2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKNRV9EJ7/my-contract/ERR-NOT-AUTHORIZED"Response
{
"data": "0x080000000000000000000000000000000d"
}Response Fields
data
string
The constant's value, hex-encoded Clarity
Use Cases
Error decoding: Resolve a contract's error-code constants
Config reads: Inspect fixed parameters baked into a contract
Error Handling
400 / Bad request
Bad request
A path, query, or body parameter was invalid or the transaction was rejected
404 / Not found
Not found
The account, contract, map entry, variable, or constant does not exist
403 / RBAC: access denied
Access denied
The GetBlock access token is missing or incorrect
Was this helpful?