使用TronWeb发送USDT时遭遇「Invalid issuer address」错误求助
解决TronWeb发送USDT时的「Invalid issuer address provided」错误
问题描述
使用TronWeb调用USDT合约的transfer方法时,持续报错Invalid issuer address provided,代码如下:
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); } }
已完成的排查:
- 确认
CONTRACT是USDT合约的正确地址 - 验证
RECEIVER_ADDRESS有效且格式正确 - 检查ABI的准确性,确保与合约匹配
- 打印合约和交易详情用于调试
错误原因
代码存在重复的交易处理流程:
contract.methods.transfer().send()本身已包含「签名交易+广播」的完整逻辑,返回的是交易回执而非未签名的交易对象。- 后续调用
tronWeb.trx.sign(transaction)时,传入的是交易回执而非待签名的原始交易数据,从而触发Invalid issuer address provided错误。
修正后的代码
直接使用send()方法完成交易,无需额外执行签名和广播步骤:
async function onSignTransaction() { const { abi } = await tronWeb.trx.getContract(CONTRACT); const contract = tronWeb.contract(abi.entrys, CONTRACT); console.log(contract); try { // 调用transfer并直接完成签名+广播 const receipt = await contract.methods .transfer(RECEIVER_ADDRESS, tronWeb.toSun(10)) .send({ feeLimit: 100000000 // 可选:指定交易手续费上限,单位为Sun(1 TRX = 10^6 Sun) }); console.log('Transaction Receipt:', receipt); } catch (error) { console.error('Error sending USDT:', error); } }
离线签名场景补充
如果需要手动控制签名和广播流程(比如离线签名),应使用call()方法获取未签名的交易对象,再执行后续操作:
async function onSignTransaction() { const { abi } = await tronWeb.trx.getContract(CONTRACT); const contract = tronWeb.contract(abi.entrys, CONTRACT); console.log(contract); try { // 获取未签名的原始交易对象 const transaction = await contract.methods .transfer(RECEIVER_ADDRESS, tronWeb.toSun(10)) .call(); // 签名交易 const signedTx = await tronWeb.trx.sign(transaction); // 广播签名后的交易 const receipt = await tronWeb.trx.sendRawTransaction(signedTx); console.log('Transaction Receipt:', receipt); } catch (error) { console.error('Error sending USDT:', error); } }
内容的提问来源于stack exchange,提问作者ecomnazar
相关产品推荐
相关产品推荐

