Post Phase

Statements inside of the post phase are used to verify that your transaction logic has been executed properly. It contains zero or more condition checks.

For example, the a transfer transaction might ensure that the final balance has a certain value, or e.g. it was incremented by a specific amount.

post {
    result.balance == 30: "Balance after transaction is incorrect!"
}

If any of the condition checks result in false, the transaction will fail and be completely reverted.

Only condition checks are allowed in this section. No actual computation or modification of values is allowed.

A Note about pre and post Phases

Another function of the pre and post phases is to help provide information about how the effects of a transaction on the accounts and resources involved. This is essential because users may want to verify what a transaction does before submitting it. pre and post phases provide a way to introspect transactions before they are executed.

For example, in the future the phases could be analyzed and interpreted to the user in the software they are using, e.g. "this transaction will transfer 30 tokens from A to B. The balance of A will decrease by 30 tokens and the balance of B will increase by 30 tokens."

Last updated