---
title: Message Lifecycle
description: "Every transaction on TON Blockchain has multiple stages, where the compute and action stages are the most important for the message lifecycle."
---

There are several stages of message processing by a contract. While there are more stages, we will focus on the most important ones:

## Receive Phase

This phase combines multiple low-level phases.

It starts by adding a **message value to the contract balance**. The value of an incoming message is the maximum price that a contract can pay for gas to process this message. The contract can overwrite this limit, but it is not recommended and is suitable only for advanced developers since it could lead to a contract being drained. The maximum amount of gas that a contract can spend in a single transaction is 1 million, which currently equals 0.4 TON for basechain. If the message value is zero, execution is aborted.

Then, a (usually small) amount of nanotons gets subtracted from the contract balance for storage. This means that you cannot perfectly predict balance changes and must adjust your code to account for this instability.

Next, it deploys the contract if it has not yet been deployed and if the message contains the init package. If the init package is not present, this step is skipped.

## Compute Phase

This phase executes the code of a smart contract and produces either a list of actions or an exception. Currently, only two types of actions are supported: **send message** and **reserve**.

Sending a message could use a fixed value or a dynamic value like the **remaining value of a message**, which is the remaining value of the incoming message. A message can be sent with the flag `SendIgnoreErrors`, which causes errors during message sending to be ignored and the execution to continue to the next action. This flag is useful when you have multiple actions. When sending a message with some value, this value is first subtracted from the incoming message value and only then, if necessary, from the contract balance (before processing).

## Action Phase

Actions are executed in sequence, but bear in mind:
**AN EXCEPTION DURING THE PROCESSING OF ACTIONS WILL NOT REVERT THE TRANSACTION**

For example, if you subtract 1 TON from a customer's balance and then send an invalid message, it could lead to a situation where the customer's balance is reduced, but the customer does not receive it.
