Skip to content

Conversation

@Kaladin13
Copy link
Collaborator

Closes #204

@github-actions
Copy link

github-actions bot commented Nov 5, 2025

To fix the formatting issues:

  1. Install necessary dependencies: npm ci
  2. Then, run this command:
npx remark -o --silent --silently-ignore payments/toncoin.mdx 

@github-actions
Copy link

github-actions bot commented Nov 6, 2025

To fix the formatting issues:

  1. Install necessary dependencies: npm ci
  2. Then, run this command:
npx remark -o --silent --silently-ignore payments/toncoin.mdx 

@Kaladin13
Copy link
Collaborator Author

/review

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the thoughtful update — I left a couple of suggestions in payments/toncoin.mdx; please apply the inline suggestions.

Kaladin13 and others added 2 commits November 6, 2025 13:51
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@github-actions
Copy link

github-actions bot commented Nov 6, 2025

To fix the formatting issues:

  1. Install necessary dependencies: npm ci
  2. Then, run this command:
npx remark -o --silent --silently-ignore payments/toncoin.mdx 

@Kaladin13 Kaladin13 marked this pull request as ready for review November 6, 2025 10:52
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update. In payments/toncoin.mdx, a couple of suggestions to align safety callouts—please apply the inline suggestions.

Kaladin13 and others added 2 commits November 6, 2025 14:16
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@github-actions
Copy link

github-actions bot commented Nov 6, 2025

To fix the formatting issues:

  1. Install necessary dependencies: npm ci
  2. Then, run this command:
npx remark -o --silent --silently-ignore payments/toncoin.mdx 

@anton-trunov
Copy link
Collaborator

/review

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No documentation issues detected.

| Security exposure | One shared hot wallet; a key leak drains the full pool | Each wallet isolates funds; compromise affects only the impacted user |
| User input requirements | User must include an invoice ID comment; missing or malformed comments need manual recovery workflows | User only needs the destination address |
| Parsing and validation | Backend parses comments on every deposit and matches to invoices | No parsing; deposit attribution is address-based |
| Deployment and storage costs | Deploy and maintain a single wallet; storage rent limited to that contract | Deploy many wallets; storage rent and deployment gas scale with user count |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need a link to the storage rent explanation. This is more or less unique to TON blockchain

| User input requirements | User must include an invoice ID comment; missing or malformed comments need manual recovery workflows | User only needs the destination address |
| Parsing and validation | Backend parses comments on every deposit and matches to invoices | No parsing; deposit attribution is address-based |
| Deployment and storage costs | Deploy and maintain a single wallet; storage rent limited to that contract | Deploy many wallets; storage rent and deployment gas scale with user count |
| Monitoring workload | Poll one address; comment parsing adds CPU but RPC calls stay low | Track many addresses; RPC queries and state tracking grow with the active user base |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

link to RPC page

| Parsing and validation | Backend parses comments on every deposit and matches to invoices | No parsing; deposit attribution is address-based |
| Deployment and storage costs | Deploy and maintain a single wallet; storage rent limited to that contract | Deploy many wallets; storage rent and deployment gas scale with user count |
| Monitoring workload | Poll one address; comment parsing adds CPU but RPC calls stay low | Track many addresses; RPC queries and state tracking grow with the active user base |
| Withdrawal handling | Highload wallet can batch withdrawals from one balance | Need sweeps or coordinated withdrawals from many wallets; extra gas and sequencing logic |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

highload wallet is mentioned here for the first time -- needs a link

| Deployment and storage costs | Deploy and maintain a single wallet; storage rent limited to that contract | Deploy many wallets; storage rent and deployment gas scale with user count |
| Monitoring workload | Poll one address; comment parsing adds CPU but RPC calls stay low | Track many addresses; RPC queries and state tracking grow with the active user base |
| Withdrawal handling | Highload wallet can batch withdrawals from one balance | Need sweeps or coordinated withdrawals from many wallets; extra gas and sequencing logic |
| Sharding behavior | All activity hits one shard; throughput limited by that shard | Wallets are distributed across shards; helps spread load |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

link to the page explaining sharding

import { Aside } from "/snippets/aside.jsx";

<Stub issue="204" />
Processing Toncoin payments requires choosing between two architectural approaches: invoice-based deposits to a single address, common to all users or unique deposit addresses per user. Each approach has different security characteristics, implementation complexity, and operational requirements.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make the exposition more self-contained and given this most likely will be read by seasoned Web3 engineers, let's add a brief note that TON blockchain does not have Ethereum-like externally owned accounts and probably link to the "Coming from Ethereum" page as well.

Environment: validate the full flow on testnet before using mainnet.
</Aside>

Wallet deployment happens lazily when users first request their deposit address. Generate the address deterministically without deploying the contract. When the user sends their first deposit to the un-deployed address, send the transaction in non-bounceable mode. The contract doesn't exist yet, so bounceable messages would return the funds. After the first deposit arrives, deploy the contract using funds from that deposit or from an external source.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

link to the place the distinction between bounceable and unbounceable messages is explained

- Withdrawal processing requires coordination across wallets
- Storage fees apply to each deployed contract (currently \~0.001 TON per year per contract)

Reference education-only implementation: [Unique address Toncoin deposits](https://github.com/ton-org/docs-examples/blob/processing/guidebook/payment-processing/src/deposits/unique-addresses.ts).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Reference education-only implementation: [Unique address Toncoin deposits](https://github.com/ton-org/docs-examples/blob/processing/guidebook/payment-processing/src/deposits/unique-addresses.ts).
To understand this approach in greater detail, see the following TypeScript implementation: [Unique address Toncoin deposits](https://github.com/ton-org/docs-examples/blob/processing/guidebook/payment-processing/src/deposits/unique-addresses.ts).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, let's add an "Aside" to mark this as "not production-ready code, use only for educational purposes"


## Common abuse patterns

- Reusing a previously settled invoice identifier to trigger duplicate credits when the backend does not invalidate the invoice after first use.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Reusing a previously settled invoice identifier to trigger duplicate credits when the backend does not invalidate the invoice after first use.
- Reusing a previously settled invoice identifier to trigger duplicate credits when the backend does not invalidate the invoice after the first use.


## Monitoring best practices

Implement exponential backoff for RPC failures. Network issues or node maintenance can interrupt transaction polling. When `getTransactions` fails, wait before retrying with increasing delays to avoid overwhelming the endpoint.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to link to the definition of getTransactions


Implement exponential backoff for RPC failures. Network issues or node maintenance can interrupt transaction polling. When `getTransactions` fails, wait before retrying with increasing delays to avoid overwhelming the endpoint.

Store transaction state persistently. Record the last processed `lt` value and transaction hash to resume monitoring after restarts without reprocessing transactions. This prevents duplicate deposit credits.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

explain lt means "logic time" and link to the corresponding page

@anton-trunov anton-trunov marked this pull request as draft November 6, 2025 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Processing > How to: invoices]

3 participants