Solidity

TVM Solidity (T-Sol) compiler expands the Solidity language with different API functions to facilitate TVM contract development.

Introduction

T-Sol, also known as TVM Solidity, is a powerful high-level functional programming language. It inherits the widely-used syntax of classic Solidity in EVM networks while unlocking additional functionality provided by TVM networks. T-Sol empowers developers with features such as concurrent computations, asynchronous execution, and specialized TVM primitives, expanding the capabilities beyond traditional Solidity.

Locklift

Locklift, inspired by Truffle and Hardhat, is a Node.js framework designed to facilitate the building, testing, running, and maintaining of smart contracts for TVM in the T-Sol language.

Prerequisites

  • Node.js version 22 or later

  • npm package manager

Installation

Locklift is typically utilized through a local installation in your project. This ensures reproducibility and prevents future version conflicts.

If you're starting a new project, you can simplify the process by running:

mkdir myProject
cd myProject
npx locklift init

Building the Contract

Next, if you take a look in the contracts/ folder, you'll see Sample.tsol:

Let's build the contract using the command below:

This command will use the specified TVM Solidity compiler and build all contracts in the contracts/ directory. The built files will be placed in build/.

Network Configuration

Locklift uses a configuration file named locklift.config.ts by default. The networks field allows you to specify the different networks that you'll be connecting to. Each network that you're using must be defined separately, with its own connection, giver, and keys.

Let's add the TetraChain network:

More information about working with Locklift is available at:

T-Sol

T-Sol is a TVM Solidity specification that describes language extensions over classic Solidity, TVM execution semantics, message processing rules, contract hooks, pragmas, runtime errors, and the TVM API surface such as tvm, msg, abi, math, rnd.

At a high level, Solidity is extended for TVM in these ways:

  • TVM-specific types and primitives are introduced (cells, slices, builders) with rich operations.

  • The message model is explicit: internal and external messages are distinct, and contracts must accept or reserve gas before processing.

  • Namespaces like tvm, msg, and abi provide TVM-native instructions and runtime capabilities.

  • Solidity types and constructs are expanded (quiet arithmetic, varint/varuint, extended bytes/strings, pragmas, and contract hooks).

  • TVM error codes, runtime errors, and gas optimization hints are defined.

Message Processing

TVM distinguishes internal and external messages. To start processing a message and access gas, a contract must call tvm.rawReserve() or tvm.accept().

ABI

When a T-Sol contract is built, an ABI file is generated that describes the contract interface for external calls and integrations.

TVM-Specific Primitives

Core low-level data structures are TvmCell, TvmSlice, and TvmBuilder, which represent storage cells, parsing views, and builders for serialized data in TVM.

More details here:

https://github.com/broxus/TVM-Solidity-Compiler/blob/master/API.md arrow-up-right

Last updated