1234567891011121314151617181920212223242526 |
- const { TronWeb } = require('tronweb');
- const tronWeb = new TronWeb({
- fullHost: 'https://nile.trongrid.io',
- });
- const privateKey = '4924c6b2cb6074da8792f2c22966e0ae27a8943d12d34d34d34d34d34d35efbe';
- const toAddress = 'TM8Q54LmsLTH5YPu72cB9MdkuH7c63JNq9'; // T开头地址
- const contractAddress = 'TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf'; // USDT合约主网地址
- const amount = 100 * 1e6; // 转账1 USDT
- async function sendTRC20() {
- try {
- const contract = await tronWeb.contract().at(contractAddress);
- const tx = await contract.methods.transfer(toAddress, amount).send({
- feeLimit: 10_000_000
- }, privateKey);
- console.log('交易成功,txid:', tx);
- } catch (error) {
- console.error('交易失败:', error);
- }
- }
- sendTRC20();
|