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:- Configure the TON Connect UI provider with the application manifest.
- Manage wallet connection state and provide UI for users to connect the wallets.
- Create a transaction message on the client or backend using
createTonPayTransfer. - Send the transaction using TON Connect’s
sendTransactionmethod. - Observe connection state changes and transaction status updates.
React implementation
Set up application
Wrap the application with the TON Connect UI provider:<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 tosendTransaction 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
validUntilvalue, 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
referenceandbodyBase64Hashbefore 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
If a transaction fails with Wallet is not connected
If a transaction fails with Wallet is not connected
Ensure the wallet is connected before calling Add a connection state check:
sendTransaction:If sendTransaction throws Invalid address format
If sendTransaction throws Invalid address format
- Ensure the
fromaddress matches the connected wallet address. - Verify that the recipient address is a valid TON address.
- Use the wallet address provided by the SDK to avoid format mismatches:
If a transaction expires before the user signs it
If a transaction expires before the user signs it
The
validUntil timestamp may be too short. Increase the validity period to give the user more time to confirm the transaction:If the manifest URL fails to load
If the manifest URL fails to load
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.
If onStatusChange is not triggered
If onStatusChange is not triggered
Ensure that the status change subscription is created once and remains active for the lifetime of the component.
If multiple wallet connection prompts appear
If multiple wallet connection prompts appear
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.