PnutbManager API Reference

Complete technical documentation for the dual-backend architecture: PHP (Database & Logic) and Node.js (Blockchain Proxy) systems.

PHP Gateway Node.js Proxy Admin Only

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.

MySQL RESTful

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.

TON Blockchain HD Wallets

Security Features

Multi-layer security with API authentication, wallet signature verification, and rate limiting. All blockchain transactions are cryptographically signed and verified.

Auth Required Encrypted

1. User & Referral Endpoints (PHP Gateway)

POST PHP /User/create/
Internal DB Entry

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
}
Note: Referral codes are automatically generated using a cryptographically secure random algorithm and guaranteed unique in the database.
GET PHP /User/info/
Query Parameter: address

Retrieves complete user profile information from MySQL database, including rank, referral statistics, and tournament participation.

Query Parameters

address TON wallet address (e.g., EQ...)

Response

{
  "wallet": "EQ...",
  "rank": "gold",
  "referral_code": "a1b2c3d4",
  "total_referrals": 15,
  "tournament_points": 1250,
  "created_at": "2024-01-15T10:30:00Z"
}
GET PHP /User/referralStatus/
Query Parameter: address

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)

Security Notice: All Node.js endpoints require API authentication. Admin endpoints additionally require wallet signature verification.
GET Node /wallet/generate/:userId
Deterministic Generation

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

userId Numeric user identifier (e.g., 12345)

Response

{
  "userId": "12345",
  "address": "EQ...",  // Deterministic TON address
  "derivation_path": "m/44'/607'/0'/0'/12345'",
  "balance": "0"
}
Unity Developer Note: Display this generated address to players for deposits. The address is consistent per user, allowing players to reuse it for multiple deposits.
GET Node /wallet/verify/:userId
Blockchain Scanner

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"
}
POST Node Admin /wallet/sweep/:userId
Admin Only

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

POST Node Admin /admin/create-asset
CreateGameAsset Message

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
GET Node /contract/status
Real-time State

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"
}
POST Node Admin /admin/send-pnutb
Jetton Transfer

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
}
Amount Format: PNUTB uses 9 decimals. To send 1 PNUTB, use 1000000000 as the amount.

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
400INVALID_WALLETWallet address format is invalid
400INSUFFICIENT_BALANCEInsufficient funds for operation
401UNAUTHORIZEDMissing or invalid authentication
403FORBIDDENAdmin access required
404USER_NOT_FOUNDUser ID or wallet not found
409DUPLICATE_ASSETAsset ID already exists
429RATE_LIMITEDToo many requests
500BLOCKCHAIN_ERRORTON 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