For the complete documentation index, see llms.txt. This page is also available as Markdown.

contract source - Stacks

Example code for the contract source REST method. Complete guide on how to use contract source REST method in GetBlock Web3 documentation.

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

Endpoint

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

Path Parameters

Parameter
Type
Description

deployer_address

string

The contract deployer's standard address

contract_name

string

The contract name

Query Parameters

Parameter
Type
Description

proof

number

Set to 0 to omit the MARF Merkle proof

Example

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

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

Response

Response Fields

Field
Type
Description

source

string

The contract's Clarity source code

publish_height

number

Stacks block height at which the contract was published

proof

string

MARF 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

Error
Message
Description

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?