Error: insufficient funds (version=4.0.47)
See original GitHub issueHi All, I am using this library to send usdt with the following code, but when I pass in 50 as amount to be sent to another address and my usdt balance is 97.59, then I got error: insufficient funds, but I have 97.59 usdt in my account, only sending 50, also my ETH balance in my account is 0.00125, which is for the gas fee:
wallet sendTUSDToAddress…error: Error: insufficient funds (version=4.0.47) 2020-05-28T16:38:10.716047+00:00 app[web.1]: at Object.throwError (/app/node_modules/ethers/errors.js:76:17) 2020-05-28T16:38:10.716047+00:00 app[web.1]: at /app/node_modules/ethers/providers/json-rpc-provider.js:276:36 2020-05-28T16:38:10.716048+00:00 app[web.1]: at processTicksAndRejections (internal/process/task_queues.js:97:5) { 2020-05-28T16:38:10.716049+00:00 app[web.1]: reason: ‘insufficient funds’, 2020-05-28T16:38:10.716050+00:00 app[web.1]: code: ‘INSUFFICIENT_FUNDS’, 2020-05-28T16:38:10.716050+00:00 app[web.1]: transaction: { 2020-05-28T16:38:10.716051+00:00 app[web.1]: nonce: 0, 2020-05-28T16:38:10.716052+00:00 app[web.1]: gasPrice: BigNumber { _hex: ‘0x0826299e00’ }, 2020-05-28T16:38:10.716054+00:00 app[web.1]: gasLimit: BigNumber { _hex: ‘0xa0ed’ }, 2020-05-28T16:38:10.716054+00:00 app[web.1]: to: ‘0xdAC17F958D2ee523a2206206994597C13D831ec7’, 2020-05-28T16:38:10.716054+00:00 app[web.1]: value: BigNumber { _hex: ‘0x00’ }, 2020-05-28T16:38:10.716056+00:00 app[web.1]: data: ‘0xa9059cbb000000000000000000000000df59a6d6c2f09210a60033e513ffd8d61c69be1f0000000000000000000000000000000000000000000000000000000002faf080’,
My code is:
`try{ let usdAbi = Token.abi; let contract = new ethers.Contract(contractAddressUSD, usdAbi,PROVIDER); let wallet2 = new ethers.Wallet(privateKeyDec, PROVIDER); let contractWithSigner = contract.connect(wallet2);
var amount2 = utils.parseUnits(amount.toString(), 6).toNumber();
let usdtBal = await contract.balanceOf(fromAddress);
console.log("wallet sendTUSDToAddress...amount2: ", amount2);
usdtBal = usdtBal.toString();
console.log("wallet sendTUSDToAddress...usdtBal: ", usdtBal);
if(Number(usdtBal) >= amount2){
var transfer = await contractWithSigner.transfer(toAddress, amount2);
console.log("wallet sendTUSDToAddress...transfer: ", transfer);
return transfer;
}else{
return {
error: "Not enough Tether USD in your wallet",
usdtbal: usdtBal
}
}
}catch(error) {
console.log("wallet sendTUSDToAddress...error: ", error);
return {
error: error,
}
}`
Any clues? Thanks for your help.
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (5 by maintainers)
Top GitHub Comments
@zemse Thank you, turned out to be a problem with the wallet.
also don’t forget to suspend gas limits!