Skip to main content
FunC (specifically, the Fift assembler) reserves several function names with predefined IDs: Every program must include a function with id = 0, meaning it must define either recv_internal or main, but not both.

Receive internal

The recv_internal function is invoked when a smart contract receives an inbound internal message. Any of the following recv_internal declarations can be used.
() recv_internal(int balance, int msg_value, cell in_msg_cell, slice in_msg_body)
() recv_internal(int msg_value, cell in_msg_cell, slice in_msg_body)
() recv_internal(cell in_msg_cell, slice in_msg_body)
() recv_internal(slice in_msg_body)
() recv_internal()
Here,
  • balance is the smart contract balance in nanotons after adding the amount msg_value in the inbound message. It is an integer.
  • msg_value is the amount in nanotons included in the inbound message. It is an integer.
  • in_msg_cell is the inbound message, given as a cell.
  • in_msg_body is the inbound message body, equal to the body field in in_msg_cell. The body is given as a cell slice.

Main

main is an alias for recv_internal. If the intention of the code is to handle inbound internal messages, it is preferable to use recv_internal over main, since recv_internal states more clearly the intention of the code.

Receive external

The recv_external function handles inbound external messages. It allows declarations similar to those for recv_internal:
() recv_external(int balance, int msg_value, cell in_msg_cell, slice in_msg_body)
() recv_external(int msg_value, cell in_msg_cell, slice in_msg_body)
() recv_external(cell in_msg_cell, slice in_msg_body)
() recv_external(slice in_msg_body)
() recv_external()
The only difference is that msg_value is always 0, since external messages cannot carry coins, as they are created outside the blockchain. The behavior of the stack is identical to the behavior described for recv_internal.

Run ticktock

The run_ticktock triggers when tick and tock transactions occur. It allows the following possible declarations:
() run_ticktock(int balance, int address, int is_tock)
() run_ticktock(int address, int is_tock)
() run_ticktock(int is_tock)
() run_ticktock()
where:
  • balance is the smart contract balance in nanotons. It is an integer.
  • address is the address of the current account inside the MasterChain. It is an unsigned 256-bit integer.
  • is_tock a flag that indicates if it is a tock transaction (-1) or a tick transaction (0).
The behavior of the stack is identical to the behavior described for recv_internal.

Split prepare

The split_prepare would trigger when a split prepare transaction occurs. Even though the split_prepare name is currently reserved, split prepare transactions are currently not in use.

Split install

The split_install would trigger when a split install transaction occurs. Even though the split_install name is currently reserved, split install transactions are currently unavailable.
I