# 后置条件

<div data-with-frame="true"><figure><img src="/files/ea510a0546d15712ff652ba4815b48b47563e75c" alt=""><figcaption></figcaption></figure></div>

{% hint style="info" %}
**构建者资源**

* 要更深入了解后置条件的使用， [这里](/post-conditions/overview.md).
* 关于 SIP-005 中概述的后置条件技术规范， [这里](https://github.com/stacksgov/sips/blob/main/sips/sip-005/sip-005-blocks-and-transactions.md#transaction-post-conditions).
  {% endhint %}

#### **全局概览**

* 后置条件是约束 *你附加到交易上的* 用于明确定义允许转移哪些资产（STX、SIP-010 代币、NFT）以及转移数量。
* 如果底层智能合约的执行会违反你声明的限制，整个交易就会中止。
* 即使某个智能合约包含意外的逻辑，它也不能转移超出你后置条件所允许范围的资产。
* 后置条件通常由客户端开发者在客户端构建。它们是已签名交易的一部分。合约无法修改它们。
* 钱包会解析已签名的交易，并在广播前向用户展示声明的后置条件。

***

### 什么是后置条件？ <a href="#what-are-post-conditions" id="what-are-post-conditions"></a>

后置条件是关于链上交易的断言，必须满足；否则，交易将在执行期间中止。换句话说，后置条件充当安全网，使你能够指定交易中可以发生哪些状态变更。

**有时，客户端开发者并不是编写底层智能合约的人，因此可能并不深入熟悉其内部逻辑、嵌套的外部合约调用或边缘情况。** 这套逻辑有助于限制因漏洞或恶意行为而可能对用户及其资产造成的损害程度。

简而言之，后置条件是一组在用户交易执行之前必须满足的条件。后置条件背后的主要目标，是限制因漏洞，无论是有意还是无意，可能对用户资产造成的损害程度。

后置条件是 Stacks 协议本身内置的一项额外安全功能，旨在帮助保护终端用户。它们不是 Clarity 智能合约的功能，而是在客户端实现，旨在作为防范恶意合约的额外保险。

当用户发起交易时，它们会作为交易的一部分发送，这意味着我们需要在前端实现后置条件。每当你将资产（同质或非同质）从一个地址转移到另一个地址时，都应该利用后置条件。

***

> ***后置条件充当安全网，使你能够指定在交易执行期间可以且应该发生哪些状态变更。***


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.stacks.co/learn/zh/transactions/post-conditions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
