Skip to content

Commit b9bf8d2

Browse files
committed
chore: fix trc20 transfers
1 parent ce5b9db commit b9bf8d2

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

.changeset/strange-foxes-bathe.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@swapkit/toolbox-tron": patch
3+
---
4+
5+
Fixes TRC 20 transfers

packages/toolboxes/tron/src/toolbox.ts

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -408,32 +408,22 @@ export const createTronToolbox = async (params: TRONToolboxParams = {}): Promise
408408
return txid;
409409
}
410410

411-
// TRC20 transfer
412-
const contractAddress = assetValue.address;
413-
if (!contractAddress) {
414-
throw new SwapKitError("toolbox_tron_invalid_token_identifier", {
415-
identifier: assetValue.toString(),
416-
});
417-
}
418-
419-
const feeLimit = getMaxTransactionFee();
420-
const contract = tronWeb.contract(TRC20_ABI, contractAddress);
421-
422-
if (!contract.methods?.transfer) {
423-
throw new SwapKitError("toolbox_tron_token_transfer_failed");
424-
}
425-
426-
const result = await contract.transfer(recipient, assetValue.getBaseValue("string")).send({
411+
// TRC20 Token Transfer - always use createTransaction + sign pattern
412+
const transaction = await createTransaction({
413+
recipient,
414+
assetValue,
415+
memo,
427416
from: fromAddress,
428-
feeLimit,
429-
callValue: 0,
430417
});
431418

432-
if (!result) {
419+
const signedTx = await signer.signTransaction(transaction);
420+
const { txid } = await tronWeb.trx.sendRawTransaction(signedTx);
421+
422+
if (!txid) {
433423
throw new SwapKitError("toolbox_tron_token_transfer_failed");
434424
}
435425

436-
return result;
426+
return txid;
437427
};
438428

439429
const estimateTransactionFee = async ({

0 commit comments

Comments
 (0)