> For the complete documentation index, see [llms.txt](https://docs.stacks.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stacks.co/reference/api/stacks-blockchain-api/smart-contracts.md).

# Smart Contracts

Read-only endpoints to obtain Clarity smart contract details

## Get smart contracts status

> Retrieves the deployment status of multiple smart contracts.

```json
{"openapi":"3.0.3","info":{"title":"Stacks Blockchain API","version":"9.6.0"},"tags":[{"name":"Smart Contracts","description":"Read-only endpoints to obtain Clarity smart contract details"}],"servers":[{"url":"https://api.hiro.so/","description":"mainnet"}],"paths":{"/extended/v2/smart-contracts/status":{"get":{"operationId":"get_smart_contracts_status","summary":"Get smart contracts status","tags":["Smart Contracts"],"description":"Retrieves the deployment status of multiple smart contracts.","parameters":[{"schema":{"anyOf":[{"type":"array","items":{"pattern":"^[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{28,41}.[a-zA-Z]([a-zA-Z0-9]|[-_]){0,39}$","title":"Smart Contract ID","description":"Smart Contract ID","type":"string"}},{"pattern":"^[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{28,41}.[a-zA-Z]([a-zA-Z0-9]|[-_]){0,39}$","title":"Smart Contract ID","description":"Smart Contract ID","type":"string"}]},"in":"query","name":"contract_id","required":true}],"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"anyOf":[{"type":"object","required":["found","result"],"properties":{"found":{"type":"boolean","enum":[true]},"result":{"type":"object","required":["status","tx_id","contract_id"],"properties":{"status":{"description":"Smart contract deployment transaction status","type":"string"},"tx_id":{"description":"Deployment transaction ID","type":"string"},"contract_id":{"description":"Smart contract ID","type":"string"},"block_height":{"description":"Height of the transaction confirmation block","type":"integer"}}}}},{"type":"object","required":["found"],"properties":{"found":{"type":"boolean","enum":[false]}}}]}}}}},"4XX":{"description":"Default Response","content":{"application/json":{"schema":{"title":"Error Response","additionalProperties":true,"type":"object","required":["error"],"properties":{"error":{"type":"string"},"message":{"type":"string"}}}}}}}}}}}
```

## Get smart contract logs

> Retrieves contract log events for a given smart contract.

```json
{"openapi":"3.0.3","info":{"title":"Stacks Blockchain API","version":"9.6.0"},"tags":[{"name":"Smart Contracts","description":"Read-only endpoints to obtain Clarity smart contract details"}],"servers":[{"url":"https://api.hiro.so/","description":"mainnet"}],"paths":{"/extended/v2/smart-contracts/{contract_id}/logs":{"get":{"operationId":"get_smart_contract_logs","summary":"Get smart contract logs","tags":["Smart Contracts"],"description":"Retrieves contract log events for a given smart contract.","parameters":[{"schema":{"minimum":0,"default":20,"maximum":100,"title":"Limit","type":"integer"},"in":"query","name":"limit","required":false,"description":"Results per page"},{"schema":{"default":0,"maximum":1000,"minimum":-1000,"title":"Offset","type":"integer"},"in":"query","name":"offset","required":false,"description":"Result offset"},{"schema":{"pattern":"^[0-9]+:[0-9]+:[0-9]+:[0-9]+$","type":"string"},"in":"query","name":"cursor","required":false,"description":"Cursor for transaction event pagination (block_height:microblock_sequence:tx_index:event_index)"},{"schema":{"type":"string"},"in":"path","name":"contract_id","required":true,"description":"Contract identifier formatted as `<contract_address>.<contract_name>`"}],"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","required":["limit","offset","total","next_cursor","prev_cursor","cursor","results"],"properties":{"limit":{"type":"integer"},"offset":{"type":"integer"},"total":{"type":"integer"},"next_cursor":{"anyOf":[{"description":"Next page cursor","type":"string"},{"type":"null"}]},"prev_cursor":{"anyOf":[{"description":"Previous page cursor","type":"string"},{"type":"null"}]},"cursor":{"anyOf":[{"description":"Current page cursor","type":"string"},{"type":"null"}]},"results":{"type":"array","items":{"title":"SmartContractLogTransactionEvent","description":"Only present in `smart_contract` and `contract_call` tx types.","type":"object","allOf":[{"title":"AbstractTransactionEvent","type":"object","required":["event_index"],"properties":{"event_index":{"type":"integer"}}},{"type":"object","required":["event_type","tx_id","contract_log"],"properties":{"event_type":{"type":"string","enum":["smart_contract_log"]},"tx_id":{"type":"string"},"contract_log":{"type":"object","required":["contract_id","topic","value"],"properties":{"contract_id":{"type":"string"},"topic":{"type":"string"},"value":{"type":"object","required":["hex","repr"],"properties":{"hex":{"type":"string"},"repr":{"type":"string"}}}}}}}]}}}}}}},"4XX":{"description":"Default Response","content":{"application/json":{"schema":{"title":"Error Response","additionalProperties":true,"type":"object","required":["error"],"properties":{"error":{"type":"string"},"message":{"type":"string"}}}}}}}}}}}
```

## Get smart contract

> Retrieves a deployed smart contract, along with the transaction that deployed it. Only successfully deployed contracts are returned; a contract id whose deploy transaction failed is not found.

```json
{"openapi":"3.0.3","info":{"title":"Stacks Blockchain API","version":"9.6.0"},"tags":[{"name":"Smart Contracts","description":"Read-only endpoints to obtain Clarity smart contract details"}],"servers":[{"url":"https://api.hiro.so/","description":"mainnet"}],"paths":{"/extended/v3/smart-contracts/{contract_id}":{"get":{"operationId":"get_smart_contract","summary":"Get smart contract","tags":["Smart Contracts"],"description":"Retrieves a deployed smart contract, along with the transaction that deployed it. Only successfully deployed contracts are returned; a contract id whose deploy transaction failed is not found.","parameters":[{"schema":{"uniqueItems":true,"type":"array","items":{"type":"string","enum":["source_code"]}},"in":"query","name":"include","required":false,"description":"Heavy fields to include in the response."},{"schema":{"pattern":"^[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{28,41}.[a-zA-Z]([a-zA-Z0-9]|[-_]){0,39}$","title":"Smart Contract ID","type":"string"},"in":"path","name":"contract_id","required":true,"description":"Smart Contract ID"}],"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"title":"SmartContract","type":"object","required":["contract_id","clarity_version","tx_id","block","bitcoin_block"],"properties":{"contract_id":{"pattern":"^[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{28,41}.[a-zA-Z]([a-zA-Z0-9]|[-_]){0,39}$","title":"Smart Contract ID","description":"Smart Contract ID","type":"string"},"clarity_version":{"anyOf":[{"description":"The Clarity version the contract runs under. Contracts deployed with a versioned payload declare their own version; for the rest it is the version the node resolved from the epoch they were deployed in. Null when it could not be determined, which only happens for contracts indexed from a chainstate predating the point where the Stacks node began reporting it.","type":"integer"},{"type":"null"}]},"tx_id":{"pattern":"^(0x)?[a-fA-F0-9]{64}$","title":"Transaction ID","description":"ID of the transaction that deployed this contract","type":"string"},"block":{"type":"object","required":["height","hash","index_hash","time","time_iso","tx_index"],"properties":{"height":{"description":"Height of the block this transactions was associated with","type":"integer"},"hash":{"description":"Hash of the blocked this transactions was associated with","type":"string"},"index_hash":{"description":"Hash of the index block this transactions was associated with","type":"string"},"time":{"description":"Unix timestamp (in seconds) indicating when this block was mined.","type":"number"},"time_iso":{"description":"The `time` as an ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) UTC timestamp.","type":"string"},"tx_index":{"description":"Index of the transaction, indicating the order. Starts at `0` and increases with each transaction","type":"integer"}}},"bitcoin_block":{"type":"object","required":["height","time","time_iso"],"properties":{"height":{"description":"Height of the anchor burn block.","type":"integer"},"time":{"description":"Unix timestamp (in seconds) indicating when this block was mined.","type":"number"},"time_iso":{"description":"The `time` as an ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) UTC timestamp.","type":"string"}}},"source_code":{"description":"The Clarity source code of the contract. Only present when requested via the `include=source_code` query param.","type":"string"}}}}}},"4XX":{"description":"Default Response","content":{"application/json":{"schema":{"title":"Error Response","additionalProperties":true,"type":"object","required":["error"],"properties":{"error":{"type":"string"},"message":{"type":"string"}}}}}}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.stacks.co/reference/api/stacks-blockchain-api/smart-contracts.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
