Transfer Jetton Tokens
Transfer Jetton tokens and estimate transfer fees on TON.
This guide explains how to transfer Jetton tokens, estimate transfer fees, and validate inputs before executing.
Transfer Tokens
The sending account must have a deployed wallet for the Jetton master supplied in token. account.transfer() checks the deployed wallet's code, owner and master before estimating fees or submitting the transfer. A failed check stops the operation.
You can send Jetton tokens to a recipient address using account.transfer():
const transferResult = await account.transfer({
token: 'EQ...', // Jetton contract address
recipient: 'EQ...', // Recipient's TON address
amount: 1000000 // Amount in Jetton's base units
})
console.log('Signed transfer body hash:', transferResult.hash)
console.log('Transfer fee:', transferResult.fee, 'nanotons')Estimate Transfer Fees
account.quoteTransfer() applies the same checks to a deployed Jetton wallet. It also accepts the sender's Jetton-wallet address with no deployed code for estimation; a successful quote does not establish that the account can transfer that Jetton.
You can get a fee estimate before executing the transfer using account.quoteTransfer():
const transferQuote = await account.quoteTransfer({
token: 'EQ...', // Jetton contract address
recipient: 'EQ...', // Recipient's TON address
amount: 1000000 // Amount in Jetton's base units
})
console.log('Transfer fee estimate:', transferQuote.fee, 'nanotons')Transfer with Validation
Validate addresses and check balances before transferring to catch errors early:
- Use
account.getTokenBalance()to verify sufficient funds. - Use
account.quoteTransfer()to confirm fees. - Execute the transfer with
account.transfer():
async function transferJettonWithValidation(account, jettonAddress, recipient, amount) {
if (typeof jettonAddress !== 'string' || jettonAddress.length === 0) {
throw new Error('Invalid Jetton address format')
}
if (typeof recipient !== 'string' || recipient.length === 0) {
throw new Error('Invalid recipient address format')
}
const balance = await account.getTokenBalance(jettonAddress)
if (balance < amount) {
throw new Error('Insufficient Jetton balance')
}
const quote = await account.quoteTransfer({
token: jettonAddress,
recipient,
amount
})
console.log('Estimated fee:', quote.fee, 'nanotons')
const result = await account.transfer({
token: jettonAddress,
recipient,
amount
})
console.log('Signed transfer body hash:', result.hash)
console.log('Actual fee:', result.fee, 'nanotons')
return result
}Next Steps
Learn how to sign and verify messages with your TON account.