Invalid issuer address error when sending USDT with TronWeb
I am trying to send USDT using TronWeb but keep encountering the error: Invalid issuer address provided
. Here is the code I’m using:
async function onSignTransaction() {
const { abi } = await tronWeb.trx.getContract(CONTRACT);
const contract = tronWeb.contract(abi.entrys, CONTRACT);
console.log(contract);
try {
// Send USDT to the specified address
const transaction = await contract.methods
.transfer(RECEIVER_ADDRESS, tronWeb.toSun(10))
.send();
// Sign the transaction
const signedTx = await tronWeb.trx.sign(transaction);
// Broadcast the transaction
const receipt = await tronWeb.trx.sendRawTransaction(signedTx);
console.log('Transaction Receipt:', receipt);
} catch (error) {
console.error('Error sending USDT:', error);
}
}
- Verified that `CONTRACT` is the correct address for the USDT contract.
- Confirmed that `RECEIVER_ADDRESS` is valid and correctly formatted.
- Checked the ABI for accuracy to ensure it matches the contract.
- Printed the contract and transaction details for debugging.
I don’t see much issues in the code however you can look into using abi instead of abi.entrys may not be needed unless it explicitly contains the methods.
Aditionally .send() method already takes care of signing and broadcasting, so you don’t need tronWeb.trx.sign and tronWeb.trx.sendRawTransaction manually.
1