grants-and-bounties
grants-and-bounties copied to clipboard
TON Cookbook of Contract Wrappers
Summary
This Bounty aims to make a TON Cookbook with clear examples and recipes for interacting with contracts using various TON libraries, specifically @ton.js and tonweb for the TWA and DApps section in the docs.ton.org documentation.
Ton Bounty was created with the help of @footsteps_helper_bot.
Wanted Designed and Applied
Description | Сomplexity | Libraries |
---|---|---|
Jetton transfer with a comment | easy | ~~Tonweb~~, ~~ton.js~~, ~~Pythoniq~~, tonutils, ton-kotlin ,TonSDK.NET |
~~Processing Snake Cells~~ | easy | ~~Tonweb~~ |
Sending a swap message to DEX (e.g., ston.fi, dedust.io). | hard | ~~Tonweb~~, ~~ton.js~~, ~~Pythoniq~~, tonutils, ~~ton-kotlin~~ ,TonSDK.NET |
Processing swap transactions from DEX (e.g., ston.fi, dedust.io). | very hard | ~~Tonweb~~, ~~ton.js~~, Pythoniq, tonutils, ton-kotlin, TonSDK.NET |
Providing a complete formula for fee calculation (simplest examples: transfer ton, transfer jetton). | hard | Tonweb, ton.js, Pythoniq, tonutils, ton-kotlin, TonSDK.NET |
Calculating a user’s Jetton wallet address. | easy | Tonweb, ~~ton.js~~, ~~Pythoniq~~, tonutils, ~~ton-kotlin~~, TonSDK.NET |
Sending a standard TON transfer message. | easy | Tonweb, ~~ton.js~~, ~~Pythoniq~~, tonutils, ~~ton-kotlin~~, TonSDK.NET |
Processing a standard TON transfer message. | easy | Tonweb, ton.js, Pythoniq, tonutils, ton-kotlin, TonSDK.NET |
Parsing transactions for basic operations, recognize type (most common example provided) | hard | ~~Tonweb~~, ~~ton.js~~, ~~Pythoniq~~, tonutils, TonSDK.NET |
(Low level) Parsing blockchain blocks. | hard | Tonweb, ton.js, Pythoniq, tonutils, ton-kotlin, TonSDK.NET |
Parsing dicts(jetton metadata and general case) | easy | Tonweb, ton.js, Pythoniq, tonutils, ton-kotlin, TonSDK.NET |
Calculate tx and msg hashes | easy | Tonweb, ton.js, Pythoniq, tonutils, ton-kotlin, TonSDK.NET |
Rewrite withdraw jettons highload v3 batched Tonweb | very hard | Pythoniq, tonutils, ton4j |
Rewrite withdraw ton highload v3 batched Tonweb | very hard | Pythoniq, tonutils, ton4j |
Context
In the field of development, cookbooks are valuable resources that provide actionable tips and tricks for executing certain concepts. Unified examples of contract wrappers will make a smoother and easier learning and development process of TWAs and DApps in TON Ecosystem.
Goals
-
Prepare examples for the TON Cookbook containing recipes that address frequently asked questions and common tasks related to interaction with a contract.
-
Cover with examples all frequency and repeatable questions.
-
Oriental Release Date: 2 weeks after the list of examples was approved.
-
As an initial set of examples, the following groups of questions can be used:
- "How to interact with <type> entity?"
- "How to retrieve and use specific data for various get method of <a specific generic or custom contract>?"
- "How to define the success of the incoming transactions for <a specific generic or a custom contract>?"
- "How to deserialize and handle different messages"
- Generic contracts are: Wallet, SBT, NFT, Jetton, DNS (could be added on recommendation)
-
Examples should cover part, that was not explained in libraries examples: Tonweb or should be improved significantly to be considered as original examples based on this.
-
Different libraries and languages for the same question should be shown with Tabs.
-
Recommended libraries for JS languages:
-
Recommended libraries for additional languages:
- Python - pythoniq (low-level), Tontools (high-level);
- Java - ton4j;
- Kotlin - ton-kotlin;
- GO - tonutils;
- C# - TonSDK.NET
Deliverables
- Cookbook containing clear examples and recipes for using JS (ton JS and tonweb libraries) Python, GO, C# languages to interact with TON contracts.
- Simplified process of basic logic implementation for DApps and TWAs.
Definition of Done
- This footstep aims to create a useful cookbook for TON Ecosystem. For each participant award will be paid after PR with his examples will be merged to docs.ton.org.
For clearness of the moderation process, declare for each set of examples the following steps:
- Participants declare a list of names and a brief description of examples(1-3 pcs)
- The list of examples should be pre-reviewed briefly by an expert TON contributor and approve this list.
- Participants create examples and add them with a PR to ton.docs.org.
- Ready-made PR to docs with examples reviewed again by a tech expert.
- @Gusarich (js)
- @aSpite (js)
- @andreypfau (Kotlin)
- @yungwine (Python)
Estimated Reward
- [x] - Processing Snake Cells + 8 examples - tonweb @aSpite (325$)
- [x] - Parsing transactions for basic operations - ton.js @Gusarich (50$)
- [x] - Calculating a user's Jetton wallet address - ton-kotlin @LevZed - (25$)
- [x] - Sending a standard TON transfer message - ton-kotlin @LevZed - (25$)
- [x] - Sending a swap message to DEX(dedust) - ton-kotlin @LevZed - (100$)
- [x] - Jetton transfer with a comment. pytoniq @shibdev - (25$)
- [x] - Calculating a user’s Jetton wallet address. - pytoniq @shibdev - (25$)
- [x] - Sending a standard TON transfer message. - pytoniq @shibdev - (25$)
- [x] - Parsing transactions for basic operations - pytoniq @shibdev - (50$)
- [x] - Sending a swap message to dedust.io - pytoniq @shibdev - (50$)
- [x] - Offline jetton address calculation - @ton/ton @aSpite - (50$)
- [ ] - Rewrite withdraw ton highload v3 batched Tonweb - pytoniq @shibdev - (150$)
- [ ] - Rewrite withdraw jettons highload v3 batched Tonweb - pytoniq @shibdev - (150$)
- [x] - Sending a swap message to DEX @mbaneshi - ton.js - (50$)
- [ ] - Sending a swap message to DEX @??? - tonweb - (100$)
- [ ] - Processing swap transactions from DEX @??? ton.js and tonweb - (100$)
Reward Distribution Rules
- Successful completion of basic(easy) examples: $25 per example in TON equivalent.
- Successful completion of advanced examples(or using tonweb): $50 per example in TON equivalent.
- Successful completion of very hard examples - determined individually.
- The review compensation for reviewer experts at 10% of the reward for the examples
I'd like to participate
I can help with review if needed
Community, you can join too. The number of executors is not limited!
@Gusarich, great! For me, it's hard to define the fair cost of review. Please, help to define ~oriental cost, it's also could be clarified later.
@reveloper
The price is very high. It won't take an hour to write an example, even if it were something complex. I think it should be changed to 10 and 20. Or a maximum of 15 and 25. It should be borne in mind that many examples are already in the documentation.
UPD: If the examples are detailed, understandable and of high quality, then such a price is justified. I would like to help with the review, if possible.
@aSpite great, added you to expert list. Thank you!
@AndreyBurnosov would you provide the example list you want to prepare?
I haven't thought about this question yet, what kind of examples are needed? @reveloper
@AndreyBurnosov
Each participant can propose a list of examples they would like to explore. These examples can encompass various types of operations and transactions, taking into account the demand.
For instance, you can consider how to parse Jetton metadata using the ton.js library. It's important to consider that this metadata can be off-chain, semi-chain, or on-chain. Therefore, it's necessary to deeply examine each example to provide a highly unique case that would be applicable in the majority of scenarios.
There is a demand within the community for such examples. For instance, a developer might want to send a token with a comment, but they might not understand how to do it. A high-quality Cookbook should address this issue within a minute.
Important: I am not the author of the footstep, so my words are merely a recommendation. @reveloper could provide a more precise answer.
Due to nobody finding this footstep(ton-bounty) interesting at the moment, I asked @aSpite to help us with examples as a participant. I personally asked for 3 examples about addresses(2) and jetton transfer(1), because this is what I need for everyday work.
Dear @Gusarich, We count on your expertise for review.
- How to convert (user friendly <-> raw), assemble, and extract addresses from strings? (JS, Python, Go) - Hard (if all languages at once)
- How to obtain different types of addresses (bounceable, non-bounceable, testnet) and determine the address type based on its user-friendly form? - Hard (if all languages at once)
- How to construct a message for a jetton transfer with a comment? - Easy (ton.js)
- How to use NFT batch deploy? - Hard (ton.js)
- How to change the owner of a collection's smart contract? - Easy (ton.js)
- How to change the content in a collection's smart contract? - Hard (ton.js)
Great, @aSpite, I confirm this list, please prepare the PR.
@Gusarich , @reveloper ,
My examples are ready. PR: https://github.com/ton-community/ton-docs/pull/343
Dear community!
I suggest the following examples:
- Sending a swap message to DEX (e.g., ston.fi, dedust.io). [hard for the first library]
- Processing swap transactions from DEX (e.g., ston.fi, dedust.io). [hard for the first library]
- Providing a complete formula for fee calculation (simplest examples: transfer ton, transfer jetton). [hard]
- Calculating a user’s Jetton wallet address. [easy]
- Sending a standard TON transfer message. [easy]
- Processing a standard TON transfer message. [easy]
- (High level) Parsing transactions for basic operations, recognize type (most common example provided) [hard]
- (Low level) Parsing blockchain blocks. [hard]
- Parsing dicts(jetton metadata and general case)
I kindly remind you to implement examples for ton.js in the first order where this is possible.
I added clarification about recommended libraries in the description of ton bounty.
Recommended libraries for additional languages:
Python - pythoniq-core (low-level), Tontools (high-level); GO - tonutils; C# - TonSDK.NET
@reveloper ,
How to construct a message for a jetton transfer with a comment? - Easy (tonweb)
As 1 easy example: How to change the owner of a collection's smart contract? - Easy (tonweb) How to change the content in a collection's smart contract? - Easy (tonweb)
@Gusarich , @reveloper
Tonweb examples are ready: https://github.com/ton-community/ton-docs/pull/347
@reveloper,
I would like to work on this examples:
@coalus, great! Do you mean ton.js library? Please, add library name in the your list.
1st Iteration: 4 hard at $50 each, which equals $200. 2 easy at $25 each, which equals $50. Total: 250$
2nd Iteration: 2 easy at $25 each, which equals $50. Tonweb examples.
Total: 300$ Wallet: EQDKbjIcfM6ezt8KjKJJLshZJJSqX7XOA4ff-W72r5gqPrHF
The cookbook already has enough examples to understand how they should be done. Therefore, the next contributors can continue without major issues. I would like to continue my work as a reviewer, if it possible, @reveloper .
@aSpite, sure, thank you! Will count on your help with the review.
@coalus, OK, now your list is confirmed.
@Gusarich, great! For me, it's hard to define the fair cost of review. Please, help to define ~oriental cost, it's also could be clarified later.
The review didn't take much time, so I'll be happy with 50$ and TON Footsteps SBT 🙂
My wallet address: sedov.t.me
@Gusarich, let's set the review reward at 10% of the reward for the examples. This will be fair in terms of effort: more complex ones require more effort, and thus merit a bigger reward.
So, for 8 examples from @aSpite valued at $300, we would be pleased to thank you with 10% = $30 + TON Footsteps SBT.
@Gusarich, let's set the review reward at 10% of the reward for the examples. This will be fair in terms of effort: more complex ones require more effort, and thus merit a bigger reward.
So, for 8 examples from @aSpite valued at $300, we would be pleased to thank you with 10% = $30 + TON Footsteps SBT.
Sure!
@Gusarich, let's set the review reward at 10% of the reward for the examples. This will be fair in terms of effort: more complex ones require more effort, and thus merit a bigger reward.
So, for 8 examples from @aSpite valued at $300, we would be pleased to thank you with 10% = $30 + TON Footsteps SBT.
I would like to clarify something. The review process requires not only checking the text but also running and thoroughly testing the execution of the provided examples. For instance, if the example is "batch deploy," the reviewer needs to create a test collection and deploy the NFT. This should all happen quite quickly if the person who wrote the example did everything initially with few errors. Otherwise, the review process may take even more time, considering that each new correction requires reevaluating the code from scratch.
@reveloper ,
I also want to propose a deadline for each new iteration. Otherwise, it's possible that some examples may be delayed for a week.
For example, if it's about changing the owner of a collection, that should take a maximum of 2-3 hours, so the example should be ready within a maximum of 2 days.
@reveloper, is it possible to use dedust sdk to write dex swap example?
@coalus ,
I would personally rather not use the Dedust SDK for a few reasons:
- The SDK already has the needed wrappers and doesn't need a total revamp. It also includes documentation, so it's not hard to work with.
- We not only have Dedust but also Ston.fi, which requires us to provide an example.
- The SDK is only available in JS/TS, so for other languages, we'll need different examples, but they should be as similar as possible.
However, the final decision ultimately belongs to @reveloper .
@coalus ,
I would personally rather not use the Dedust SDK for a few reasons:
- The SDK already has the needed wrappers and doesn't need a total revamp. It also includes documentation, so it's not hard to work with.
- We not only have Dedust but also Ston.fi, which requires us to provide an example.
- The SDK is only available in JS/TS, so for other languages, we'll need different examples, but they should be as similar as possible.
However, the final decision ultimately belongs to @reveloper .
- We can just change status of this task from "hard" to "easy"
- Ston.fi also have their own sdk
- There are already implementation on Python. Most of the products on TON use one of this languages.
My point is that if someone wants to add dedust/ston.fi swap support to their product, it's a bit better to use SDK.
@coalus , I would personally rather not use the Dedust SDK for a few reasons:
- The SDK already has the needed wrappers and doesn't need a total revamp. It also includes documentation, so it's not hard to work with.
- We not only have Dedust but also Ston.fi, which requires us to provide an example.
- The SDK is only available in JS/TS, so for other languages, we'll need different examples, but they should be as similar as possible.
However, the final decision ultimately belongs to @reveloper .
- We can just change status of this task from "hard" to "easy"
- Ston.fi also have their own sdk
- There are already implementation on Python. Most of the products on TON use one of this languages.
My point is that if someone wants to add dedust/ston.fi swap support to their product, it's a bit better to use SDK.
I looked at the Dedust SDK code. There is quite a lot of code and processing details, so I agree that using the SDK would be better. In this case, I would also show the use of the SDK for Ston.fi and leave the task as hard.
@reveloper
@ Missing the example: "How to put on sale telemint NFTs: nft-item-no-dns and nft-item".
I suppose it will be easy because it simple enough message with a payload.