Skip to main content
Use TON Connect native sendTransaction method when:
  • The application manages wallet connection UI and transaction flow directly.
  • TON Connect is already used elsewhere in the application.
  • Access to TON Connect-specific APIs is required, such as status change listeners or custom wallet adapters.

Integration overview

Direct TON Connect integration follows these steps:
  1. Configure the TON Connect UI provider with the application manifest.
  2. Manage wallet connection state and provide UI for users to connect the wallets.
  3. Create a transaction message on the client or backend using createTonPayTransfer.
  4. Send the transaction using TON Connect’s sendTransaction method.
  5. Observe connection state changes and transaction status updates.

React implementation

Set up application

Wrap the application with the TON Connect UI provider:
The manifest URL must be publicly accessible and served over HTTPS in production. Replace <APP_URL> with the public HTTPS origin that serves tonconnect-manifest.json. The manifest file provides application metadata required for wallet identification.

Payment component

Manage connection state

Listen for wallet connection status changes using the TON Connect UI API:

Server-side message building

For production applications, build transaction messages on the server to centralize tracking and validation.

Backend endpoint

Frontend implementation

Vanilla JavaScript implementation

For non-React applications, use the TON Connect SDK directly:

Transaction parameters

Message structure

The message object passed to sendTransaction must include these fields:
string
required
Recipient wallet address in user-friendly format.
string
required
Amount to send in nanotons.
string
required
Base64-encoded message payload containing transfer details and tracking information.

Transaction options

number
required
Unix timestamp indicating when the transaction expires. Typically is 5 minutes.
string
required
Sender’s wallet address. Must match the connected wallet address.
string
Network identifier. Usually omitted as it is inferred from the connected wallet.

Error handling

Best practices

  • Check wallet connection status before attempting to send transactions. Provide clear UI feedback for connection state.
  • Use a reasonable validUntil value, typically 5 minutes, to prevent stale transactions while allowing enough time for user confirmation.
  • Ensure the sender address from TON Connect matches the format expected by the backend. Use the user-friendly format consistently.
  • Always persist reference and bodyBase64Hash before sending the transaction. This allows payment reconciliation through webhooks even if the client flow fails after submission.
  • Implement connection state listeners to update the UI and handle wallet disconnections.
  • Handle transaction rejection explicitly. Treat user rejection as a normal cancellation, not as an error.

Troubleshooting

Ensure the wallet is connected before calling sendTransaction:
Add a connection state check:
  1. Ensure the from address matches the connected wallet address.
  2. Verify that the recipient address is a valid TON address.
  3. Use the wallet address provided by the SDK to avoid format mismatches:
The validUntil timestamp may be too short. Increase the validity period to give the user more time to confirm the transaction:
Check for the following common issues:
  • The URL is not publicly accessible.
  • CORS headers are not configured correctly.
  • The manifest JSON is malformed.
  • The URL is not HTTPS; required in production.
Open the manifest URL directly in a browser to verify that it is accessible.
Ensure that the status change subscription is created once and remains active for the lifetime of the component.
connectWallet() may be called more than once. Track the connection state:

Optional API key configuration

When using TON Connect with server-side message building, the optional API key can be included in the backend:

Testnet configuration

Set up testnet

Configure the environment to use testnet:

Next steps

Webhook integration

Receive real-time notifications when payments complete.

Transaction status

Query payment status using reference or body hash.