blockchainassertonflow-cadence

In Cadence smart contract programming language, what distinguishes pre/post conditions from assert statements?


Pre and post-conditions are considered pure conditions, as they prohibit any state mutative operations. Similarly, assert statements also do not allow state mutative operations.

However, there remains a key distinction between the two. As a developer, it is important to understand the circumstances under which pre/post conditions are more suitable than assert statements for a given function. Are there any implications on gas, accessibility, or other factors to consider?


Solution

  • Conditions and assertions have some similarities, but also some differences: