const TronWeb = require('tronweb'); async function main() { try { const [ ,, privateKey, toAddress, contractAddress, fullNodeUrl, amount ] = process.argv; if (!privateKey || !toAddress || !contractAddress || !fullNodeUrl || !amount) { console.log(JSON.stringify({ success: false, error: '参数不足' })); return; } const tronWeb = new TronWeb({ fullHost: fullNodeUrl, privateKey: privateKey }); const contract = await tronWeb.contract().at(contractAddress); // USDT 是 6 位精度 const decimals = 6; const sendAmount = tronWeb.toBigNumber(amount) .times(tronWeb.toBigNumber(10).pow(decimals)) .toString(); const tx = await contract.transfer( toAddress, sendAmount ).send({ feeLimit: 100_000_000 }); // 成功返回 console.log(JSON.stringify({ success: true, txid: tx })); } catch (e) { // 失败返回 console.log(JSON.stringify({ success: false, error: e.message })); } } main();