Messages and Transactions
Every transaction in the Venom network is carried out via messages. The following section takes a closer look at messages and transactions.
When a message is sent to an account, the creation of a transaction is triggered which modifies the account's state. Such messages can include instructions for the execution of smart contracts.
There are three different types of messages in the Venom network.
- Inbound external messages: This category describes messages originating from outside the blockchain. These messages do not have a "from" address and can be sent from external services, regular users, or any of the external entities. External messages initiate changes to the blockchain's state. However, the external message can only declare its intent to transfer value.
- Internal messages: The second category describes messages sent from one account to another within the Venom blockchain. Only internal messages can be value-bearing.
- Outbound external messages: This type of message is emitted by a smart contract hosted on the Venom blockchain.
Each message in the Venom network needs to consist of a "header" and "body."
- Header: Contains all the information about the sender of the message, its recipient, and value as well as the necessary information for validators to commit the message to the blockchain.
- Body: Included in the body are the virtual machine instructions required to execute the smart contract.
A message triggers the creation of a transaction that modifies the state of an account. As such, a transaction directly results from an inbound message being processed by the receiving account code.
Inbound messages that are received by an account lead to the computation of its new state. Depending on the inbound message, it can also lead to the generation of one or more outbound messages with the receiving account as the source.
The inputs for the transaction are the inbound message and the account's previous state, while the outputs are the generated outbound message and the next state of the account.
This relation between input and output is represented as a Directed Acyclic Graph (DAG).
Each transaction is a multi-step process consisting of several different phases. The following outlines the logical steps in the process of executing a message.
If each phase is successfully completed, the transaction is executed. The transaction is not executed if an error occurs.
- Storage phase: Storage payments for the account's state are collected. (Storage phase is omitted if the transaction is sent to deploy a new smart contract).
- Computing phase: Smart contract code is invoked (inside the instance of TVM) with parameters such as inbound message and account's persistent data.
- Action phase: Actions from the list of actions are performed if the smart contract is terminated successfully.
- Bounce phase: Triggered when a transaction is aborted.