PnutbManager API Reference
Complete technical documentation for the dual-backend architecture: PHP (Database & Logic) and Node.js (Blockchain Proxy) systems.
PHP Backend
Core database management system handling MySQL storage, user referrals, tournament metadata, and primary UI gateway operations. Responsible for all persistent data and business logic orchestration.
Node.js Proxy
Blockchain interface layer managing HD Wallet generation, TON transaction verification, and Admin interactions with the Tact Smart Contract. Handles all on-chain operations.
Security Features
Multi-layer security with API authentication, wallet signature verification, and rate limiting. All blockchain transactions are cryptographically signed and verified.
1. User & Referral Endpoints (PHP Gateway)
Registers a new wallet in the system and generates a unique referral code for the user. Automatically tracks referral relationships if a referrer is provided.
Request Body (application/json)
{
"wallet": "EQ...", // Required: TON wallet address
"referred_by": "REF123" // Optional: Referrer's referral code
}
Response (Success)
{
"status": "success",
"referral_code": "a1b2c3d4", // Unique 8-character code
"user_id": 12345
}
Retrieves complete user profile information from MySQL database, including rank, referral statistics, and tournament participation.
Query Parameters
Response
{
"wallet": "EQ...",
"rank": "gold",
"referral_code": "a1b2c3d4",
"total_referrals": 15,
"tournament_points": 1250,
"created_at": "2024-01-15T10:30:00Z"
}
Returns detailed referral statistics for the specified wallet, including total invites and tier information.
Response
{
"wallet": "EQ...",
"total_invites": 15,
"tier_1_count": 10,
"tier_2_count": 5,
"total_rewards": "150.5"
}
2. HD Wallet & Deposit System (Node.js Proxy)
Generates a deterministic TON address for a specific User ID using HD derivation (subwallet ID) from the master mnemonic. The same userId always generates the same address.
Path Parameters
Response
{
"userId": "12345",
"address": "EQ...", // Deterministic TON address
"derivation_path": "m/44'/607'/0'/0'/12345'",
"balance": "0"
}
Scans the TON blockchain for any incoming transfers to the user's generated HD wallet. Returns all unprocessed deposits with their transaction details.
Response
{
"userId": "12345",
"address": "EQ...",
"deposits": [
{
"hash": "tx_id_1",
"amount": "10.5",
"confirmed": true,
"timestamp": 1705334400,
"lt": 12345678
}
],
"total_unprocessed": "10.5"
}
Admin function to consolidate funds from user deposit addresses into the central Admin Collection Wallet. Automatically reserves 0.02 TON for future gas fees.
Process Details
- Verifies available balance on user address
- Calculates sweepable amount (balance - 0.02 TON reserve)
- Creates and signs transfer transaction
- Broadcasts to TON network
- Updates local database records
Response
{
"userId": "12345",
"sweep_tx": "tx_hash",
"amount_swept": "10.48",
"gas_reserved": "0.02",
"status": "confirmed"
}
3. Tact Smart Contract Interactions
Triggers the CreateGameAsset message on the Tact smart contract, creating a new purchasable in-game asset.
Request Body
{
"id": 1, // Unique asset identifier
"name": "Sword", // Asset name (max 64 chars)
"desc": "Fire Sword", // Asset description
"img": "https://...", // Image URL
"qty": 100, // Total mintable quantity
"price": 5000000 // Price in nanoTON (0.005 TON)
}
Validation Rules
- Asset ID must be unique within contract
- Quantity must be between 1 and 1,000,000
- Price must be >= 1 nanoTON
- Name and description cannot be empty
Reads the current real-time state from the Tact smart contract, including operational status and ownership information.
Response
{
"is_paused": false,
"owner": "EQ...",
"pnutb_wallet": "EQ...",
"total_assets": 25,
"total_volume": "125000.5",
"last_transaction": "tx_hash"
}
Triggers the contract to send PNUTB Jetton tokens to a specified recipient address.
Request Body
{
"recipient": "EQ...", // Destination wallet address
"amount": "100", // Amount in PNUTB (including decimals)
"memo": "Reward payment" // Optional transfer memo
}
4. Administrative Endpoints
| Endpoint | Backend | Method | Description |
|---|---|---|---|
/admin/pause |
Node | POST | Freezes all contract purchases on-chain. No new purchases can be made until unpaused. |
/admin/unpause |
Node | POST | Resumes contract operations, allowing purchases and transfers again. |
/admin/set-jetton-wallet |
Node | POST | Sets the official Jetton (PNUTB) wallet address for token operations. |
/admin/send-ton |
Node | POST | Withdraws TON balance from the contract to Owner wallet. |
/admin/transfer-ownership |
Node | POST | Transfers contract admin rights to a new wallet address. |
/Admin/createAsset/ |
PHP | POST | Syncs asset information to MySQL database and triggers Node.js on-chain creation. |
5. Error Handling
| HTTP Code | Error Code | Description |
|---|---|---|
| 400 | INVALID_WALLET | Wallet address format is invalid |
| 400 | INSUFFICIENT_BALANCE | Insufficient funds for operation |
| 401 | UNAUTHORIZED | Missing or invalid authentication |
| 403 | FORBIDDEN | Admin access required |
| 404 | USER_NOT_FOUND | User ID or wallet not found |
| 409 | DUPLICATE_ASSET | Asset ID already exists |
| 429 | RATE_LIMITED | Too many requests |
| 500 | BLOCKCHAIN_ERROR | TON network transaction failed |
6. Rate Limits
Public Endpoints
60 requests per minute per IP
Headers: X-RateLimit-Remaining
Admin Endpoints
20 requests per minute per wallet
Stricter limits for blockchain operations
Blockchain Queries
10 requests per second
To prevent node overload