Skip to content

Commit

Permalink
Merge branch 'main' into patch-3
Browse files Browse the repository at this point in the history
  • Loading branch information
reveloper authored Apr 30, 2024
2 parents 5bd10a5 + d6e368d commit 863bf1a
Show file tree
Hide file tree
Showing 29 changed files with 967 additions and 433 deletions.
2 changes: 1 addition & 1 deletion .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- i18n/**/*

"documentation :book:":
- README.md
- academy-overview.md

"tooling :wrench:":
- .github/**/*
Expand Down
2 changes: 1 addition & 1 deletion docs/develop/archive/mining.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Yes, there is a third-party app—[TON Miner Bot](https://t.me/TonMinerBot).
#### <a id="faq-general-stats"></a>Where can I see mining statistics?
[ton.org/mining](https://ton.org/mining)
#### <a id="faq-general-howmany"></a>How many miners are out there?
We cannot say this. All we know is the total hashrate of all miners on the network. However, there are graphs on [ton.org/mining](https://ton.org/mining) that attempt to estimate quantity of machines of certan type needed to provide aproximate total hashrate.
We cannot say this. All we know is the total hashrate of all miners on the network. However, there are graphs on [ton.org/mining](https://ton.org/mining) that attempt to estimate quantity of machines of certain type needed to provide approximate total hashrate.
#### <a id="faq-general-noincome"></a>Do I need Toncoin to start mining?
No, you do not. Anyone can start mining without owning a single Toncoin.
#### <a id="faq-mining-noincome"></a>I mine for hours, why my wallet total does not increase, not even by 1 TON?
Expand Down
14 changes: 7 additions & 7 deletions docs/develop/blockchain/shards.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ By default in the Basechain (`workchain=0`) there is only one shard with a shard

Each shard is responsible for some subset of accounts with some common binary prefix. This prefix appears in shard id which presented by a 64-bit integer and has the following structure: `<binary prefix>100000...`. For example, shard with id `1011100000...` contains all accounts started with prefix `1011`.

When number of transactions in some shard growth, it splits into two shards. New shards obtaining the following ids: `<parent prefix>01000...` and `<parent prefix>11000...` and responsible for accounts starting with `<parent prefix>0` and `<parent prefix>1` correspondingly. The seqnos of blocks in shards goes continuously starting from parent last seqno plus 1. After split shards go independently and may have different seqnos.
When number of transactions in some shard grows, this shard splits into two shards. New shards obtain the following ids: `<parent prefix>01000...` and `<parent prefix>11000...` and become responsible for accounts starting with `<parent prefix>0` and `<parent prefix>1` correspondingly. The seqnos of blocks in shards go continuously starting from the parent last seqno plus 1. After split, shards go independently and may have different seqnos.

Masterchain block contains information about shards in its header. After the block of shard appears in masterchain header it may be considered as finished (it cannot be rolled back).
Masterchain block contains information about shards in their headers. After the block of shard appears in masterchain header it may be considered as finished (it cannot be rolled back).

Example:
* Masterchain block `seqno=34607821` has 2 shards: `(0,4000000000000000,40485798)` and `(0,c000000000000000,40485843)` (https://toncenter.com/api/v2/shards?seqno=34607821).
* Shard `shard=4000000000000000` was splitted into `shard=2000000000000000` and `shard=6000000000000000` and masterchain block `seqno=34607822` already has 3 shards: `(0,2000000000000000,40485799)` and `(0,6000000000000000,40485799)`. Note, that both new shards has the same seqnos but different shard IDs (https://toncenter.com/api/v2/shards?seqno=34607822).
* New shards go independently and after 100 masterchain blocks (in masterchain block `seqno=34607921`) one shard has last block `(0,2000000000000000,40485901)` and another one has `(0,6000000000000000,40485897)` (https://toncenter.com/api/v2/shards?seqno=34607921).
* Shard `shard=4000000000000000` was splitted into `shard=2000000000000000` and `shard=6000000000000000`, and the masterchain block `seqno=34607822` obtains 3 shards: `(0,2000000000000000,40485799)` and `(0,6000000000000000,40485799)`. Note that both new shards have the same seqnos but different shard IDs (https://toncenter.com/api/v2/shards?seqno=34607822).
* New shards go independently and after 100 masterchain blocks (in masterchain block `seqno=34607921`) one shard has the last block `(0,2000000000000000,40485901)` and another one has `(0,6000000000000000,40485897)` (https://toncenter.com/api/v2/shards?seqno=34607921).

## Merging
When shards load goes down they can merge back as follow:
* Two shards can merge if they have common parent and, therefore, their shard ids are `<parent prefix>010...` and `<parent prefix110...`. Merged shard will have shard id `<parent prefix>10...` (for example `10010...` + `10110...` = `1010...`). The first block of merged shard will have `seqno=max(seqno1, seqno2) + 1`.
If the load on shards goes down they can merge back:
* Two shards can merge if they have a common parent and, therefore, their shard ids are `<parent prefix>010...` and `<parent prefix110...`. Merged shard will have shard id `<parent prefix>10...` (for example `10010...` + `10110...` = `1010...`). The first block of a merged shard will have `seqno=max(seqno1, seqno2) + 1`.

Example:
* In masterchain block `seqno=34626306` two of five shards with last blocks `(0,a000000000000000,40492030)` and `(0,e000000000000000,40492216)` merged into one with block `(0,c000000000000000,40492217)` (https://toncenter.com/api/v2/shards?seqno=34626306 and https://toncenter.com/api/v2/shards?seqno=34626307).
* In masterchain block `seqno=34626306`, two of five shards with last blocks `(0,a000000000000000,40492030)` and `(0,e000000000000000,40492216)` merged into one with block `(0,c000000000000000,40492217)` (https://toncenter.com/api/v2/shards?seqno=34626306 and https://toncenter.com/api/v2/shards?seqno=34626307).
4 changes: 2 additions & 2 deletions docs/develop/companies/outsource.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Coinvent is a dedicated outsource development team, passionately committed to cr
### softstack

#### Summary
Softstack formerly known as Chainsulting, is a leading provider of comprehensive Web3 solutions, with a focus on software development and smart contract auditing.
Softstack is a leading service provider of comprehensive Web3 solutions, since 2017, with a focus on software development and smart contract auditing. Made in Germany

#### Workstreams
- Smart Contract & dApp Development
Expand All @@ -122,7 +122,7 @@ Softstack formerly known as Chainsulting, is a leading provider of comprehensive
#### Contacts
- [email protected]
- [softstack.io](https://softstack.io/)
- Telegram [@softstack](https://t.me/softstack)
- Telegram [@yannikheinze](https://t.me/yannikheinze)

## Add your team

Expand Down
20 changes: 12 additions & 8 deletions docs/develop/dapps/apis/sdk.mdx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# SDK list (if you've decided on functionality)
# SDKs

Please use the sidebar navigation to choose the preferred programming language!
Instant navigate on preferred language with right sidebar.

:::tip
## Overview

There are different ways to connect to blockchain:
1. RPC data provider or other API: in most cases, you have to *rely* on its stability and security.
2. ADNL connection: you're connecting to a [liteserver](/participate/run-nodes/liteserver). They might be inaccessible, but with a certain level of validation (implemented in the library), cannot lie.
3. Tonlib binary: you're connecting to liteserver as well, so all benefits and downsides apply, but your application also contains a dynamic-loading library compiled outside.
4. Offchain-only. Such SDKs allow to create and serialize cells, which you can then send to APIs.

:::

### TypeScript / JavaScript

Expand All @@ -21,19 +20,24 @@ There are different ways to connect to blockchain:
|[tonkite/adnl](https://github.com/tonkite/adnl)|[ADNL](/develop/network/adnl-tcp) natively / via WebSocket| ADNL TypeScript implementation. |
|[tonutils](https://github.com/thekiba/tonutils)|Native [ADNL](/develop/network/adnl-tcp)| TypeScript-based interface for building and interacting with applications in TON Ecosystem. Due to native ADNL dependency, cannot be used for blockchain interaction in browser.|

### Java
| Library | Blockchain connection | Description |
|---------|------------------|--------------|
| [ton4js](https://github.com/neodix42/ton4j) | Tonlib binary | Java SDK for The Open Network (TON) |


### Python

<!-- tonsdk dropped due to invalid cells serialization -->

| Library | Blockchain connection | Description |
|---------|------------------|--------------|
|[TonTools](https://github.com/yungwine/TonTools)|via RPC ([Orbs](https://www.orbs.com/ton-access/) / [Toncenter](https://toncenter.com/api/v2/) / etc)|TonTools is a high-level OOP library for Python, which can be used to interact with TON Blockchain.|
|[pytoniq-core](https://github.com/yungwine/pytoniq-core) | *offchain-only* | Python powerful transport-free SDK |
|[pytoniq](https://github.com/yungwine/pytoniq) |Native ADNL| Python SDK with native LiteClient and other ADNL-based protocols implementations. |
|[tonpy](https://github.com/disintar/tonpy)|Native ADNL| Python package that provides data structures and API to interact with TON blockchain. |
|[mytonlib](https://github.com/igroman787/mytonlib)|Native ADNL| Native Python SDK library for working with The Open Network |
|[pytoniq-core](https://github.com/yungwine/pytoniq-core) | *offchain-only* | Python powerful transport-free SDK |
|[pytonlib](https://github.com/toncenter/pytonlib)|Tonlib binary| This is standalone Python library based on libtonlibjson, brought as a binary dependency from TON monorepo. |
|[mytonlib](https://github.com/igroman787/mytonlib)|Native ADNL| Native Python SDK library for working with The Open Network |
|[TonTools](https://github.com/yungwine/TonTools)|via RPC ([Orbs](https://www.orbs.com/ton-access/) / [Toncenter](https://toncenter.com/api/v2/) / etc)|TonTools is a high-level OOP library for Python, which can be used to interact with TON Blockchain.|
|[tonpy](https://github.com/disintar/tonpy)|Native ADNL| Python package that provides data structures and API to interact with TON blockchain. |
|[tvm_valuetypes](https://github.com/toncenter/tvm_valuetypes)|*offchain-only*| library is collection of utilits for handling TVM types. |
|[pytvm](https://github.com/yungwine/pytvm) | *offchain*, Tonlib | Python TVM emulator using bindings to C++ standard emulator |

Expand Down
2 changes: 1 addition & 1 deletion docs/develop/dapps/apis/toncenter.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ There are different ways to connect to blockchain:

Indexers allow to list jetton wallets, NFTs, transactions by certain filters, not only retrieve specific ones.

- Public TON Index can be used: tests and development are for free, premium for production - [toncenter.com/api/v3/](https://toncenter.com/api/v3/).
- Public TON Index can be used: tests and development are for free, [premium](https://t.me/tonapibot) for production - [toncenter.com/api/v3/](https://toncenter.com/api/v3/).
- Run your own TON Index with [Worker](https://github.com/toncenter/ton-index-worker/tree/36134e7376986c5517ee65e6a1ddd54b1c76cdba) and [TON Index API wrapper](https://github.com/toncenter/ton-indexer).

### GraphQL Nodes
Expand Down
76 changes: 30 additions & 46 deletions docs/develop/dapps/asset-processing/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Button from '@site/src/components/button'

# Payments processing
# Processing Global Overview

This page contains an overview and specific details that explain how to process (send and accept) digital assets on the TON blockchain.

Expand All @@ -10,74 +10,51 @@ TON transactions are irreversible after just one confirmation. For the best user

## Best Practices

### Fundamentals for Wallet

- [Create a key pair, a wallet and get a wallet address](https://github.com/toncenter/examples/blob/main/common.js)

### Toncoin

#### Toncoin Deposits

:::info
It is suggested to accept deposits across multiple wallets on your side.
It is suggested to set several MEMO deposit wallets for better performance.
:::
- [JS code to accept Toncoin deposits](https://github.com/toncenter/examples/blob/main/deposits.js)

#### Toncoin Withdrawals
- [JS code to withdraw (send) Toncoin from a wallet in batches](https://github.com/toncenter/examples/blob/main/withdrawals-highload-batch.js)
- [JS code to withdraw (send) Toncoins from a wallet](https://github.com/toncenter/examples/blob/main/withdrawals-highload.js)

- [MEMO Deposits](https://github.com/toncenter/examples/blob/main/deposits.js)

- [Detailed info](https://docs.ton.org/develop/dapps/asset-processing#global-overview)

### Jetton
#### Toncoin Withdrawals

#### Jetton Deposits
:::info
It is suggested to accept deposits across multiple wallets on your side.
:::
- [Batched withdrawals](https://github.com/toncenter/examples/blob/main/withdrawals-highload-batch.js)
- [Withdrawals](https://github.com/toncenter/examples/blob/main/withdrawals-highload.js)

- [JS code to accept jettons deposits](https://github.com/toncenter/examples/blob/main/deposits-jettons.js)

#### Jetton Withdrawals
- [JS code to withdraw (send) jettons from a wallet](https://github.com/toncenter/examples/blob/main/withdrawals-jettons-highload.js)
- [Detailed info](/develop/dapps/asset-processing#global-overview)

- [Detailed info](https://docs.ton.org/develop/dapps/asset-processing/jettons)
### Jetton

## Other Examples
- [Read Jetton Proccesing](/develop/dapps/asset-processing/jettons)

### Self-hosted service

#### Made by community
### Made by TON Community

[Gobicycle](https://github.com/gobicycle/bicycle) service is focused on replenishing user balances and sending payments to blockchain accounts. Both TONs and Jettons are supported. The service is written with numerous pitfalls in mind that a developer might encounter (all checks for jettons, correct operations status check, resending messages, performance during high load when blockchain is splitted by shards). Provide simple HTTP API, rabbit and webhook notifications about new payments.
#### GO

### JavaScript
- [Gobicycle](https://github.com/gobicycle/bicycle) - service is focused on replenishing user balances and sending payments to blockchain accounts. Both TONs and Jettons are supported. The service is written with numerous pitfalls in mind that a developer might encounter (all checks for jettons, correct operations status check, resending messages, performance during high load when blockchain is splitted by shards). Provide simple HTTP API, rabbit and webhook notifications about new payments.
- [GO examples](https://github.com/xssnick/tonutils-go#how-to-use)

#### Made by community
#### JavaScript

Using ton.js SDK (supported by TON Community):

- [Create a key pair, a wallet and get a wallet address](https://github.com/toncenter/examples/blob/main/common.js)
- [Create a wallet, get its balance, make a transfer](https://github.com/ton-community/ton#usage)

### Python

#### Made by community

Using psylopunk/pytonlib (Simple Python client for The Open Network):

- [Sending transactions](https://github.com/psylopunk/pytonlib/blob/main/examples/transactions.py)
#### Python

Using tonsdk library (similar to tonweb):

- [Init wallet, create external message to deploy the wallet](https://github.com/tonfactory/tonsdk#create-mnemonic-init-wallet-class-create-external-message-to-deploy-the-wallet)

### Golang

#### Made by community

- [See full list of examples](https://github.com/xssnick/tonutils-go#how-to-use)

## Global overview
## Global Overview
Embodying a fully asynchronous approach, TON Blockchain involves a few concepts which are uncommon to traditional blockchains. Particularly, each interaction of any actor with the blockchain consists of a graph of asynchronously transferred messages between smart contracts and/or the external world. The common path of any interaction starts with an external message sent to a `wallet` smart contract, which authenticates the message sender using public-key cryptography, takes charge of fee payment, and sends inner blockchain messages. That way, transactions on the TON network are not synonymous with user interaction with the blockchain but merely nodes of the message graph: the result of accepting and processing a message by a smart contract, which may or may not lead to the emergence of new messages. The interaction may consist of an arbitrary number of messages and transactions and span a prolonged period of time. Technically, transactions with queues of messages are aggregated into blocks processed by validators. The asynchronous nature of the TON Blockchain **does not allow to predict the hash and lt (logical time) of a transaction** at the stage of sending a message. The transaction accepted to the block is final and cannot be modified.

**Each inner blockchain message is a message from one smart contract to another, which bears some amount of digital assets, as well as an arbitrary portion of data.**
Expand Down Expand Up @@ -159,13 +136,20 @@ To accept payments based on attached comments, the service should
### Invoices with ton:// link

If you need an easy integration for a simple user flow, it is suitable to use the ton:// link.
Best suited for one-time payments and invoices.
Best suited for one-time payments and invoices with Toncoin.

```bash
```text
ton://transfer/<destination-address>?
[nft=<nft-address>&]
[fee-amount=<nanocoins>&]
[forward-amount=<nanocoins>]
[amount=<toncoin-in-nanocoins>&]
[text=<url-encoded-utf8-comment>]
```

Example of ton:// link generation:

```typescript
const tonLink = `ton://transfer/${address.toString({
urlSafe: true,
})}?amount=${amount}${text ? `&text=${encodeURIComponent(text)}` : ''}`;
```

- ✅ Easy integration
Expand Down
63 changes: 63 additions & 0 deletions docs/develop/dapps/asset-processing/address-verification.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Wallet Address Validation

### How to Check the Validity of a TON Wallet Address?



<Tabs groupId="address-examples">

<TabItem value="Tonweb" label="JS (Tonweb)">

```js
const TonWeb = require("tonweb")
TonWeb.utils.Address.isValid('...')
```

</TabItem>
<TabItem value="GO" label="tonutils-go">

```python
package main

import (
"fmt"
"github.com/xssnick/tonutils-go/address"
)

if _, err := address.ParseAddr("EQCD39VS5j...HUn4bpAOg8xqB2N"); err != nil {
return errors.New("invalid address")
}
```


</TabItem>
<TabItem value="Java" label="Ton4j">

```javascript
try {
Address.of("...");
} catch (e) {
// not valid address
}
```

</TabItem>
<TabItem value="Kotlin" label="ton-kotlin">

```javascript
try {
AddrStd("...")
} catch(e: IllegalArgumentException) {
// not valid address
}
```

</TabItem>
</Tabs>

:::tip
Full Address description on the [Smart Contract Addresses](/learn/overviews/addresses) page.
:::
Loading

0 comments on commit 863bf1a

Please sign in to comment.