Before we start, you need to know the message itself is sending on
Cell data type in TON. Which means, each cell has a limit of
1023 bits for storing data. This limit includes the data stored within the cell and any necessary headers or metadata.
Suppose you have a message body that is 900 bits long, and you want to store it in a cell along with its message header. The message header itself will also take up some bits for storing its fields, such as message type, address information, and other metadata. When you try to store both the message header and the 900-bit message body in the same cell, the total number of bits required will exceed the 1023-bit limit of a single cell.
As a result, during serialization, a cell overflow exception will occur because the cell cannot accommodate more than 1023 bits of data.
To handle this situation, you need to store the message body in a separate cell, called a reference cell. In the message header, you would use a flag to indicate that the message body is stored in a reference cell. In this case, the "inplace message body flag" (which can have a value of 0 or 1) should be set to 1, indicating that the message body is not stored in the same cell as the header but in a
By storing the message body in a reference cell, you can avoid the cell overflow exception and still store the entire message (header and body) within the constraints of the TON blockchain's cell structure.