[TEP-140] Enhancing Smart Contract Flexibility with the Programmable Action Phase


The Programmable Action Phase proposal, identified as TEP-140, introduces a significant upgrade to the execution model of smart contracts on the TON blockchain. By extending the capabilities of the Action Phase, this proposal aims to simplify contract logic and enhance the flexibility and predictability of contract actions post-computation.


The need for the Programmable Action Phase arises from the limitations faced by smart contracts under the current TON execution model. Presently, smart contracts compose a sequence of actions during the Computation Phase, which are then executed in the Action Phase. This model, while effective, restricts the contract’s ability to adapt its behavior based on the success or failure of actions, particularly when managing TON balance for gas and message sending.

The introduction of conditional execution and logical operators within the Action Phase addresses this challenge, enabling more dynamic and efficient contract behavior and reducing the complexity of the Computation Phase.

Proposal Overview

The proposal suggests the extension of the “output actions” program, which currently functions as a sequential execution model, to include conditions and logical operators. This would transform the output actions into a richer, cycle-less program, enhancing the expressiveness and control flow of smart contract actions.

Key Enhancements

  • Logical Operators: The inclusion of operators such as AND, XOR, and TRY-CATCH within the output actions enables conditional execution paths, allowing contracts to execute different sets of actions based on the outcomes of preceding actions.
  • Conditional Execution: By utilizing these operators, contracts can implement try-catch-else behavior, branching execution based on the success or failure of actions without the need for complex Computation Phase logic.
  • TVM Level Access: New op-codes will be introduced to facilitate the manipulation of the c5 cell, enabling the assembly of complex action sequences through straightforward TVM instructions.

Technical Specifications

The proposal outlines the addition of new action types to represent the logical operators:

  • AND Operator: Executes all actions from the first list, followed by all actions from the second list, propagating exceptions if any occur.
  • XOR Operator: Executes actions from both lists but throws an exception if both executions are successful, enforcing a mutually exclusive execution path.
  • TRY-CATCH Operator: Attempts to execute actions from the “try list” and, upon failure, executes actions from the “catch list”.

These operators enhance the contract’s ability to dynamically respond to the outcomes of actions, paving the way for more resilient and adaptive smart contract designs.

Drawbacks and Considerations

While the Programmable Action Phase introduces significant advantages, it also complicates the execution model of the Action Phase and introduces challenges in analyzing and verifying the correctness of c5 cell compositions. Furthermore, the proposal acknowledges the potential difficulty in parsing and presenting these extended actions in analytical tools, such as blockchain explorers.


The Programmable Action Phase represents a pivotal development in the evolution of smart contract capabilities on the TON blockchain. By enabling conditional execution and logical operations within the Action Phase, this proposal addresses critical limitations of the current model, offering enhanced flexibility, efficiency, and simplicity in contract design. As the TON community deliberates on TEP-140, the potential for unlocking new use cases and improving contract behavior remains a compelling prospect for developers and users alike.