Skip to content
Open
15 changes: 15 additions & 0 deletions guidebook/toncoin-processing/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Toncoin Payment Processing Configuration

# Network Configuration
# Set to "false" for mainnet, leave as "true" or omit for testnet
IS_TESTNET=true

# TonCenter API Key
# Get your API key at https://toncenter.com (mainnet) or https://testnet.toncenter.com (testnet)
# Or run your own API: https://github.com/toncenter/ton-http-api
API_KEY=your_api_key_here

# Wallet Address
# Your wallet address that will receive deposits (for single-wallet examples)
# Or your HOT wallet address (for multi-wallet examples)
WALLET_ADDRESS=UQB22lH8P_P2OitCe8UYRxpuDF5GVqCfYTL7PDz3OzbuHebu
23 changes: 23 additions & 0 deletions guidebook/toncoin-processing/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
node_modules
temp
build
dist
.DS_Store
package.ts

# VS Code
.vscode/*
.history/
*.vsix

# IDEA files
.idea

# VIM
Session.vim
.vim/

# Other private editor folders
.nvim/
.emacs/
.helix/
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

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

The .gitignore file is missing the .env entry. While .env.example is provided for configuration, the actual .env file containing sensitive API keys and wallet addresses should be excluded from version control to prevent credential exposure.

Suggested change
.helix/
.helix/
# Environment variable files
.env

Copilot uses AI. Check for mistakes.
1 change: 1 addition & 0 deletions guidebook/toncoin-processing/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
7 changes: 7 additions & 0 deletions guidebook/toncoin-processing/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"printWidth": 120,
"tabWidth": 4,
"singleQuote": true,
"bracketSpacing": true,
"semi": true
}
60 changes: 60 additions & 0 deletions guidebook/toncoin-processing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Toncoin Payment Processing Examples

Educational TypeScript examples demonstrating Toncoin payment processing on the TON blockchain.

## Libraries Used

- [@ton/ton](https://github.com/ton-org/ton) - High-level TON blockchain API client
- [@ton/core](https://github.com/ton-org/ton-core) - Core primitives for TON blockchain
- [@ton/crypto](https://github.com/ton-org/ton-crypto) - Cryptographic primitives for TON

## Examples

### 1. Single Wallet with Invoices (`src/deposits/invoices.ts`)

Demonstrates accepting Toncoin deposits to a single wallet using unique text comments (UUIDs) to identify each payment.

**Use case**: Payment processing where each payment is tracked by a unique identifier in the transaction comment.

### 2. Multi-Wallet Deposits (`src/deposits/unique-addresses.ts`)

Demonstrates accepting Toncoin deposits where each user has their own unique deposit wallet that forwards funds to a master HOT wallet.

**Use case**: Exchange or service where users need permanent deposit addresses.

## Setup

1. Install dependencies:
```bash
npm install
```

2. Configure your environment:
- Copy `.env.example` to `.env`
- Set your API key and wallet address
- Choose mainnet or testnet

3. Run an example:
```bash
# Single wallet invoices example
npm start

# Multi-wallet example
npm run start:unique
```

## Development Scripts

- `npm start` - Run the single-wallet invoices example
- `npm run start:unique` - Run the multi-wallet deposits example
- `npm run build` - Type-check the project (does not produce executable output)
- `npm run format` - Format code with Prettier

## ⚠️ Educational Use Only

These examples are for learning purposes. Do not deploy to production without:
- Thorough security review
- Proper error handling
- Database persistence
- Monitoring and alerting
- Rate limiting and retry strategies
Loading
Loading