-
Notifications
You must be signed in to change notification settings - Fork 7
feat: add processing overview #1007
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
efc9b52
add stub
Kaladin13 3bed545
more and links
Kaladin13 b0ca0fb
stubs
Kaladin13 8c81b62
Merge branch 'main' into processing-overview
Kaladin13 091b48f
spell
Kaladin13 6acc884
Merge remote-tracking branch 'origin/processing-overview' into proces…
Kaladin13 3486e4d
Dewater
verytactical a6dc217
Dewater2
verytactical 8738a89
Merge branch 'main' into processing-overview
verytactical 6f92d4a
Update payments/overview.mdx
verytactical cfee7e7
formatting
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| title: "Jettons payments processing" | ||
| sidebarTitle: "Jettons" | ||
| --- | ||
|
|
||
| import { Stub } from '/snippets/stub.jsx'; | ||
|
|
||
| <Stub issue="700" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| --- | ||
| title: "Payment processing overview" | ||
| sidebarTitle: "Overview" | ||
| --- | ||
|
|
||
| Payment processing on TON refers to monitoring and handling blockchain transactions for business applications. While simple use cases can rely entirely on smart contracts, most real-world payment systems require off-chain processing to track deposits, manage user balances, send confirmations, and integrate with existing business logic. | ||
|
|
||
| ## On-chain vs off-chain processing | ||
|
|
||
| On-chain processing executes all payment logic within smart contracts. When a user sends TON or Jettons to a contract, the contract immediately processes the payment and updates state. This works for simple scenarios like direct peer-to-peer transfers or automated market makers, but becomes impractical when you need user accounts, payment history, refunds, or integration with external systems. | ||
|
|
||
| Off-chain processing monitors blockchain state changes from outside the network. Your application observes transactions, verifies their validity, updates internal databases, and triggers business logic. Exchanges, merchants, and payment processors use this approach because it provides flexibility to implement complex workflows, maintain user data, and integrate with traditional systems. | ||
|
|
||
| ## Transaction finality | ||
|
|
||
| TON achieves transaction finality after a single masterchain block confirmation, typically within 5 seconds. Once a transaction from a shardchain appears in a masterchain block, it becomes irreversible. This differs from blockchains like Ethereum where merchants wait for multiple confirmations (usually 12-15 blocks, taking 2-3 minutes) or Bitcoin where 6 confirmations are standard (about 60 minutes). | ||
|
|
||
| The masterchain coordinates all workchain activity and produces blocks approximately every 5 seconds. When monitoring payments, you need to verify that the transaction was included in a masterchain block rather than just in a shardchain. Most TON APIs provide methods to check whether a transaction has achieved masterchain finality or, better yet, only consider transaction included in masterchain as finalized by the network. | ||
|
|
||
| ## Supported assets | ||
|
|
||
| TON supports several asset types for payment processing: | ||
|
|
||
| **Toncoin** is the native currency of the network. Every wallet can receive Toncoins directly without additional setup. Transfers are simple value transfers between addresses, making Toncoin the easiest asset to process. | ||
|
|
||
| [**Jettons**](/standard/tokens/jettons/overview) are fungible tokens following the TON Enhancement Proposal 74 (TEP-74) standard. Each Jetton type has a master contract and individual wallet contracts for each holder. When processing Jetton payments, you monitor the Jetton wallet contract associated with your deposit address. Transfer notifications include sender information and transfer amounts. | ||
|
|
||
| Read more about [how Jettons work](/standard/tokens/jettons/how-it-works). | ||
|
|
||
| - [Toncoin processing](/payments/toncoin) | ||
| - [Jetton processing](/payments/jettons) | ||
|
|
||
| ## Implementation approaches | ||
|
|
||
| Three main approaches exist for implementing payment processing on TON: | ||
|
|
||
| **Self-built solution**: You run your own service that connects to some TON API or [liteserver](/ecosystem/rpc/overview), monitors blocks for relevant transactions, and maintains a database of payment events. This requires building infrastructure to fetch blocks, parse transactions, handle reconnections, and manage state. The advantage is complete control over the implementation and no dependency on external services. The disadvantage is significant development and maintenance effort. | ||
|
|
||
| **Self-hosted payment processor**: Open-source payment processors like [Bicycle](https://github.com/gobicycle/bicycle) provide ready-to-deploy solutions that handle blockchain monitoring and expose APIs for your application. You deploy the processor on your infrastructure, configure it for your wallet addresses and asset types, and consume its API to track payments. This balances control with reduced development effort, though you still manage the infrastructure. | ||
|
|
||
| **Third-party payment processor**: External services handle all blockchain interaction and provide simple APIs or webhooks for payment notifications. You integrate their SDK or API, and they manage infrastructure, monitoring, and maintenance. This is fastest to implement but introduces dependency on the service provider and typically involves transaction fees. | ||
|
|
||
| The choice depends on your requirements for control, development resources, and operational complexity. High-volume applications often build custom solutions, while smaller merchants prefer third-party services. | ||
|
|
||
| ## Monitoring payments | ||
|
|
||
| Payment monitoring requires polling for new blocks and filtering transactions that affect your addresses. For Toncoins, you check for incoming messages to your wallet address. For Jettons, you monitor the Jetton wallet contract associated with your address for transfer notifications. | ||
|
|
||
| The typical monitoring flow involves fetching the latest workchain blocks, retrieving all transactions from them, filtering for transactions involving your addresses, parsing transaction data to extract amounts and metadata, verifying the transaction reached finality, and updating your internal payment records. | ||
|
|
||
| Most applications poll for new blocks every few seconds. More sophisticated systems use multiple strategies: polling for recent data, webhooks from indexing services for real-time notifications, and periodic reconciliation to catch any missed transactions. | ||
verytactical marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| title: "Toncoin payments processing" | ||
| sidebarTitle: "Toncoin" | ||
| --- | ||
|
|
||
| import { Stub } from '/snippets/stub.jsx'; | ||
|
|
||
| <Stub issue="204" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -628,6 +628,7 @@ pytoniq | |
| queryable | ||
| ragpull | ||
| recv | ||
| reconnections | ||
| redeclaration | ||
| redeclared | ||
| redistributable | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.