Skip to main content
Use this server-side helper to generate a canonical TON message payload and a tracking reference.

Function signature

Transfer parameters

API options

string
default:"mainnet"
Target blockchain network. Use "mainnet" for production or "testnet" for development and testing.
string
The optional TON Pay API key from the Merchant Dashboard. When provided, it enables:
  • Transaction visibility in the TON Pay Merchant Dashboard.
  • Webhook notifications for completed transactions.
  • Receiving wallet management from the Merchant Dashboard.

Parameter details

number
required
Human-readable payment amount. Decimals are allowed, for example, 10.5 TON.
string
required
Asset to transfer. Use “TON” for Toncoin or a jetton master address or constant, for example, USDT.
string
Payee wallet address. Optional if an API key is provided. Defaults to the merchant’s default wallet address configured in the Merchant Dashboard.
string
required
Payer wallet address. In UI flows, obtain it from TON Connect.
number
Jetton only. Numeric identifier embedded into the jetton payload for idempotency and tracking. Ignored for Toncoin payments.
string
Short note visible to the user in the wallet while signing.
string
Note visible to the recipient after the transfer is received.

Predefined asset constants

Built-in constants can be used instead of raw addresses.
Response:

Response fields

object
required
Prebuilt TON Connect transaction message. Intended to be passed to sendTransaction as messages: [message].
string
required
Base64 hash of the signed message body content (payload). Used with getTonPayTransferByBodyHash.
string
required
Tracking reference string. Used with getTonPayTransferByReference.
The SDK call returns a ready-to-send message along with identifiers for subsequent status lookups. Always persist tracking identifiers server-side before sending the transaction to the user.

Optional API key configuration

The TON Pay API key is optional but enables merchant features, including transaction visibility in the dashboard, webhook notifications, and centralized wallet management in the TON Pay Merchant Dashboard.

Obtain an optional API key

1

Open the Merchant Dashboard

Open the TON Pay Merchant Dashboard and sign in to the merchant account.
2

Open Developer settings

Navigate to DeveloperAPI Keys sections to set up the optional API key.
3

Generate or copy an optional API key

Generate a new API key (optional) or copy an existing one and store it securely.

Usage in code

Optional API key capabilities

With optional API key: recipientAddr is optional.
Without API key (the API key remains optional): recipientAddr is required.

Testnet configuration

Set up testnet

1

Set chain to testnet

Configure the chain option to "testnet" in the API calls:
2

Use testnet wallet addresses

Ensure all wallet addresses are valid testnet addresses.
3

Obtain testnet TON

4

Configure testnet jettons

If testing with jettons, use the correct testnet jetton master addresses; not mainnet addresses.

Configure environment

Use environment variables to switch between mainnet and testnet:

Verify testnet transactions

Verify testnet transactions using testnet block explorers:

Apply testing best practices

  • Test all payment outcomes on testnet, including success, failures, user rejections, and edge cases.
  • Verify webhook endpoint correctly processes testnet webhooks; payload structure matches mainnet.
  • Validate behavior across different amounts, including small, large, and fractional values.
  • Ensure reference and bodyBase64Hash are persisted and usable for status lookups.
  • Exercise error paths such as insufficient balance, invalid addresses, and network issues.