Skip to content

Commit

Permalink
Merge pull request #8 from ton-community/main
Browse files Browse the repository at this point in the history
Fork Sync: Update from ton-community/ton-docs
  • Loading branch information
github-actions[bot] authored Apr 29, 2024
2 parents 6081203 + 2a698f5 commit 3a828cc
Show file tree
Hide file tree
Showing 21 changed files with 538 additions and 101 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
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
60 changes: 18 additions & 42 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,75 +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)

#### Toncoin Withdrawals

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

### Jetton

#### 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)
- [JS code to withdraw (send) jettons from a wallet in batches](https://github.com/toncenter/examples/blob/main/withdrawals-jettons-highload-batch.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
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.
:::
53 changes: 45 additions & 8 deletions docs/develop/dapps/asset-processing/jettons.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,51 @@ import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import Button from '@site/src/components/button';

# TON Jetton processing
# Jetton Processing

Best practices with comments on jettons processing:
## Best Practices on Jettons Processing

- [JS algo to accept jettons deposits](https://github.com/toncenter/examples/blob/main/deposits-jettons.js)
Jettons are tokens on TON Blockchain - one can consider them similarly to ERC-20 tokens on Ethereum.

- [JS algo to jettons withdrawals](https://github.com/toncenter/examples/blob/main/withdrawals-jettons-highload.js)
:::info Transaction Confirmation
TON transactions are irreversible after just one confirmation. For the best UX/UI avoid additional waiting.
:::

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

:::info Transaction Confirmation
TON transactions are irreversible after just one confirmation. For the best user experience, it is suggested to avoid waiting on additional blocks once transactions are finalized on the TON Blockchain. Read more in the [Catchain.pdf](https://docs.ton.org/catchain.pdf#page=3).
[Highload Wallet v3](/participate/wallets/contracts#highload-wallet-v3) - this is TON Blockchain latest solution which is the gold standard for jetton withdrawals. It allows you to take advantage of batched withdrawals.

[Batched withdrawals](https://github.com/toncenter/examples/blob/main/withdrawals-jettons-highload-batch.js) - Meaning that multiple withdrawals are sent in batches, allowing for quick and cheap withdrawals.

#### Deposits
:::info
It is suggested to set several MEMO deposit wallets for better performance.
:::

[Memo Deposits](https://github.com/toncenter/examples/blob/main/deposits-jettons.js) - This allows you to keep one deposit wallet, and users add a memo in order to be identified by your system. This means that you don’t need to scan the entire blockchain, but is slightly less easy for users.

[Memo-less deposits](https://github.com/gobicycle/bicycle) - This solution also exists, but is more difficult to integrate. However, we can assist with this, if you would prefer to take this route. Please notify us before deciding to implement this approach.

### Additional Info

:::caution Transaction Notification
if you will be allowing your users set a custom memo when withdrawing jettons - make sure to set forwardAmount to 0.000000001 TON (1 nanoton) whenever a memo (text comment) is attached, otherwise the transfer will not be standard compliant and will not be able to be processed by other CEXes and other such services.
:::

In most cases, this should be enough for you, if not, you can find detailed information below.
- Please find the JS lib example - [tonweb](https://github.com/toncenter/tonweb) - which is the official JS library from the TON Foundation.

- If you want to use Java, you can look into [ton4j](https://github.com/neodix42/ton4j/tree/main).

- For Go, one should consider [tonutils-go](https://github.com/xssnick/tonutils-go). At the moment, we recommend the JS lib.


## Content List


:::tip
In following docs offers details about Jettons architecture generally, as well as core concepts of TON which may be different from EVM-like and other blockchains. This is crucial reading in order for one to grasp a good understanding of TON, and will greatly help you.
:::

This document describes the following in order:
1. Overview
2. Architecture
Expand All @@ -34,9 +61,14 @@ This document describes the following in order:
## Overview

:::info
TON transactions are irreversible after just one confirmation.
For clear understanding, the reader should be familiar with the basic principles of asset processing described in [this section of our documentation](/develop/dapps/asset-processing/). In particular, it is important to be familiar with [contracts](/learn/overviews/addresses#everything-is-a-smart-contract), [wallets](/develop/smart-contracts/tutorials/wallet), [messages](/develop/smart-contracts/guidelines/message-delivery-guarantees) and deployment process.
:::

:::Info
For the best user experience, it is suggested to avoid waiting on additional blocks once transactions are finalized on the TON Blockchain. Read more in the [Catchain.pdf](https://docs.ton.org/catchain.pdf#page=3).
:::

Quick jump to the core description of jetton processing:

<Button href="/develop/dapps/asset-processing/jettons#accepting-jettons-from-users-through-a-centralized-wallet" colorType={'primary'} sizeType={'sm'}>Centralized Proccessing</Button>
Expand Down Expand Up @@ -342,6 +374,11 @@ If they match, it’s ideal. If not, then you likely received a scam token that
To prevent a bottleneck in incoming transactions to a single wallet, it is suggested to accept deposits across multiple wallets and to expand the number of these wallets as needed.
:::


:::caution Transaction Notification
if you will be allowing your users set a custom memo when withdrawing jettons - make sure to set forwardAmount to 0.000000001 TON (1 nanoton) whenever a memo (text comment) is attached, otherwise the transfer will not be standard compliant and will not be able to be processed by other CEXes and other such services.
:::

In this scenario, the payment service creates a unique memo identifier for each sender disclosing
the address of the centralized wallet and the amounts being sent. The sender sends the tokens
to the specified centralized address with the obligatory memo in the comment.
Expand Down
2 changes: 1 addition & 1 deletion docs/develop/dapps/asset-processing/metadata.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# TON Metadata Parsing
# Metadata Parsing

The metadata standard, which covers NFTs, NFT Collections, and Jettons, is outlined in TON Enhancement Proposal 64 [TEP-64](https://github.com/ton-blockchain/TEPs/blob/master/text/0064-token-data-standard.md).

Expand Down
2 changes: 1 addition & 1 deletion docs/develop/dapps/asset-processing/nfts.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# TON NFT processing
# NFT Processing

## Overview

Expand Down
Loading

0 comments on commit 3a828cc

Please sign in to comment.