Overview
TON deposits require constructing a TON-specific message payload. The flow differs depending on whether you’re transferring native TON or a Jetton (TRC-20-like token on TON). Thecall_data from the Layerswap API contains the information needed to build the correct payload.
Prerequisites:
- @ton/ton for cell building and TON client
- @tonconnect/ui-react (for browser wallets) or a TON SDK for server-side signing
call_data Format
For TON,call_data is a JSON string containing:
comment— A text memo that Layerswap uses to identify the deposit. This is embedded in the transaction payload.amount— The transfer amount in base units (nanotons for TON, base units of the Jetton otherwise). Always present; for native TON it matches the deposit action’samountfield.asset— The source asset symbol (e.g.TON,USDT). Informational; the actual contract is on the deposit action’stoken.contract.
Native TON Transfer
For native TON transfers (whentoken.contract is null), the transaction is a simple message to the deposit address with a comment payload.
Transaction Construction
1
Parse call_data
Extract the
comment field from the JSON.2
Build the comment cell
Create a TON cell with a 32-bit zero prefix (indicates a text comment) followed by the comment string.
3
Construct the message
Send a message to
to_address with the deposit amount (converted to nanotons) and the comment cell as payload.Full Example
Jetton Transfer
For Jetton transfers (whentoken.contract is not null), you need to build a Jetton transfer message that targets the sender’s Jetton wallet address (not the Jetton master contract).
Transaction Construction
1
Parse call_data
Extract both
comment and amount from the JSON.2
Resolve the sender's Jetton wallet
Use the Jetton master contract to look up the sender’s Jetton wallet address via
get_wallet_address.3
Build the Jetton transfer cell
Construct a cell with the Jetton transfer opcode (
0x0f8a7ea5), the Jetton amount, the destination address, and a forward payload containing the comment.4
Send the message
Send the message to the sender’s Jetton wallet address with enough TON attached to cover fees.
Full Example
Sending the Transaction
TheTON Connect tab is for browser wallets like Tonkeeper or MyTonWallet — it picks between the native and Jetton builders above based on token.contract. The Server-side tab signs and sends directly with a wallet key for backend use.
The server-side example above shows a native TON transfer. For Jetton transfers, build the Jetton cell as shown in the Jetton section and target the sender’s Jetton wallet address.