Skip to main content

Initialization of cc, cp, and gas limits

  • The original cc, current continuation, is initialized using the cell slice created from the code section of the smart contract. If the account is frozen or uninitialized, the code must be provided in the init field of the incoming message.
  • The cp, current TVM codepage, is set to the default value of 0.
  • The gas limit values are initialized based on the results of the credit phase.

Registers initialization

For more info about registers, take a look at Registers
  • c0: Quit — extraordinary continuation which terminates TVM with exit code 0.
  • c1: Quit — extraordinary continuation which terminates TVM with exit code 1. Both exit codes 0 and 1 are considered successful terminations of TVM.
  • c2: ExcQuit — extraordinary continuation which terminates TVM with an exception. In this case, the exit code is an exception number.
  • c3: root cell of code currently executing in TVM.
  • c4: root cell of account data.
  • c5: empty cell.
  • c7: Tuple[Tuple[0x076ef1ea, 0, 0, ...]].

Stack

The contents of the stack depend on the event that triggered the transaction:
  • Internal message
  • External message
  • Tick-tock
  • Split prepare
  • Merge install
  • Get method (off-chain)
The top of the stack is always the function selector, an integer that identifies the event that caused the transaction. The following function selectors are defined:
IdNameDescription
0onInternalMessageReceived an internal message
-1onExternalMessageReceived an external message
-2onRunTickTockReceived a tick-tock event
-3onSplitPrepareReceived a split prepare event (unimplemented yet)
-4onSplitInstallReceived a split install event (unimplemented yet)

External/internal message

IndexNameTypeDescription
s0Function selectorInteger-1 for external messages, 0 for internal messages.
s1Message bodySliceThis is an arbitrary payload of a message, which can be used for text comments (when sending TONs from one wallet to another) or for smart contract commands.
s2MessageCellCell containing message metadata (sender, receiver, amount) as well as message body.
s3Message valueIntegerAmount of received nanotons (0 for externals).
s4Contract balanceIntegerCurrent account balance in nanotons.

Tick‑tock

IndexNameTypeDescription
s0Function selectorInteger-2 for tick-tock transactions.
s1Tick or tock?Integer0 for tick transactions, -1 for tock transactions.
s2Account addressInteger256-bit raw account address (without workchain).
s3ContractIntegerCurrent account balance in nanotons.

Split/merge events

These events are not implemented yet. Possible stack layout for split/merge events is described in TON Blockchain whitepaper. However, it is subject to change.