Skip to content

Commit

Permalink
feat: implement guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
a-bahdanau committed Oct 18, 2024
1 parent 7170db3 commit 98ffd5e
Show file tree
Hide file tree
Showing 34 changed files with 142 additions and 80 deletions.
4 changes: 3 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@
"keystream",
"leaderboard",
"leaderboards",
"libmicrohttpd",
"libatomic",
"liteserver",
"liteservers",
"logname",
Expand Down Expand Up @@ -270,7 +272,7 @@
"xlarge",
"xtwitter",
"yourname",
"zerostate",
"zerostate"
],
"ignoreRegExpList": [
"\\(#.*\\)",
Expand Down
2 changes: 1 addition & 1 deletion docs/develop/dapps/cookbook.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ Most SDKs provide the following process for sending messages from your wallet:
- You create wallet wrapper (object in your program) of a correct version (in most cases, v3r2; see also [wallet versions](/participate/wallets/contracts)), using secret key and workchain (usually 0, which stands for [basechain](/v3/concepts/dive-into-ton/ton-blockchain/blockchain-of-blockchains#workchain-blockchain-with-your-own-rules)).
- You also create blockchain wrapper, or "client" - object that will route requests to API or liteservers, whichever you choose.
- Then, you *open* contract in the blockchain wrapper. This means contract object is no longer abstract and represents actual account in either TON mainnet or testnet.
- After that, you can form messages you want and send them. You can also send up to 4 messages per request, as described in an [advanced manual](/develop/smart-contracts/tutorials/wallet#sending-multiple-messages-simultaneously).
- After that, you can form messages you want and send them. You can also send up to 4 messages per request, as described in an [advanced manual](/v3/guidelines/smart-contracts/howto/wallet#sending-multiple-messages-simultaneously).

<Tabs groupId="code-examples">
<TabItem value="js-ton-v4" label="JS (@ton) for Wallet V4">
Expand Down
2 changes: 1 addition & 1 deletion docs/develop/func/cookbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ if (current_time > 1672080143) {
:::caution draft
Please note that this method of generating random numbers isn't safe.

Checkout [Random Number Generation](https://docs.ton.org/develop/smart-contracts/guidelines/random-number-generation) for more information.
Checkout [Random Number Generation](https://docs.ton.org/v3/guidelines/smart-contracts/security/random-number-generation) for more information.
:::

```func
Expand Down
2 changes: 1 addition & 1 deletion docs/develop/func/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ If you want to use native TON compiler FunC locally you need binaries setup on y

:::info
At the same time you can always make binaries from sources like:
[FunC compiler source code](https://github.com/ton-blockchain/ton/tree/master/crypto/func) (read [how to compile](/develop/howto/compile#func) a FunC compiler from sources).
[FunC compiler source code](https://github.com/ton-blockchain/ton/tree/master/crypto/func) (read [how to compile](/v3/guidelines/smart-contracts/howto/compile/compilation-instructions#func) a FunC compiler from sources).
:::

## TON Course: FunC
Expand Down
2 changes: 1 addition & 1 deletion docs/develop/func/stdlib.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ The pseudo-random number generator uses the random seed, an unsigned 256-bit Int
:::caution
Keep in mind that random numbers generated by the functions below can be predicted if you do not use additional tricks.

- [Random number generation](/develop/smart-contracts/guidelines/random-number-generation)
- [Random number generation](/v3/guidelines/smart-contracts/security/random-number-generation)

:::

Expand Down
2 changes: 1 addition & 1 deletion docs/develop/get-started-with-ton.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ After finishing the TON Onboarding Challenge where we successfully mined an NFT,
* [TON Hello World: Step-by-step guide for writing your first smart contract](https://ton-community.github.io/tutorials/02-contract/)
* [Develop Smart Contracts: Introduction](/develop/smart-contracts/)
* [[YouTube] Ton Dev Study - FunC & Blueprint](https://www.youtube.com/playlist?list=PLyDBPwv9EPsDjIMAF3XqNI2XGNwdcB3sg)
* [How to work with wallet smart contracts](/develop/smart-contracts/tutorials/wallet)
* [How to work with wallet smart contracts](/v3/guidelines/smart-contracts/howto/wallet)
* [FunC Journey: Part 1](https://blog.ton.org/func-journey)
* [Bot for sales of dumplings](/v3/guidelines/dapps/tutorials/telegram-bot-examples/accept-payments-in-a-telegram-bot-js)
* [Mint Your first Jetton](/v3/guidelines/dapps/tutorials/mint-your-first-token)
Expand Down
2 changes: 1 addition & 1 deletion docs/develop/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ Use Blueprint
The following resources provide valuable information for TON smart contract development:

* [TON Hello World: Step-by-step guide for writing your first smart contract](https://ton-community.github.io/tutorials/02-contract/) - An accessible and concise explanation of the fundamentals with JS.
* [How to work with wallet smart contracts](/develop/smart-contracts/tutorials/wallet) - Detailed and careful explanations of smart contract basics with the use of JS and GO.
* [How to work with wallet smart contracts](/v3/guidelines/smart-contracts/howto/wallet) - Detailed and careful explanations of smart contract basics with the use of JS and GO.
* [Learn Smart Contracts by examples](/develop/smart-contracts/examples) (FunC, Fift)
* [Speed Run TON](/develop/smart-contracts/examples) - 6 interactive challenges and step-by-step tutorials to learn smart contracts development.

Expand Down
2 changes: 1 addition & 1 deletion docs/develop/smart-contracts/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ RU

For those who prefer detail and nuance, visit:

* [How to work with wallet smart contracts](/develop/smart-contracts/tutorials/wallet)
* [How to work with wallet smart contracts](/v3/guidelines/smart-contracts/howto/wallet)



Expand Down
2 changes: 1 addition & 1 deletion docs/develop/smart-contracts/environment/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Remember to set the [environment variable](https://stackoverflow.com/questions/1

## Build from source

If you don't want to rely on pre-compiled binaries and prefer to compile the binaries yourself, you can follow the [official instructions](/develop/howto/compile).
If you don't want to rely on pre-compiled binaries and prefer to compile the binaries yourself, you can follow the [official instructions](/v3/guidelines/smart-contracts/howto/compile/compilation-instructions).

The ready-to-use gist instructions are provided below:

Expand Down
2 changes: 1 addition & 1 deletion docs/develop/smart-contracts/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,6 @@ If you want to share a new example smart contract, make your PR for this [page](
## See Also

* [Develop Smart Contracts Introduction](/develop/smart-contracts/)
* [How to work with wallet smart contracts](/develop/smart-contracts/tutorials/wallet)
* [How to work with wallet smart contracts](/v3/guidelines/smart-contracts/howto/wallet)
* [[You Tube] Ton Dev Study FunC & BluePrint lessons](https://www.youtube.com/watch?v=7omBDfSqGfA&list=PLtUBO1QNEKwtO_zSyLj-axPzc9O9rkmYa)

2 changes: 1 addition & 1 deletion docs/develop/smart-contracts/guidelines.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This page collects some recommendations and best practices that could be followe
* [Internal messages](/develop/smart-contracts/guidelines/internal-messages)
* [External messages](/develop/smart-contracts/guidelines/external-messages)
* [Using non-bounceable messages](/develop/smart-contracts/guidelines/non-bouncable-messages)
* [Get-methods](/develop/smart-contracts/guidelines/get-methods)
* [Get-methods](/v3/guidelines/smart-contracts/get-methods)
* ["accept_message" effects](/develop/smart-contracts/guidelines/accept)
* [Paying for processing queries and sending responses](/develop/smart-contracts/guidelines/processing)
* [How and why to shard your TON smart contract. Studying the anatomy of TON's Jettons](https://blog.ton.org/how-to-shard-your-ton-smart-contract-and-why-studying-the-anatomy-of-tons-jettons)
Expand Down
2 changes: 1 addition & 1 deletion docs/develop/smart-contracts/sdk/javascript.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Watch Video Tutorials
## See Also

* [Develop Smart Contract Introduction](/develop/smart-contracts/)
* [How to work with wallet smart contracts](/develop/smart-contracts/tutorials/wallet)
* [How to work with wallet smart contracts](/v3/guidelines/smart-contracts/howto/wallet)
* [Using toncli](/develop/smart-contracts/sdk/toncli)
* [SDKs](/develop/dapps/apis/sdk)

2 changes: 1 addition & 1 deletion docs/develop/smart-contracts/security/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This article needs an update. Please, help us to improve it.
If you are creating a smart contract, then here you can see some examples of what errors can lead you to losing funds:

- [TON Hack Challenge #1](https://github.com/ton-blockchain/hack-challenge-1)
- [Drawing conclusions from TON Hack Challenge](/develop/smart-contracts/security/ton-hack-challenge-1)
- [Drawing conclusions from TON Hack Challenge](/v3/guidelines/smart-contracts/security/ton-hack-challenge-1)

## TON Course: Security

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ This exit code is responsible for most of the errors when working with actions:

### Action Phase | exit code = 35

During the building of the [CommonMsgInfo](/develop/smart-contracts/tutorials/wallet#commonmsginfo) part of the message, you must specify the correct source address. It must be equal to either [addr_none](/develop/data-formats/msg-tlb#addr_none00) or the address of the account that sends the message.
During the building of the [CommonMsgInfo](/v3/guidelines/smart-contracts/howto/wallet#commonmsginfo) part of the message, you must specify the correct source address. It must be equal to either [addr_none](/develop/data-formats/msg-tlb#addr_none00) or the address of the account that sends the message.

In the blockchain code, this is handled by the [check_replace_src_addr](https://github.com/ton-blockchain/ton/blob/9728bc65b75defe4f9dcaaea0f62a22f198abe96/crypto/block/transaction.cpp#L1985).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ To deploy a wallet via TonLib one needs to:
6. Check the contract in a few seconds with [getAccountState](https://github.com/ton-blockchain/ton/blob/master/tl/generate/scheme/tonlib_api.tl#L288) method.

:::tip
Read more in the [Wallet Tutorial](/develop/smart-contracts/tutorials/wallet#-deploying-a-wallet)
Read more in the [Wallet Tutorial](/v3/guidelines/smart-contracts/howto/wallet#-deploying-a-wallet)
:::

### Check the validity of wallet address
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ int seqno() method_id {
}
```

Returns the sequence number of the transaction within a specific wallet. This method is primarily used for [replay protection](/develop/smart-contracts/tutorials/wallet#replay-protection---seqno).
Returns the sequence number of the transaction within a specific wallet. This method is primarily used for [replay protection](/v3/guidelines/smart-contracts/howto/wallet#replay-protection---seqno).

#### get_subwallet_id()

Expand All @@ -80,7 +80,7 @@ int get_subwallet_id() method_id {
}
```

- [What is Subwallet ID?](/develop/smart-contracts/tutorials/wallet#what-is-subwallet-id)
- [What is Subwallet ID?](/v3/guidelines/smart-contracts/howto/wallet#what-is-subwallet-id)

#### get_public_key()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Any kind of wallet contract

### V1

First desing that comes to mind is something like this:
First design that comes to mind is something like this:
- User sends proof to the distributor
- Distributor checks proof and deploys `double spend` contract
- Distributor passes message to the double spend.
Expand All @@ -56,12 +56,12 @@ Looks like a loop is redundant here.

### V2

Linear desing is much better:
Linear design is much better:
- User deploys the `double spend` and it proxies proof to the distributor
- Distributor checks the sending `double spend` address by state init `(distributor_address, user_address?)`
- Distributor checks proof, in this case user index should be part of the proof and releases jettons.
- Distributor sends fee to the fee wallet
**MOAR NAIVE ART**
**MORE NAIVE ART**

## Shard optimizations

Expand Down Expand Up @@ -154,7 +154,7 @@ Should be good to go now!
- Distributor sends fee to the fee wallet
- Distributor checks proof, in this case user index should be part of the proof and releases jettons via jetton wallet in same shard.

**MOAR NAIVE ART**
**MORE NAIVE ART**
Is there anything wrong with that? Let's take a good look.
....
Damn right! There is only one fee wallet, and fees are queueing up to a single shard. That could have been a disaster! (Wondering if it ever happened for real?).
Expand All @@ -163,7 +163,7 @@ Damn right! There is only one fee wallet, and fees are queueing up to a single s
- Same as V3 but 16 wallets now, each in same shard as it's *distributor*.
- Going to have to make *fee wallet* address updatable

**Bit moar art**
**Bit more art**

How about now? LGTM.

Expand All @@ -172,4 +172,4 @@ We always can go even further.
Take a look at a custom [jetton wallet](https://github.com/ton-community/mintless-jetton/blob/main/contracts/jetton-utils.fc#L142) which has a built-in shard optimization.
As a result user's jetton wallet ends up in the same shard as a user with 87% probability.
But that's a fairly uncharted territory yet, so you're on your own.
Good luck with TGE!
Good luck with TGE!
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ cmake -GNinja -DCMAKE_BUILD_TYPE=Release .. \
:::

:::tip
If you are compiling on a computer with low memory (e.g., 1 Gb), don't forget to [create a swap partitions](/develop/howto/compile-swap).
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
Expand All @@ -128,7 +128,7 @@ wget https://ton-blockchain.github.io/testnet-global.config.json

## Lite Client

To build a lite client, do [common part](/develop/howto/compile#common), [download the config](/develop/howto/compile#download-global-config), and then do:
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:

```bash
cmake --build . --target lite-client
Expand All @@ -152,7 +152,7 @@ Basic help info can be obtained by typing `help` into the Lite Client. Type `qui

## FunC

To build FunC compiler from source code, do [common part](/develop/howto/compile#common) described above and then:
To build FunC compiler from source code, do [common part](/v3/guidelines/smart-contracts/howto/compile/compilation-instructions#common) described above and then:

```bash
cmake --build . --target func
Expand All @@ -166,7 +166,7 @@ func -o output.fif -SPA source0.fc source1.fc ...

## Fift

To build Fift compiler from source code, do [common part](/develop/howto/compile#common) described above and then:
To build Fift compiler from source code, do [common part](/v3/guidelines/smart-contracts/howto/compile/compilation-instructions#common) described above and then:

```bash
cmake --build . --target fift
Expand All @@ -180,7 +180,7 @@ fift -s script.fif script_param0 script_param1 ..

## Tonlib-cli

To build tonlib-cli, do [common part](/develop/howto/compile#common), [download the config](/develop/howto/compile#download-global-config) and then do:
To build tonlib-cli, 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:

```bash
cmake --build . --target tonlib-cli
Expand All @@ -196,7 +196,7 @@ Basic help info can be obtained by typing `help` into the tonlib-cli. Type `quit

## RLDP-HTTP-Proxy

To build rldp-http-proxy, do [common part](/develop/howto/compile#common), [download the config](/develop/howto/compile#download-global-config) and then do:
To build rldp-http-proxy, 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:

```bash
cmake --build . --target rldp-http-proxy
Expand All @@ -210,7 +210,7 @@ rldp-http-proxy/rldp-http-proxy

## generate-random-id

To build generate-random-id, do [common part](/develop/howto/compile#common) and then do:
To build generate-random-id, do [common part](/v3/guidelines/smart-contracts/howto/compile/compilation-instructions#common) and then do:

```bash
cmake --build . --target generate-random-id
Expand All @@ -224,7 +224,7 @@ utils/generate-random-id

## storage-daemon

To build storage-daemon and storage-daemon-cli, do [common part](/develop/howto/compile#common) and then do:
To build storage-daemon and storage-daemon-cli, do [common part](/v3/guidelines/smart-contracts/howto/compile/compilation-instructions#common) and then do:

```bash
cmake --build . --target storage-daemon storage-daemon-cli
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: At the end of this guide you will deploy multisig wallet and send s
# Interact with multisig wallets using TypeScript

## Introduction
If you don't know what is multisig wallet in TON, you can check it out [here](/develop/smart-contracts/tutorials/multisig)
If you don't know what is multisig wallet in TON, you can check it out [here](/v3/guidelines/smart-contracts/howto/multisig)

Following this steps you will learn how to:
* Create and deploy multisig wallet
Expand Down Expand Up @@ -159,6 +159,6 @@ And of course you can get public properties from `MultisigWallet`, `MultisigOrde
- `signatures` - `Dictionary<number, Buffer>` of signatures *ownerId => signature*

## References
* [Low-level multisig guide](/develop/smart-contracts/tutorials/multisig)
* [Low-level multisig guide](/v3/guidelines/smart-contracts/howto/multisig)
* [ton.js Documentation](https://ton-community.github.io/ton/)
* [Multisig contract sources](https://github.com/ton-blockchain/multisig-contract)
Loading

0 comments on commit 98ffd5e

Please sign in to comment.