Transactions
Transactions are objects that are signed by one or more accounts and are sent to the chain to interact with it.
Transactions are structured as such:
First, the transaction can import any number of types from external accounts using the import syntax.
The body is declared using the transaction
keyword and its contents are contained in curly braces.
Next is the body of the transaction, which first contains local variable declarations that are valid throughout the whole of the transaction.
Then, four optional main phases: Preparation, preconditions, execution, and postconditions, in that order. The preparation and execution phases are blocks of code that execute sequentially.
The following empty Cadence transaction contains no logic, but demonstrates the syntax for each phase, in the order these phases will be executed:
Although optional, each phase serves a specific purpose when executing a transaction and it is recommended that developers use these phases when creating their transactions. The following will detail the purpose of and how to use each phase.
Last updated