contract source - Stacks

Returns the Clarity source code of a deployed contract, the block height at which it was published, and optionally a MARF proof.

Endpoint

httpGET /v2/contracts/source/{deployer_address}/{contract_name}

Path Parameters

ParameterTypeDescription
deployer_addressstringThe contract deployer's standard address
contract_namestringThe contract name

Query Parameters

ParameterTypeDescription
proofnumberSet to 0 to omit the MARF Merkle proof

Example

bashexport STACKS_RPC=https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/

curl "${STACKS_RPC}v2/contracts/source/SP2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKNRV9EJ7/my-contract?proof=0"

Response

json{
    "source": "(define-public (transfer (amount uint) (recipient principal))\n  (ok true))",
    "publish_height": 450120,
    "proof": "0x0c3a5b6e..."
}

Response Fields

FieldTypeDescription
sourcestringThe contract's Clarity source code
publish_heightnumberStacks block height at which the contract was published
proofstringMARF proof (empty when proof=0)

Use Cases

  • Verification: Inspect the deployed Clarity source of a contract
  • Tooling: Feed source into a Clarity analyzer or explorer

Error Handling

ErrorMessageDescription
400 / Bad requestBad requestA path, query, or body parameter was invalid or the transaction was rejected
404 / Not foundNot foundThe account, contract, map entry, variable, or constant does not exist
403 / RBAC: access deniedAccess deniedThe GetBlock access token is missing or incorrect