diff --git a/docs/v3/documentation/smart-contracts/contracts-specs/nominator-pool.mdx b/docs/v3/documentation/smart-contracts/contracts-specs/nominator-pool.mdx
index 56c984ff25c..7731425a471 100644
--- a/docs/v3/documentation/smart-contracts/contracts-specs/nominator-pool.mdx
+++ b/docs/v3/documentation/smart-contracts/contracts-specs/nominator-pool.mdx
@@ -99,7 +99,7 @@ The pool implements weighted voting for network config proposals:
## Get methods
-### `get_pool_data`
+#### Get-method get_pool_data
Returns complete pool state information as a tuple containing:
@@ -161,7 +161,7 @@ validator_reward = (reward * validator_reward_share) / 10000
17. `config_proposal_votings` (Cell)
Raw dictionary of active proposal votes
-### `list_nominators`
+#### Get-method list_nominators
Returns an array of all nominators with their:
@@ -174,7 +174,7 @@ Returns an array of all nominators with their:
4. `withdraw_request` (int)
`-1` indicates active withdrawal request
-### `get_nominator_data`
+#### Get-method get_nominator_data
Returns detailed nominator information for the specified address.
@@ -193,16 +193,17 @@ For nominator `EQA0i8-CdGnF_DhUHHf92R1ONH6sIA9vLZ_WLcCIhfBBXwtG`:
get_nominator_data 0x348bcf827469c5fc38541c77fdd91d4e347eac200f6f2d9fd62dc08885f0415f
```
+
### Voting Methods
-#### `list_votes`
+#### Get-method list_votes
Returns all active proposals with the following:
1. `proposal_hash` (uint) - Convert with `dec_to_hex()`
2. `votes_create_time` (uint) - Unix timestamp
-#### `list_voters(proposal_hash)`
+#### Get-method list_voters
Returns voting details per proposal:
diff --git a/docs/v3/documentation/smart-contracts/contracts-specs/single-nominator-pool.md b/docs/v3/documentation/smart-contracts/contracts-specs/single-nominator-pool.md
index 0d7d161d252..6a2548b96ec 100644
--- a/docs/v3/documentation/smart-contracts/contracts-specs/single-nominator-pool.md
+++ b/docs/v3/documentation/smart-contracts/contracts-specs/single-nominator-pool.md
@@ -125,11 +125,9 @@ If you have a single nominator who holds all stakes for validation, this is the
The nominator owner can perform 4 operations:
-### 1. Withdraw
-
-This is used to withdraw funds to the owner's wallet. To withdraw the funds, the owner should send a message with a body that includes opcode=0x1000 (32 bits), query_id (64 bits), and the withdrawn amount (stored as a coin variable). The nominator contract will send the funds with the BOUNCEABLE flag and mode=64.
-
-In case the owner is using a **hot wallet** (not recommended), [withdraw-deeplink.ts](https://github.com/ton-blockchain/single-nominator/blob/main/scripts/ts/withdraw-deeplink.ts) can be used to generate a deeplink to initiate a withdrawal from tonkeeper wallet.
+#### 1. Withdraw
+Used to withdraw funds to the owner's wallet. To withdraw the funds the owner should send a message with a body that includes: opcode=0x1000 (32 bits), query_id (64 bits) and withdraw amount (stored as coin variable). The nominator contract will send the funds with BOUNCEABLE flag and mode=64.
+In case the owner is using a **hot wallet** (not recommended), [withdraw-deeplink.ts](https://github.com/ton-blockchain/single-nominator/blob/main/scripts/ts/withdraw-deeplink.ts) can be used to generate a deeplink to initiate a withdrawal from tonkeeper wallet.
Command line: `ts-node scripts/ts/withdraw-deeplink.ts single-nominator-addr withdraw-amount` where:
diff --git a/docs/v3/documentation/smart-contracts/func/cookbook.md b/docs/v3/documentation/smart-contracts/func/cookbook.md
index 34f9f1ed9a1..b8c545c850d 100644
--- a/docs/v3/documentation/smart-contracts/func/cookbook.md
+++ b/docs/v3/documentation/smart-contracts/func/cookbook.md
@@ -480,7 +480,8 @@ forall X -> (tuple) to_tuple (X x) asm "NOP";
-### How to write custom functions using the `asm` keyword
+### How to write own functions using asm keyword
+
Many features we use in FunC come from pre-prepared methods inside `stdlib.fc`. However, we have many more capabilities, and learning to write custom functions unlocks new possibilities.
diff --git a/docs/v3/documentation/smart-contracts/transaction-fees/accept-message-effects.md b/docs/v3/documentation/smart-contracts/transaction-fees/accept-message-effects.md
index e3f6e4fdbaf..0361b852684 100644
--- a/docs/v3/documentation/smart-contracts/transaction-fees/accept-message-effects.md
+++ b/docs/v3/documentation/smart-contracts/transaction-fees/accept-message-effects.md
@@ -1,30 +1,43 @@
# Accept Message Effects
-`accept_message` and `set_gas_limit` may cause not that straightforward effects when doing exactly what is said in the [stdlib reference](/v3/documentation/smart-contracts/func/docs/stdlib#accept_message).
+The `accept_message` and `set_gas_limit` TVM primitives play a crucial role in managing gas limits and transaction processing in TON smart contracts. While their basic functionality is documented in the [stdlib reference](/v3/documentation/smart-contracts/func/docs/stdlib#accept_message), their effects on transaction processing, gas limits, and contract balances can be complex and have important security implications. This page explores these effects in detail, particularly focusing on how they impact external and internal message processing.
## External messages
-External messages are processed as follows:
-- The `gas_limit` is set to `gas_credit` (ConfigParam 20 and ConfigParam 21), which is equal to 10k gas.
-- During the spending of those credits, a contract should call `accept_message` to `set_gas_limit`, indicating that it is ready to pay fees for message processing.
-- If `gas_credit` is reached or computation is finished, and `accept_message` is not called, the message will be completely discarded (as if it never existed at all).
-- Otherwise, a new gas limit, equal to `contract_balance/gas_price` (in the case of `accept_message`) or a custom number (in the case of `set_gas_limit`), will be set; after the transaction ends, full computation fees will be deducted from the contract balance (in this way, `gas_credit` is indeed **credit**, not free gas).
+External messages follow this processing flow:
+- The `gas_limit` is initially set to `gas_credit` ([Param20/Param21](v3/documentation/network/configs/blockchain-configs#param-20-and-21)), which equals 10k gas units
+- During credit spending, a contract must call `accept_message` to `set_gas_limit`, indicating its readiness to pay processing fees
+- If `gas_credit` is depleted or computation completes without `accept_message`, the message is discarded (as if it never existed)
+- Otherwise, a new gas limit is set to either:
+ - `contract_balance/gas_price` (with `accept_message`)
+ - A custom value (with `set_gas_limit`)
+- After transaction completion, full computation fees are deducted from the contract balance (making `gas_credit` truly a credit, not free gas)
-Note that if, after `accept_message`, some error is thrown (either in ComputePhase or ActionPhase), the transaction will be written to the blockchain, and fees will be deducted from the contract balance. However, storage will not be updated, and actions will not be applied, as is the case in any transaction with an error exit code.
+If an error occurs after `accept_message` (in either Compute or Action phase):
+- The transaction is recorded on the blockchain
+- Fees are deducted from the contract balance
+- Storage remains unchanged
+- Actions are not applied
-As a result, if the contract accepts an external message and then throws an exception due to an error in the message data or the sending of an incorrectly serialized message, it will pay for processing but will have no way of preventing message replay. **The same message will be accepted by the contract over and over until it consumes the entire balance.**
+**Critical Security Consideration:**
+If a contract accepts an external message and then throws an exception (due to invalid message data or serialization errors), it:
+- Pays for processing
+- Cannot prevent message replay
+- Will continue accepting the same message until its balance is depleted
+## Internal message
-
-## Internal message
-
-By default, when a contract receives an internal message, the gas limit is set to `message_balance`/`gas_price`. In other words, the message pays for its processing. By using `accept_message`/`set_gas_limit`, the contract may change the gas limit during execution.
+When a contract receives an internal message from another contract:
+- Default gas limit: `message_value`/`gas_price` (message covers its own processing)
+- The contract can modify this limit using `accept_message`/`set_gas_limit`
Note that manual settings of gas limits do not interfere with bouncing behavior; messages will be bounced if sent in bounceable mode and contain enough money to pay for their processing and the creation of bounce messages.
:::info example
-For instance, if you send a bounceable message with 0.1 TON in the basechain that is accepted by a contract with a 1 TON balance, and the computation costs 0.005 TON, with a message fee of 0.001 TON, then the bounce message will contain `0.1 - 0.005 - 0.001` = `0.094` TON.
+**Case 1:**
+If you send a bounceable message with 0.1 TON in the basechain that is accepted by a contract with a 1 TON balance, and the computation costs 0.005 TON, with a message fee of 0.001 TON, then the bounce message will contain `0.1 - 0.005 - 0.001` = `0.094` TON.
+**Case 2:**
If in the same example, the computation cost is 0.5 (instead of 0.005), there will be no bounce (the message balance would be `0.1 - 0.5 - 0.001 = -0.401`, thus no bounce), and the contract balance will be `1 + 0.1 - 0.5` = `0.6` TON.
:::
diff --git a/docs/v3/documentation/smart-contracts/transaction-fees/fees-low-level.md b/docs/v3/documentation/smart-contracts/transaction-fees/fees-low-level.md
index 76190d42548..892e8735053 100644
--- a/docs/v3/documentation/smart-contracts/transaction-fees/fees-low-level.md
+++ b/docs/v3/documentation/smart-contracts/transaction-fees/fees-low-level.md
@@ -2,10 +2,9 @@
:::caution
This section describes instructions and manuals for interacting with TON at a low level.
-
Here you will find the **raw formulas** for calculating commissions and fees on TON.
-
-However, most of them are **already implemented through opcodes**! So, you **use them instead of manual calculations**.
+However, most of them are **already implemented through opcodes**!
+So, you **use them instead of manual calculations**.
:::
This document provides a general idea of transaction fees on TON and particularly computation fees for the FunC code. There is also a [detailed specification in the TVM whitepaper](https://ton.org/tvm.pdf).
@@ -18,15 +17,14 @@ As was described in the [TVM overview](/v3/documentation/tvm/tvm-overview), tran
TON validators collect storage fees from smart contracts.
-Storage fees are collected from the smart contract `balance` at the **Storage phase** of **any** transaction due to storage payments for the account state
-(including smart-contract code and data, if present) up to the present time. Even if [contract received 1 nanoton](https://retracer.ton.org/?tx=1805820dccd7ffd70d6cee6cb581e60ee2f91f7f3eeb20ed00c08dc9fcd6a08b) it will pay all the debt since last payment. The smart contract may be frozen as a result. **Only unique hash cells are counted for storage and forward fees i.e. 3 identical hash cells are counted as one**. In particular, it [deduplicates](/v3/documentation/data-formats/tlb/library-cells) data: if there are several equivalent sub-cells referenced in different branches, their content is only stored once.
+Storage fees are collected from the smart contract `balance` at the **Storage phase** of **any** transaction due to storage payments for the account state (including smart-contract code and data, if present) up to the present time. Even if a contract receives 1 nanoton, it will pay all the debt since the last payment. The smart contract may be frozen as a result. **Only unique hash cells are counted for storage and forward fees i.e. 3 identical hash cells are counted as one**. In particular, it [deduplicates](/v3/documentation/data-formats/tlb/library-cells) data: if there are several equivalent sub-cells referenced in different branches, their content is only stored once.
-It’s important to keep in mind that on TON you pay for both the execution of a smart contract and for the **used storage** (check [@thedailyton article](https://telegra.ph/Commissions-on-TON-07-22)), `storage_fee` depends on your contract size: number of cells and sum of bits from that cells. It means you have to pay a storage fee for having TON Wallet (even if it's very-very small).
+It's important to keep in mind that on TON you pay for both the execution of a smart contract and for the **used storage** (check [@thedailyton article](https://telegra.ph/Commissions-on-TON-07-22)), `storage_fee` depends on your contract size: number of cells and sum of bits from that cells. It means you have to pay a storage fee for having TON Wallet (even if it's very-very small).
If you have not used your TON Wallet for a significant period of time (1 year), _you will have to pay a significantly larger commission than usual because the wallet pays commission on sending and receiving transactions_.
-:::info **Note**:
-When message is bounced from the contract, the contract will pay it's current `storage_fee`
+:::info **Note**:
+When a message is bounced from the contract, the contract will pay its current `storage_fee`
:::
### Formula
@@ -64,7 +62,7 @@ Current values are:
mc_cell_price_ps:500000
```
-### Calculator Example
+### Calculator example
You can use this JS script to calculate storage price for 1 MB in the workchain for 1 year
@@ -297,10 +295,10 @@ For educational purposes [example of the old one](https://explorer.toncoin.org/c
## References
-- Based on @thedailyton [article](https://telegra.ph/Fees-calculation-on-the-TON-Blockchain-07-24) from 24.07\*
+- Based on @thedailyton [article](https://telegra.ph/Fees-calculation-on-the-TON-Blockchain-07-24) from July 24th
-## See Also
+## See also
- [TON Fees overview](/v3/documentation/smart-contracts/transaction-fees/fees)
-- [Transactions and Phases](/v3/documentation/tvm/tvm-overview#transactions-and-phases)
+- [Transactions and phases](/v3/documentation/tvm/tvm-overview#transactions-and-phases)
- [Fees calculation](/v3/guidelines/smart-contracts/fee-calculation)
diff --git a/docs/v3/documentation/smart-contracts/transaction-fees/fees.md b/docs/v3/documentation/smart-contracts/transaction-fees/fees.md
index 4b19173fccb..45ef5f23b23 100644
--- a/docs/v3/documentation/smart-contracts/transaction-fees/fees.md
+++ b/docs/v3/documentation/smart-contracts/transaction-fees/fees.md
@@ -11,13 +11,13 @@ The price of gas units is determined by the [chain configuration](https://tonvie
Current settings in basechain are as follows: 1 unit of gas costs 400 nanotons.
```cpp
-1 gas = 26214400 / 2^16 nanotons = 0,000 000 4 TON
+1 gas = 26214400 / 2^16 nanotons = 0.000 000 4 TON
```
Current settings in masterchain are as follows: 1 unit of gas costs 10000 nanotons.
```cpp
-1 gas = 655360000 / 2^16 nanotons = 0,000 01 TON
+1 gas = 655360000 / 2^16 nanotons = 0.000 01 TON
```
### Average transaction cost
@@ -34,7 +34,7 @@ The current gas amount is written in the Network Config [param 20](https://tonvi
The gas fee, like many other parameters of TON, is configurable and may be changed by a special vote made in the mainnet.
-Changing any parameter requires getting 66% of the validator votes.
+Changing any parameter requires approval from 66% of the validators' votes.
#### Could gas cost more?
@@ -48,7 +48,7 @@ Validators receive a small fee for processing transactions, and charging higher
Fees on TON are difficult to calculate in advance, as their amount depends on transaction run time, account status, message content and size, blockchain network settings, and a number of other variables that cannot be calculated until the transaction is sent.
-That is why even NFT marketplaces usually take an extra amount of TON (_~1 TON_) and return (_`1 - transaction_fee`_) later.
+That is why NFT marketplaces typically require an extra amount of TON (~1 TON) and refund the remaining amount (1 - transaction_fee) after the transaction.
:::info
Each contract should check incoming messages for the amount of TON attached to ensure it is enough to cover the fees.
@@ -146,21 +146,21 @@ The average fee for minting one NFT is 0.08 TON.
### Cost of saving data in TON?
-Saving 1 MB of data for one year on TON will cost 6.01 TON. Note that you usually don’t need to store large amounts of data on-chain. Consider using [TON Storage](/v3/guidelines/web3/ton-storage/storage-daemon) if you need decentralized storage.
+Saving 1 MB of data for one year on TON will cost 6.01 TON. Note that you usually don't need to store large amounts of data on-chain. Consider using [TON Storage](/v3/guidelines/web3/ton-storage/storage-daemon) if you need decentralized storage.
### Is it possible to send a gasless transaction?
In TON, gasless transactions are possible using [wallet v5](/v3/documentation/smart-contracts/contracts-specs/wallet-contracts#preparing-for-gasless-transactions) a relayer that pays the gas fee for transaction.
-### How to calculation?
+### How to calculate fees?
There is an article about [fee calculation](/v3/guidelines/smart-contracts/fee-calculation) in TON Blockchain.
## References
-- Based on the [@thedailyton article](https://telegra.ph/Commissions-on-TON-07-22) originally written by [menschee](https://github.com/menschee)\*
+- Based on the [@thedailyton article](https://telegra.ph/Commissions-on-TON-07-22) originally written by [menschee](https://github.com/menschee)
-## See Also
+## See also
- ["Low-level fees overview"](/v3/documentation/smart-contracts/transaction-fees/fees-low-level)—read about the formulas for calculating commissions.
- [Smart contract function to calculate forward fees in FunC](https://github.com/ton-blockchain/token-contract/blob/main/misc/forward-fee-calc.fc)
diff --git a/docs/v3/documentation/smart-contracts/transaction-fees/forward-fees.md b/docs/v3/documentation/smart-contracts/transaction-fees/forward-fees.md
index 7048c5fe532..8fd36a8a931 100644
--- a/docs/v3/documentation/smart-contracts/transaction-fees/forward-fees.md
+++ b/docs/v3/documentation/smart-contracts/transaction-fees/forward-fees.md
@@ -1,13 +1,67 @@
-# Forward Fees
+# Forward fees
-In general, if a smart contract wants to send a query to another smart contract, it should pay for sending the internal message to the destination smart contract (message forwarding fees), processing this message at the destination (gas fees), and sending back the answer if required (message forwarding fees).
+This page explains how smart contracts handle message forwarding fees and value transfers between contracts.
+
+## Overview
+
+When a smart contract sends a query to another smart contract, it must pay for:
+- Sending the internal message (message forwarding fees)
+- Processing the message (gas fees)
+- Sending back the answer, if required (message forwarding fees)
+
+## Standard message handling
:::note
-In most cases, the sender will attach a small amount of Toncoin (e.g., one Toncoin) to the internal message (sufficient to pay for the processing of this message) and set its "bounce" flag (i.e., send a bounceable internal message); the receiver will return the unused portion of the received value with the answer (deducting message forwarding fees from it). This is normally accomplished by invoking `SENDRAWMSG` with `mode = 64` (cf. Appendix A of the TON VM documentation).
+In most cases, the sender:
+1. Attaches a small amount of Toncoin (typically one Toncoin) to the internal message
+2. Sets the "bounce" flag (sends a bounceable internal message)
+
+The receiver then returns the unused portion of the received value with the answer, deducting message forwarding fees. This is typically done using `SENDRAWMSG` with `mode = 64`.
:::
-If the receiver is unable to parse the received message and terminates with a non-zero exit code (for example, because of an unhandled cell deserialization exception), the message will be automatically "bounced" back to its sender, with the "bounce" flag cleared and the "bounced" flag set. The body of the bounced message will contain 32 bit `0xffffffff` followed by 256 bit from original message. It is important to check the "bounced" flag of incoming internal messages before parsing the `op` field in the smart contract and processing the corresponding query (otherwise there is a risk that the query contained in a bounced message will be processed by its original sender as a new separate query). If the "bounced" flag is set, special code could find out which query has failed (e.g., by deserializing `op` and `query_id` from the bounced message) and take appropriate action. A simpler smart contract might simply ignore all bounced messages (terminate with zero exit code if "bounced" flag is set). Note, that "bounced" flag is rewritten during sending so it can not be forged and it is safe to assume that if message came with "bounced" flag it is result of bouncing of some message sent from receiver.
+## Message bouncing
+
+### Automatic bouncing
+
+If the receiver cannot parse the received message and terminates with a non-zero exit code (for example, due to an unhandled cell deserialization exception), the message automatically bounces back to its sender. The bounced message:
+- Has its "bounce" flag cleared
+- Has its "bounced" flag set
+- Contains 32 bits `0xffffffff` followed by 256 bits from the original message
+
+### Handling bounced messages
+
+Always check the "bounced" flag of incoming internal messages before parsing the `op` field. This prevents processing a bounced message as a new query.
+
+If the "bounced" flag is set:
+- You can identify the failed query by deserializing `op` and `query_id`
+- Take appropriate action based on the failure
+- Alternatively, terminate with zero exit code to ignore bounced messages
+
+:::note
+The "bounced" flag cannot be forged because it's rewritten during sending. If a message has the "bounced" flag set, it's definitely a result of a bounced message from the receiver.
+:::
+
+## Error handling
+
+If the receiver successfully parses the incoming query but:
+- The requested method `op` is not supported
+- Another error condition is met
+
+Send a response with `op` equal to `0xffffffff` or another appropriate value using `SENDRAWMSG` with `mode = 64`.
+
+## Value transfer with confirmation
+
+Some operations require both value transfer and confirmation. For example, the validator elections smart contract receives:
+- An election participation request
+- The stake as the attached value
-On the other hand, the receiver might parse the incoming query successfully and find out that the requested method `op` is not supported, or that another error condition is met. Then a response with `op` equal to `0xffffffff` or another appropriate value should be sent back, using `SENDRAWMSG` with `mode = 64` as mentioned above.
+### Implementation
-In some situations, the sender wants both to transfer some value to the sender and to receive either a confirmation or an error message. For instance, the validator elections smart contract receives an election participation request along with the stake as the attached value. In such cases, it makes sense to attach, say, one extra Toncoin to the intended value. If there is an error (e.g., the stake may not be accepted for any reason), the full amount received (minus the processing fees) should be returned to the sender along with an error message (e.g., by using `SENDRAWMSG` with `mode = 64` as explained before). In the case of success, the confirmation message is created and exactly one Toncoin is sent back (with the message transferring fees deducted from this value; this is `mode = 1` of `SENDRAWMSG`).
+1. The sender attaches exactly one Toncoin to the intended value
+2. If an error occurs (e.g., stake not accepted):
+ - Return the full received amount (minus processing fees)
+ - Include an error message using `SENDRAWMSG` with `mode = 64`
+3. On success:
+ - Create a confirmation message
+ - Return exactly one Toncoin (minus message transferring fees)
+ - Use `SENDRAWMSG` with `mode = 1`
diff --git a/docs/v3/guidelines/smart-contracts/howto/compile/compilation-instructions.md b/docs/v3/guidelines/smart-contracts/howto/compile/compilation-instructions.md
index 804eea84f96..e42d73a85b4 100644
--- a/docs/v3/guidelines/smart-contracts/howto/compile/compilation-instructions.md
+++ b/docs/v3/guidelines/smart-contracts/howto/compile/compilation-instructions.md
@@ -1,11 +1,11 @@
-# Compile from Sources
+# Compile from sources
You can download prebuilt binaries [here](/v3/documentation/archive/precompiled-binaries#1-download).
If you still want to compile sources yourself, follow the instructions below.
:::caution
-This is a simplified quick build guide.
+This is a simplified quick build guide.
If you are building for production and not for home use, it's better to use [autobuild scripts](https://github.com/ton-blockchain/ton/tree/master/.github/workflows).
:::
@@ -14,13 +14,13 @@ If you are building for production and not for home use, it's better to use [aut
The software is likely to compile and work properly on most Linux systems. It should work on macOS and even Windows.
-1) Download the newest version of TON Blockchain sources available at the GitHub repository https://github.com/ton-blockchain/ton/:
+1. Download the newest version of TON Blockchain sources available at the GitHub repository https://github.com/ton-blockchain/ton/:
```bash
git clone --recurse-submodules https://github.com/ton-blockchain/ton.git
```
-2) Install the newest versions of:
+2. Install the newest versions of:
- `make`
- `cmake` version 3.0.2 or later
- `g++` or `clang` (or another C++14-compatible compiler as appropriate for your operating system).
@@ -34,8 +34,7 @@ apt update
sudo apt install build-essential cmake clang openssl libssl-dev zlib1g-dev gperf libreadline-dev ccache libmicrohttpd-dev pkg-config libsodium-dev libsecp256k1-dev liblz4-dev
```
-
-3) Suppose that you have fetched the source tree to directory `~/ton`, where `~` is your home directory, and that you have created an empty directory `~/ton-build`:
+3. Suppose that you have fetched the source tree to directory `~/ton`, where `~` is your home directory, and that you have created an empty directory `~/ton-build`:
```bash
mkdir ton-build
@@ -53,18 +52,21 @@ cmake -DCMAKE_BUILD_TYPE=Release ../ton && cmake --build . -j$(nproc)
### On MacOS
Prepare the system by installing required system packages
+
```zsh
brew install ninja libsodium libmicrohttpd pkg-config automake libtool autoconf gnutls
brew install llvm@16
```
-Use newly installed clang.
+Use newly installed clang.
+
```zsh
export CC=/opt/homebrew/opt/llvm@16/bin/clang
export CXX=/opt/homebrew/opt/llvm@16/bin/clang++
```
Compile secp256k1
+
```zsh
git clone https://github.com/bitcoin-core/secp256k1.git
cd secp256k1
@@ -74,6 +76,7 @@ Compile secp256k1
./configure --enable-module-recovery --enable-static --disable-tests --disable-benchmark
make -j12
```
+
and lz4:
```zsh
@@ -83,6 +86,7 @@ and lz4:
git checkout v1.9.4
make -j12
```
+
and relink OpenSSL 3.0
```zsh
@@ -110,7 +114,7 @@ cmake -GNinja -DCMAKE_BUILD_TYPE=Release .. \
If you are compiling on a computer with low memory (e.g., 1 Gb), don't forget to [create a swap partitions](/v3/guidelines/smart-contracts/howto/compile/instructions-low-memory).
:::
-## Download Global Config
+## Download global config
For tools like lite client you need to download the global network config.
@@ -126,7 +130,7 @@ or from https://ton-blockchain.github.io/testnet-global.config.json for testnet:
wget https://ton-blockchain.github.io/testnet-global.config.json
```
-## Lite Client
+## Lite client
To build a lite client, do [common part](/v3/guidelines/smart-contracts/howto/compile/compilation-instructions#common), [download the config](/v3/guidelines/smart-contracts/howto/compile/compilation-instructions#download-global-config), and then do:
@@ -149,7 +153,6 @@ If you indicate a writeable "database" directory as an extra argument to the cli
Basic help info can be obtained by typing `help` into the Lite Client. Type `quit` or press `Ctrl-C` to exit.
-
## FunC
To build FunC compiler from source code, do [common part](/v3/guidelines/smart-contracts/howto/compile/compilation-instructions#common) described above and then:
@@ -208,7 +211,7 @@ The Proxy binary will be located as:
./rldp-http-proxy/rldp-http-proxy
```
-## generate-random-id
+## Generate-random-id
To build generate-random-id, do [common part](/v3/guidelines/smart-contracts/howto/compile/compilation-instructions#common) and then do:
@@ -222,7 +225,7 @@ The binary will be located as:
./utils/generate-random-id
```
-## storage-daemon
+## Storage-daemon
To build storage-daemon and storage-daemon-cli, do [common part](/v3/guidelines/smart-contracts/howto/compile/compilation-instructions#common) and then do:
@@ -245,7 +248,7 @@ git clone https://github.com/ton-blockchain/ton.git
cd ton
# git checkout for example checkout func-0.2.0
git checkout func-0.2.0
-git submodule update --init --recursive
+git submodule update --init --recursive
cd ..
mkdir ton-build
cd ton-build
@@ -254,13 +257,14 @@ cmake ../ton
cmake --build . --target func
```
-## Compile old versions on Apple M1:
+## Compile old versions on Apple M1
TON supports Apple M1 from 11 Jun 2022 ([Add apple m1 support (#401)](https://github.com/ton-blockchain/ton/commit/c00302ced4bc4bf1ee0efd672e7c91e457652430) commit).
To compile older TON revisions on Apple M1:
1. Update RocksDb submodule to 6.27.3
+
```bash
cd ton/third-party/rocksdb/
git checkout fcf3d75f3f022a6a55ff1222d6b06f8518d38c7c
diff --git a/docs/v3/guidelines/smart-contracts/howto/compile/instructions-low-memory.md b/docs/v3/guidelines/smart-contracts/howto/compile/instructions-low-memory.md
index 1af28fc322e..0c706837934 100644
--- a/docs/v3/guidelines/smart-contracts/howto/compile/instructions-low-memory.md
+++ b/docs/v3/guidelines/smart-contracts/howto/compile/instructions-low-memory.md
@@ -1,50 +1,56 @@
-# Compile TON on a low-memory machines
+# Compile TON on low-memory machines
:::caution
-This section describes instructions and manuals for interacting with TON at a low level.
+This section provides low-level instructions for working with TON.
:::
-Creating a swap partitions to compile TON on a computer with low memory (less than 1GB).
+To compile TON on systems with limited memory (<1GB), you need to create swap partitions.
## Prerequisites
-During C++ compilation in the Linux system the following errors occur, resulting in a compilation abort:
+When compiling C++ components on Linux, you may encounter memory-related failures:
```
-C++: fatal error: Killed signal terminated program cc1plus compilation terminated.
+C++: fatal error: Killed signal terminated program cc1plus
+compilation terminated.
```
## Solution
-This occurs due to a lack of memory and is solved by creating a swap partitions.
+Follow these steps to create a 4GB swap partition:
```bash
-# Create the partition path
+# Create swap partition
sudo mkdir -p /var/cache/swap/
-# Set the size of the partition
-# bs=64M is the block size, count=64 is the number of blocks, so the swap space size is bs*count=4096MB=4GB
+
+# Allocate 4GB swap space (64MB blocks × 64)
sudo dd if=/dev/zero of=/var/cache/swap/swap0 bs=64M count=64
-# Set permissions for this directory
+
+# Set secure permissions
sudo chmod 0600 /var/cache/swap/swap0
-# Create the SWAP file
+
+# Initialize swap
sudo mkswap /var/cache/swap/swap0
-# Activate the SWAP file
+
+# Activate swap
sudo swapon /var/cache/swap/swap0
-# Check if SWAP information is correct
+
+# Verify activation
sudo swapon -s
```
-Command to delete swap partition:
+### Swap management commands
+
+**Remove swap partition:**
```bash
sudo swapoff /var/cache/swap/swap0
sudo rm /var/cache/swap/swap0
```
-Free space command:
+**Free all swap space:**
```bash
sudo swapoff -a
-#Detailed usage: swapoff --help
-#View current memory usage: --swapoff: free -m
-```
\ No newline at end of file
+# Check memory: free -m
+```
diff --git a/docs/v3/guidelines/smart-contracts/howto/multisig-js.md b/docs/v3/guidelines/smart-contracts/howto/multisig-js.md
index 43d0cd23489..09cce382d81 100644
--- a/docs/v3/guidelines/smart-contracts/howto/multisig-js.md
+++ b/docs/v3/guidelines/smart-contracts/howto/multisig-js.md
@@ -55,7 +55,7 @@ import { KeyPair, mnemonicToPrivateKey } from "ton-crypto";
import { getHttpEndpoint } from "@orbs-network/ton-access";
```
-### 2. Create a `TonClient` instance
+### 2. Create a TonClient instance
Initialize the `TonClient`:
@@ -84,7 +84,7 @@ for (let i = 0; i < mnemonics.length; i++) {
}
```
-### 4. Create a `MultisigWallet` object
+### 4. Create a MultisigWallet object
You can create a `MultisigWallet` object in two ways:
diff --git a/docs/v3/guidelines/smart-contracts/security/random-number-generation.md b/docs/v3/guidelines/smart-contracts/security/random-number-generation.md
index 3928c4c108d..581a339b8a6 100644
--- a/docs/v3/guidelines/smart-contracts/security/random-number-generation.md
+++ b/docs/v3/guidelines/smart-contracts/security/random-number-generation.md
@@ -12,7 +12,7 @@ These algorithms typically require a _seed_ value to produce a sequence of _pseu
To predict the result of the `random()` function in a smart contract, one would need to know the current `seed` of the block, which is impossible unless you are a validator.
-## Simply use `randomize_lt()`
+## Simply use randomize_lt()
To make random number generation unpredictable, you can add the current [Logical Time](/v3/documentation/smart-contracts/message-management/messages-and-transactions#what-is-a-logical-time) to the seed. This ensures that different transactions produce different seeds and results.
diff --git a/docs/v3/guidelines/smart-contracts/security/secure-programming.mdx b/docs/v3/guidelines/smart-contracts/security/secure-programming.mdx
index bfb5466e57e..94bef71770b 100644
--- a/docs/v3/guidelines/smart-contracts/security/secure-programming.mdx
+++ b/docs/v3/guidelines/smart-contracts/security/secure-programming.mdx
@@ -155,7 +155,7 @@ For example, in TON Jetton:
At this stage, avoid `throw_if()/throw_unless()`, as it could result in lost Jettons. Use try-catch statements, available in FunC v0.4.0+, to handle errors and return Jettons if necessary.
-### 6. Calculate gas and check `msg_value`
+### 6. Calculate gas and check msg_value
Estimate the gas cost of each handler in your message flow and check the sufficiency of `msg_value`. Avoid demanding excessive gas, as it must be divided among subsequent messages. Recalculate gas requirements if your code starts sending more messages.