diff --git a/.github/labeler.yml b/.github/labeler.yml index 91ec2cea3a..3bbdd60914 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -8,7 +8,7 @@ - i18n/**/* "documentation :book:": - - README.md + - academy-overview.md "tooling :wrench:": - .github/**/* diff --git a/docs/develop/dapps/apis/sdk.mdx b/docs/develop/dapps/apis/sdk.mdx index c29edc87d5..311ac33df2 100644 --- a/docs/develop/dapps/apis/sdk.mdx +++ b/docs/develop/dapps/apis/sdk.mdx @@ -1,8 +1,8 @@ -# 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. @@ -10,7 +10,6 @@ There are different ways to connect to blockchain: 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 @@ -21,6 +20,11 @@ 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 @@ -28,12 +32,12 @@ There are different ways to connect to blockchain: | 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 | diff --git a/docs/develop/dapps/apis/toncenter.md b/docs/develop/dapps/apis/toncenter.md index e1cdcb88b9..0770f50ea5 100644 --- a/docs/develop/dapps/apis/toncenter.md +++ b/docs/develop/dapps/apis/toncenter.md @@ -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 diff --git a/docs/develop/dapps/asset-processing/README.md b/docs/develop/dapps/asset-processing/README.md index cb7387f474..d7a0b30f63 100644 --- a/docs/develop/dapps/asset-processing/README.md +++ b/docs/develop/dapps/asset-processing/README.md @@ -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. @@ -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.** diff --git a/docs/develop/dapps/asset-processing/address-verification.mdx b/docs/develop/dapps/asset-processing/address-verification.mdx new file mode 100644 index 0000000000..eb4b0d976c --- /dev/null +++ b/docs/develop/dapps/asset-processing/address-verification.mdx @@ -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? + + + + + + + + ```js + const TonWeb = require("tonweb") + TonWeb.utils.Address.isValid('...') + ``` + + + + + ```python + package main + + import ( + "fmt" + "github.com/xssnick/tonutils-go/address" + ) + + if _, err := address.ParseAddr("EQCD39VS5j...HUn4bpAOg8xqB2N"); err != nil { + return errors.New("invalid address") + } + ``` + + + + + + ```javascript + try { + Address.of("..."); + } catch (e) { + // not valid address + } + ``` + + + + +```javascript + try { + AddrStd("...") + } catch(e: IllegalArgumentException) { + // not valid address + } +``` + + + + +:::tip +Full Address description on the [Smart Contract Addresses](/learn/overviews/addresses) page. +::: diff --git a/docs/develop/dapps/asset-processing/jettons.md b/docs/develop/dapps/asset-processing/jettons.md index e7dd51e43f..2380118847 100644 --- a/docs/develop/dapps/asset-processing/jettons.md +++ b/docs/develop/dapps/asset-processing/jettons.md @@ -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 @@ -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: @@ -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. diff --git a/docs/develop/dapps/asset-processing/metadata.md b/docs/develop/dapps/asset-processing/metadata.md index b2584b2330..01c6ebe3b5 100644 --- a/docs/develop/dapps/asset-processing/metadata.md +++ b/docs/develop/dapps/asset-processing/metadata.md @@ -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). diff --git a/docs/develop/dapps/asset-processing/nfts.md b/docs/develop/dapps/asset-processing/nfts.md index 323162d517..4e8c1ac97b 100644 --- a/docs/develop/dapps/asset-processing/nfts.md +++ b/docs/develop/dapps/asset-processing/nfts.md @@ -1,4 +1,4 @@ -# TON NFT processing +# NFT Processing ## Overview diff --git a/docs/develop/dapps/cookbook.md b/docs/develop/dapps/cookbook.md index a071ff4812..f1c17df23e 100644 --- a/docs/develop/dapps/cookbook.md +++ b/docs/develop/dapps/cookbook.md @@ -247,6 +247,64 @@ print(address.to_str(is_user_friendly=True, is_bounceable=False, is_url_safe=Tru + +### How to Check the Validity of a TON Wallet Address? + + + + + + +```js + +const TonWeb = require("tonweb") + +TonWeb.utils.Address.isValid('...') +``` + + + + +```python +package main + +import ( + "fmt" + "github.com/xssnick/tonutils-go/address" +) + +if _, err := address.ParseAddr("EQCD39VS5j...HUn4bpAOg8xqB2N"); err != nil { + return errors.New("invalid address") +} +``` + + + + + +```javascript +try { + Address.of("..."); +} catch (e) { + // not valid address +} +``` + + + + +```javascript +try { + AddrStd("...") +} catch(e: IllegalArgumentException) { + // not valid address +} +``` + + + + + ## Standard wallets in TON ecosystem ### How to transfer TON? How to send a text message to other wallet? @@ -561,6 +619,47 @@ const userJettonWalletAddress = new Address(0, jettonWalletStateInit.hash()); console.log('User Jetton Wallet address:', userJettonWalletAddress.toString()); ``` + + + + +```python + +from pytoniq_core import Address, Cell, begin_cell + +def calculate_jetton_address( + owner_address: Address, jetton_master_address: Address, jetton_wallet_code: str +): + # Recreate from jetton-utils.fc calculate_jetton_wallet_address() + # https://tonscan.org/jetton/EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs#source + + data_cell = ( + begin_cell() + .store_uint(0, 4) + .store_coins(0) + .store_address(owner_address) + .store_address(jetton_master_address) + .end_cell() + ) + + code_cell = Cell.one_from_boc(jetton_wallet_code) + + state_init = ( + begin_cell() + .store_uint(0, 2) + .store_maybe_ref(code_cell) + .store_maybe_ref(data_cell) + .store_uint(0, 1) + .end_cell() + ) + state_init_hex = state_init.hash.hex() + jetton_address = Address(f'0:{state_init_hex}') + + return jetton_address + +``` +Read the entire example [here](/static/example-code-snippets/pythoniq/jetton-offline-address-calc-wrapper.py). + diff --git a/docs/develop/data-formats/library-cells.md b/docs/develop/data-formats/library-cells.md index c9f09308e4..5b925189cd 100644 --- a/docs/develop/data-formats/library-cells.md +++ b/docs/develop/data-formats/library-cells.md @@ -90,9 +90,29 @@ Actual for 04.2024 and suppose to be enhanced in the near future. -### LS, contract type detection and get methods +### Get Methods for Library Cell Based Contracts + +You have jetton-wallet with its code stored in a library cell and desire to check balance. + +To check its balance, you need to execute a get method in the code. This involves: +- accessing the library cell +- retrieving the hash of the referenced cell +- finding the cell with that hash in the masterchain's library collection +- executing the code from there. + +In Layered Solutions (LS), all these processes happen behind the scenes without the user needing to know about the specific code storage method. + +However, when working locally, things are different. For example, if you use an explorer or wallet, you may take an account state and try to determine its type—whether it's an NFT, wallet, token, or auction. + +For regular contracts, you can look at the available get methods, i.e., the interface, to understand it. Or, you may "steal" an account state to my local pseudonet and execute methods there. + +For the a library cell, this isn't possible because it doesn't contain data on its own. You must manually detect and retrieve the necessary cells from the context. This can be done through LS (though bindings do not yet support this) or via DTon. + + +#### Retrieving Library Cell with Liteserver Liteserver when running get methods automatically set correct library context. If you want to detect type of contract by get methods or run getmethods locally you need to download corresponding cells via LS method [liteServer.getLibraries](https://github.com/ton-blockchain/ton/blob/master/tl/generate/scheme/lite_api.tl#L85). +#### Retrieving Library Cell with DTon You can also get library from dton.io/graphql: ``` { diff --git a/docs/develop/smart-contracts/examples.md b/docs/develop/smart-contracts/examples.md index 8f44ce2c8d..4cd99c81f8 100644 --- a/docs/develop/smart-contracts/examples.md +++ b/docs/develop/smart-contracts/examples.md @@ -14,6 +14,8 @@ Make sure you have thoroughly tested contracts before using them in a production | [wallet-contract](https://github.com/ton-blockchain/wallet-contract)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/ton-blockchain/wallet-contract&name=wallet-contract) | Wallet v4 is proposed version of wallet to replace v3 or older wallets | | [liquid-staking-contract](https://github.com/ton-blockchain/liquid-staking-contract/)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/ton-blockchain/liquid-staking-contract/&name=liquid-staking-contract) | Liquid Staking (LSt) is a protocol that connects TON holders of all caliber with hardware node operators to participate in TON Blockchain validation through assets pooling. | | [modern_jetton](https://github.com/EmelyanenkoK/modern_jetton)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/EmelyanenkoK/modern_jetton&name=modern_jetton) | Implementation of standard jetton with additional withdraw_tons and withdraw_jettons. | +| [highloadwallet-v3](https://github.com/ton-blockchain/highload-wallet-contract-v3) | This wallet is made for who need to send transactions at very high rates. For example, crypto exchanges. | +| [stablecoin-contract](https://github.com/ton-blockchain/stablecoin-contract) | Jetton-with-governance FunC smart contracts. Used for stablecoins such as USDt. | | [governance-contract](https://github.com/ton-blockchain/governance-contract)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/ton-blockchain/governance-contract&name=governance-contract) | Core TON Blockchain contracts `elector-code.fc` and `config-code.fc`. | | [bridge-func](https://github.com/ton-blockchain/bridge-func)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/ton-blockchain/bridge-func&name=bridge-func) | TON-EVM Toncoin Bridge. | | [token-bridge-func](https://github.com/ton-blockchain/token-bridge-func)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/ton-blockchain/token-bridge-func&name=token-bridge-func) | TON-EVM token bridge - FunC smart contracts. | @@ -24,32 +26,33 @@ Make sure you have thoroughly tested contracts before using them in a production | [dns-contract](https://github.com/ton-blockchain/dns-contract)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/ton-blockchain/dns-contract&name=dns-contract) | Smart contracts of `.ton` zone. | | [nominator-pool](https://github.com/ton-blockchain/nominator-pool)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/ton-blockchain/nominator-pool&name=nominator-pool) | Nominator pool smart contract | | [single-nominator-pool](https://github.com/orbs-network/single-nominator)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/ton-blockchain/nominator-pool&name=nominator-pool) | Single Nominator Pool smart contract | -| [vesting-contract](https://github.com/ton-blockchain/vesting-contract)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/ton-blockchain/nominator-pool&name=nominator-pool) | Nominator pool smart contract | +| [vesting-contract](https://github.com/ton-blockchain/vesting-contract)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/ton-blockchain/nominator-pool&name=nominator-pool) | Nominator pool smart contract | | [storage](https://github.com/ton-blockchain/ton/tree/master/storage/storage-daemon/smartcont)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/ton-blockchain/ton/tree/master/storage/storage-daemon/smartcont&name=storage) | TON Storage provider and fabric contracts | ### Ecosystem Contracts -| Contracts | Description | -| --------------------------------------------------------------------------------------------------------------- |--------------------------------------------------------------------------------------------------------------------| -| [telemint](https://github.com/TelegramMessenger/telemint)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/TelegramMessenger/telemint&name=telemint) | Telegram Usenames(`nft-item.fc`) and Telegram Numbers(`nft-item-no-dns.fc`) contracts. | -| [WTON](https://github.com/TonoxDeFi/WTON)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/TonoxDeFi/WTON&name=WTON) | This smart contract provides an implementation of wrapped toncoin, called WTON | -| [capped-fungible-token](https://github.com/TonoxDeFi/capped-fungible-token)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/TonoxDeFi/capped-fungible-token&name=capped-fungible-token) | Basic implementation of smart contracts for Jetton wallet and Jetton minter | -| [getgems-io/nft-contracts](https://github.com/getgems-io/nft-contracts/tree/main/packages/contracts/sources)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/getgems-io/nft-contracts/tree/main/packages/contracts/sources&name=getgems-io/nft-contracts) | Getgems NFT Contracts | -| [lockup-wallet-deployment](https://github.com/ton-defi-org/lockup-wallet-deployment)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/ton-defi-org/lockup-wallet-deployment&name=lockup-wallet-deployment) | Deploy and run lockup Contract end to end | -| [wton-contract](https://github.com/ton-community/wton-contract)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/ton-community/wton-contract&name=wton-contract) | wTON contracts | -| [contract-verifier-contracts](https://github.com/ton-community/contract-verifier-contracts)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/ton-community/contract-verifier-contracts&name=contract-verifier-contracts) | Sources registry contracts which stores an on-chain proof per code cell hash. | -| [vanity-contract](https://github.com/ton-community/vanity-contract)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/ton-community/vanity-contract&name=vanity-contract) | Smart contract that allows to "mine" any suitable address for any contract. | -| [ton-config-smc](https://github.com/ton-foundation/ton-config-smc)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/ton-foundation/ton-config-smc&name=ton-config-smc) | Simple contract for storing versioned data in TON Blockchain. | -| [ratelance](https://github.com/ProgramCrafter/ratelance/tree/main/contracts/func)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/ProgramCrafter/ratelance/tree/main/contracts/func&name=ratelance) | Ratelance is freelance platform that seeks to remove barriers between potential employers and workers. | -| [logger.fc](https://github.com/tonwhales/ton-contracts/blob/master/contracts/logger.fc)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/tonwhales/ton-contracts/blob/master/contracts/logger.fc&name=logger.fc) | Contract that saves data in the local storage. | -| [ton-nominators](https://github.com/tonwhales/ton-nominators)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/tonwhales/ton-nominators&name=ton-nominators) | Ton Whales Nominator pool source code. | -| [ton-link-contract-v3](https://github.com/ton-link/ton-link-contract-v3)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/ton-link/ton-link-contract-v3&name=ton-link-contract-v3) | Ton-link allows smart contracts to access data outside of the blockchain while maintaining data security. | -| [delab-team/fungible-token](https://github.com/delab-team/contracts/tree/main/fungible-token)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/delab-team/contracts/tree/main/fungible-token&name=delab-team/fungible-token) | DeLab TON fungible-token implementation | -| [whitelisted-wallet.fc](https://github.com/tonwhales/ton-contracts/blob/master/contracts/whitelisted-wallet.fc)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/tonwhales/ton-contracts/blob/master/contracts/whitelisted-wallet.fc&name=whitelisted-wallet.fc) | Simple Whitelisted Wallet Contract | -| [delab-team/jetton-pool](https://github.com/delab-team/contracts/tree/main/jetton-pool)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/delab-team/contracts/tree/main/jetton-pool&name=delab-team/jetton-pool) | The Jetton Pool TON smart contract is designed to create farm pools. | -| [ston-fi/contracts](https://github.com/ston-fi/dex-core/tree/main/contracts)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/ston-fi/dex-core/tree/main/contracts&name=ston-fi/contracts) | Stonfi DEX core contracts | -| [onda-ton](https://github.com/0xknstntn/onda-ton)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/0xknstntn/onda-ton&name=onda-ton) | Onda Lending Pool - Core smart contracts of the first lending protocol on TON | -| [ton-stable-timer](https://github.com/ProgramCrafter/ton-stable-timer)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/ProgramCrafter/ton-stable-timer&name=ton-stable-timer) | TON Stable Timer contract | -|[HipoFinance/contract](https://github.com/HipoFinance/contract)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/HipoFinance/contract&name=HipoFinance) | hTON is a decentralized, permission-less, open-source liquid staking protocol on TON Blockchain | +| Contracts | Description | +|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------| +| [telemint](https://github.com/TelegramMessenger/telemint)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/TelegramMessenger/telemint&name=telemint) | Telegram Usenames(`nft-item.fc`) and Telegram Numbers(`nft-item-no-dns.fc`) contracts. | +| [capped-fungible-token](https://github.com/TonoxDeFi/capped-fungible-token)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/TonoxDeFi/capped-fungible-token&name=capped-fungible-token) | Basic implementation of smart contracts for Jetton wallet and Jetton minter | +| [gusarich-airdrop](https://github.com/Gusarich/airdrop/tree/main/contracts) | Implementation of a Scalable Airdrop System for the TON blockchain. It can be used to distribute Jettons on-chain to any number of wallets. | +| [getgems-io/nft-contracts](https://github.com/getgems-io/nft-contracts/tree/main/packages/contracts/sources)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/getgems-io/nft-contracts/tree/main/packages/contracts/sources&name=getgems-io/nft-contracts) | Getgems NFT Contracts | +| [lockup-wallet-deployment](https://github.com/ton-defi-org/lockup-wallet-deployment)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/ton-defi-org/lockup-wallet-deployment&name=lockup-wallet-deployment) | Deploy and run lockup Contract end to end | +| [WTON](https://github.com/TonoxDeFi/WTON)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/TonoxDeFi/WTON&name=WTON) | This smart contract provides an implementation of wrapped toncoin, called WTON | +| [wton-contract](https://github.com/ton-community/wton-contract)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/ton-community/wton-contract&name=wton-contract) | wTON contracts | +| [contract-verifier-contracts](https://github.com/ton-community/contract-verifier-contracts)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/ton-community/contract-verifier-contracts&name=contract-verifier-contracts) | Sources registry contracts which stores an on-chain proof per code cell hash. | +| [vanity-contract](https://github.com/ton-community/vanity-contract)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/ton-community/vanity-contract&name=vanity-contract) | Smart contract that allows to "mine" any suitable address for any contract. | +| [ton-config-smc](https://github.com/ton-foundation/ton-config-smc)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/ton-foundation/ton-config-smc&name=ton-config-smc) | Simple contract for storing versioned data in TON Blockchain. | +| [ratelance](https://github.com/ProgramCrafter/ratelance/tree/main/contracts/func)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/ProgramCrafter/ratelance/tree/main/contracts/func&name=ratelance) | Ratelance is freelance platform that seeks to remove barriers between potential employers and workers. | +| [logger.fc](https://github.com/tonwhales/ton-contracts/blob/master/contracts/logger.fc)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/tonwhales/ton-contracts/blob/master/contracts/logger.fc&name=logger.fc) | Contract that saves data in the local storage. | +| [ton-nominators](https://github.com/tonwhales/ton-nominators)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/tonwhales/ton-nominators&name=ton-nominators) | Ton Whales Nominator pool source code. | +| [ton-link-contract-v3](https://github.com/ton-link/ton-link-contract-v3)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/ton-link/ton-link-contract-v3&name=ton-link-contract-v3) | Ton-link allows smart contracts to access data outside of the blockchain while maintaining data security. | +| [delab-team/fungible-token](https://github.com/delab-team/contracts/tree/main/fungible-token)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/delab-team/contracts/tree/main/fungible-token&name=delab-team/fungible-token) | DeLab TON fungible-token implementation | +| [whitelisted-wallet.fc](https://github.com/tonwhales/ton-contracts/blob/master/contracts/whitelisted-wallet.fc)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/tonwhales/ton-contracts/blob/master/contracts/whitelisted-wallet.fc&name=whitelisted-wallet.fc) | Simple Whitelisted Wallet Contract | +| [delab-team/jetton-pool](https://github.com/delab-team/contracts/tree/main/jetton-pool)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/delab-team/contracts/tree/main/jetton-pool&name=delab-team/jetton-pool) | The Jetton Pool TON smart contract is designed to create farm pools. | +| [ston-fi/contracts](https://github.com/ston-fi/dex-core/tree/main/contracts)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/ston-fi/dex-core/tree/main/contracts&name=ston-fi/contracts) | Stonfi DEX core contracts | +| [onda-ton](https://github.com/0xknstntn/onda-ton)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/0xknstntn/onda-ton&name=onda-ton) | Onda Lending Pool - Core smart contracts of the first lending protocol on TON | +| [ton-stable-timer](https://github.com/ProgramCrafter/ton-stable-timer)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/ProgramCrafter/ton-stable-timer&name=ton-stable-timer) | TON Stable Timer contract | +| [HipoFinance/contract](https://github.com/HipoFinance/contract)
🪄 [Run in WebIDE](https://ide.nujan.io/?importURL=https://github.com/HipoFinance/contract&name=HipoFinance) | hTON is a decentralized, permission-less, open-source liquid staking protocol on TON Blockchain | ### Learning Contracts diff --git a/docs/develop/smart-contracts/tutorials/wallet.md b/docs/develop/smart-contracts/tutorials/wallet.md index 8476dfd8f9..c0f9560f95 100644 --- a/docs/develop/smart-contracts/tutorials/wallet.md +++ b/docs/develop/smart-contracts/tutorials/wallet.md @@ -2416,7 +2416,9 @@ log.Println("Contract address:", contractAddress.String()) // Output contract -Everything we have detailed above follows the same steps as the contract [deployment via wallet](/develop/smart-contracts/tutorials/wallet#contract-deployment-via-wallet) section. To better analyze the fully functional code, please visit the repository indicated at the beginning of the tutorial where all sources are stored. +:::caution +Everything we have detailed above follows the same steps as the contract [deployment via wallet](/develop/smart-contracts/tutorials/wallet#contract-deployment-via-wallet) section. To better understanding, read the entire [GitHub source code]((https://github.com/aSpite/wallet-tutorial)). +::: ### Sending High-Load Wallet Transactions diff --git a/docs/learn/academy/academy-overview.md b/docs/learn/academy/academy-overview.md new file mode 100644 index 0000000000..ab1b166a19 --- /dev/null +++ b/docs/learn/academy/academy-overview.md @@ -0,0 +1,15 @@ +# Educational Resources + + +## TON Blockchain Course + +:::danger +Page under the development. +::: + + +## See Also + +* [Speedrun TON](https://tonspeedrun.com/) +* [TON Hello World](https://tonhelloworld.com/01-wallet/) +* [[YouTube] TON Dev Study EN ](https://www.youtube.com/@TONDevStudy)[[RU]](https://www.youtube.com/results?search_query=tondevstudy) \ No newline at end of file diff --git a/docs/learn/overviews/addresses.md b/docs/learn/overviews/addresses.md index 456204ad43..ddfb53fd85 100644 --- a/docs/learn/overviews/addresses.md +++ b/docs/learn/overviews/addresses.md @@ -173,3 +173,7 @@ Additionally, there are two ways to convert user-friendly and raw addresses for It's also possible to make use of similar mechanisms using [SDKs](/develop/dapps/apis/sdk). +### Address Examples + +Learn more examples on TON Addresses in the [TON Cookbook](/develop/dapps/cookbook#working-with-contracts-addresses). + diff --git a/docs/participate/network-maintenance/custom-overlays.md b/docs/participate/network-maintenance/custom-overlays.md new file mode 100644 index 0000000000..ddb6d28717 --- /dev/null +++ b/docs/participate/network-maintenance/custom-overlays.md @@ -0,0 +1,94 @@ +# Custom overlays + +TON `v2024.04` update introduces the ability to use custom overlays. +Currently they can be used only for broadcasting external messages. The main idea is to create private overlay with +sender nodes and validators. Only sender nodes can create broadcasts with external messages which will be (hopefully) +received by block collator and get into the block. + +## Default custom overlays + +Mytonctrl uses default custom overlays available at https://ton-blockchain.github.io/fallback_custom_overlays.json. To +stop participation in default custom overlays run commands +```bash +MyTonCtrl> set useDefaultCustomOverlays false +MyTonCtrl> delete_custom_overlay default +``` + +## Create custom overlay + +### Collect adnl addresses + +To add validators to a custom overlay you can use either their `fullnode adnl id` available with `validator-console -c getconfig` +or `validator adnl id` which can be found in mytonctrl's status. +To add liteservers to a custom overlay you must use their `fullnode adnl id`. + +### Create a config file + +Create a config file in format: + +```json +{ + "adnl_address_hex_1": { + "msg_sender": true, + "msg_sender_priority": 1 + }, + "adnl_address_hex_2": { + "msg_sender": false + }, + ... +} +``` + +`msg_sender_priority` determines the order of external message inclusion to blocks: first processed messages from higher priority source. Messages from public overlay and local LS have priority 0. + +**Note, all nodes listed in config should participate in overlay (in other words they need to add overlay with exactly this config), otherwise connectivity will be poor and broadcasts will fail** + +There is special word `@validators` to create a dynamic custom overlay that mytonctrl will generate automatically +each round adding all current validators. + +### Add custom overlay + +Use mytonctrl command to add custom overlay: + +```bash +MyTonCtrl> add_custom_overlay +``` + +Note, that name and config file **must** be the same on all overlay members. Check that overlay has been created using +mytonctrl `list_custom_overlays` command. + +### Debug + +You can set node verbosity level equals to 4 and grep logs with "CustomOverlay" word. + +## Delete custom overlay + +To remove custom overlay from a node, use mytonctrl command `delete_custom_overlay `. +If the overlay is dynamic (i.e. there is `@validators` word in config) it will be deleted within one minute, otherwise it will be removed instantly. +To make sure that node has deleted custom overlay check `list_custom_overlays` mytonctrl and `showcustomoverlays` validator-console commands. + +## Low level + +List of validator-console commands to work with custom overlays: + +* `addcustomoverlay ` - add custom overlay to local node. Note, that this config must be in a format other than config for mytonctrl: + ```json + { + "name": "OverlayName", + "nodes": [ + { + "adnl_id": "adnl_address_b64_1", + "msg_sender": true, + "msg_sender_priority": 1 + }, + { + "adnl_id": "adnl_address_b64_2", + "msg_sender": false + }, ... + ] + } + ``` +* `delcustomoverlay ` - delete custom overlay from node. +* `showcustomoverlays` - show list of custom overlays node knows about. + + diff --git a/docs/participate/run-nodes/full-node.mdx b/docs/participate/run-nodes/full-node.mdx index cd9e58e1d0..12570bfb74 100644 --- a/docs/participate/run-nodes/full-node.mdx +++ b/docs/participate/run-nodes/full-node.mdx @@ -575,6 +575,31 @@ tail -f /var/ton-work/log.thread* This section contains answers to the most frequently asked questions about running nodes. + +### Failed to get account state + +``` +Failed to get account state +``` + +This error means that there are issues during search for this account in shard state. +Most probably it means that liteserver node is syncing too slow, in particular the Masterchain synchronisation overtook shardchains (Basechain) synchronisation. In this case node knows the recent Masterchain block but can not check account state in recent shardchain block and returns Failed to get account state. + + +### Failed to unpack account state + +``` +Failed to unpack account state +``` +This error means that requested account doesn't exist in current state. That means that this account is simultaneously is not deployed AND has zero balance + +### Cannot apply external message to current state : External message was not accepted + +``` +Cannot apply external message to current state : External message was not accepted +``` +This error means that contract didn't accepted external message. You need to find exitcode in trace. -13 means that account doesn't have enough TON to accept message (or it requires more than gas_credit). In case of wallet contracts exitcode=33 means wrong seqno (probably seqno data you use is outdatd), exitcode=34 means wrong subwallet_id (for old wallets v1/v2 it means wrong signature), exitcode=35 means that either message is expired or signature is wrong. + ### What does Error 651 mean? `[Error : 651 : no nodes]` indicates that your node cannot locate another node within the TON Blockchain. diff --git a/docusaurus.config.js b/docusaurus.config.js index f50d7d64c5..94667bb298 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -265,6 +265,14 @@ const config = { to: '/develop/overview', label: 'Start with Onboarding Tutorials', }, + { + to: '/develop/dapps/tutorials/jetton-minter', + label: 'Mint your Tokens', + }, + { + to: '/develop/dapps/tutorials/collection-minting', + label: 'Mint your NFTs', + }, { to: '/develop/dapps/telegram-apps/', label: 'Build your first Mini App', @@ -273,10 +281,6 @@ const config = { to: '/develop/dapps', label: 'Dive into DApps Development', }, - { - to: '/develop/dapps/tutorials/jetton-minter', - label: 'Mint your first Token (Jetton)', - }, ], }, { @@ -290,20 +294,20 @@ const config = { label: 'APIs and SDKs', }, { - to: '/develop/dapps/cookbook', - label: 'Common Tasks Cookbook', + to: 'develop/dapps/asset-processing', + label: 'Asset Processing', }, { - to: '/develop/dapps/cookbook-diagram', - label: 'Common Tasks Scheme', + to: 'develop/dapps/asset-processing/jettons', + label: 'Jetton Processing', }, { - to: '/develop/dapps/telegram-apps/', - label: 'Working in Telegram', + to: '/develop/dapps/cookbook', + label: 'Cookbook', }, { - to: 'develop/dapps/asset-processing', - label: 'Advanced Asset Holding', + to: '/develop/dapps/telegram-apps/', + label: 'TMA Development', }, ], }, diff --git a/i18n/mandarin/docusaurus-plugin-content-docs/current/participate/run-nodes/full-node.mdx b/i18n/mandarin/docusaurus-plugin-content-docs/current/participate/run-nodes/full-node.mdx index 7ef3668601..9b65b30d74 100644 --- a/i18n/mandarin/docusaurus-plugin-content-docs/current/participate/run-nodes/full-node.mdx +++ b/i18n/mandarin/docusaurus-plugin-content-docs/current/participate/run-nodes/full-node.mdx @@ -603,7 +603,7 @@ __答:__ 不。您需要检查mytonctrl中的“Local validator out of sync” 推荐的解决方案是再次使用新转储重新安装`MyTonCtrl`。 ::: -如果同步花费异常长的时间,可能是转储出现了问题。请[联系我们](https://t.me/SwiftAdviser)寻求帮助。 +如果同步花费异常长的时间,可能是转储出现了问题。请[联系我们](https://t.me/alexgton)寻求帮助。 请以您安装的用户身份运行`mytonctrl`。 diff --git a/sidebars.js b/sidebars.js index fe8de47149..8fff37021b 100644 --- a/sidebars.js +++ b/sidebars.js @@ -21,6 +21,25 @@ const sidebars = { 'type': 'html', 'value': '
', }, + { + 'type': 'html', + 'value': ' TON Academy ', + }, + { + type: 'category', + label: 'Learn', + items: [ + { + type: 'doc', + label: 'Overview', + id: 'learn/academy/academy-overview', + }, + ] + }, + { + 'type': 'html', + 'value': '
', + }, { 'type': 'html', 'value': ' TON Concepts ', @@ -335,6 +354,7 @@ const sidebars = { label: 'Advanced Asset Holding', items: [ 'develop/dapps/asset-processing/README', + 'develop/dapps/asset-processing/address-verification', 'develop/dapps/asset-processing/jettons', 'develop/dapps/asset-processing/nfts', 'develop/dapps/asset-processing/metadata', @@ -641,6 +661,7 @@ const sidebars = { 'participate/network-maintenance/nominators', 'participate/network-maintenance/persistent-states', 'participate/nodes/collators', + 'participate/network-maintenance/custom-overlays', ], }, { diff --git a/src/theme/Footer/config.ts b/src/theme/Footer/config.ts index aae74d35c8..cd7b171f68 100644 --- a/src/theme/Footer/config.ts +++ b/src/theme/Footer/config.ts @@ -53,7 +53,7 @@ const BRIDGE_URL = "https://bridge.ton.org"; const DNS_URL = "https://dns.ton.org/"; const CAREERS_URL = "https://jobs.ton.org/jobs"; const BUG_BOUNTY_URL = "https://github.com/ton-blockchain/bug-bounty"; -const TON_OVERFLOW_URL = "https://answers.ton.org"; +const TON_OVERFLOW_URL = "https://tonresear.ch"; const TON_CONCEPT_URL = "https://docs.ton.org/learn/introduction"; const TON_FOOTSTEPS = "https://github.com/ton-society/ton-footsteps"; const TON_BLOG_PRESS_RELEASES_URL = "https://blog.ton.org/category/news"; diff --git a/static/example-code-snippets/pythoniq/jetton-offline-address-calc-wrapper.py b/static/example-code-snippets/pythoniq/jetton-offline-address-calc-wrapper.py new file mode 100644 index 0000000000..afdb56221a --- /dev/null +++ b/static/example-code-snippets/pythoniq/jetton-offline-address-calc-wrapper.py @@ -0,0 +1,70 @@ +from pytoniq_core import Address, Cell, begin_cell + + +def calculate_jetton_address( + owner_address: Address, jetton_master_address: Address, jetton_wallet_code: str +): + # Recreate from jetton-utils.fc calculate_jetton_wallet_address() + # https://tonscan.org/jetton/EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs#source + + data_cell = ( + begin_cell() + .store_uint(0, 4) + .store_coins(0) + .store_address(owner_address) + .store_address(jetton_master_address) + .end_cell() + ) + + code_cell = Cell.one_from_boc(jetton_wallet_code) + + state_init = ( + begin_cell() + .store_uint(0, 2) + .store_maybe_ref(code_cell) + .store_maybe_ref(data_cell) + .store_uint(0, 1) + .end_cell() + ) + state_init_hex = state_init.hash.hex() + jetton_address = Address(f'0:{state_init_hex}') + + return jetton_address + + +def print_debug(d: dict): + for k, v in d.items(): + print(f'{k: <25} {v}') + + +if __name__ == '__main__': + # https://docs.ton.org/develop/dapps/cookbook#how-to-calculate-users-jetton-wallet-address-offline + # https://tonviewer.com/EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs?section=method + # Execute "get_jetton_data" and copy last cell value (should be jetton_wallet_code, but they don't match) + jetton_wallet_code = 'b5ee9c72010101010023000842028f452d7a4dfd74066b682365177259ed05734435be76b5fd4bd5d8af2b7c3d68' + + # USDT contract + jetton_master_address = Address('EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs') + + # User address + owner_address = Address('UQANCZLrRHVnenvs31J26Y6vUcirln0-6zs_U18w93WaN2da') + + debug = { + 'jetton_master_address': jetton_master_address.to_str(), + 'owner_address': owner_address.to_str(is_bounceable=False), + } + + jetton_address_calc = calculate_jetton_address( + owner_address, jetton_master_address, jetton_wallet_code + ) + jetton_address_calc_str = jetton_address_calc.to_str( + is_user_friendly=True, is_url_safe=True, is_bounceable=False + ) + debug['jetton_address calc'] = jetton_address_calc_str + + jetton_addr_by_node = 'UQAXgYVGR0rl2az6qPJcPlxFyiNKPCQckoI2ZXaGxLnWJGUf' + debug['jetton_address by_node'] = jetton_addr_by_node + + debug['match'] = jetton_addr_by_node == jetton_address_calc_str + + print_debug(debug) \ No newline at end of file