tronprotocol / tronweb

Javascript API Library for interacting with the TRON Network
MIT License
440 stars 277 forks source link

callback is not defined #429

Closed vanodevium closed 10 months ago

vanodevium commented 1 year ago

Hi!

I have a function:

const fee = process.env.FEE_LIMIT || 30000000;

async function payTRC20(toAddress, amount, fromAddress, tronWeb, contract) {
  const options = {
    feeLimit: fee,
    callValue: 0,
  };
  const tx = await tronWeb.transactionBuilder.triggerSmartContract(
    contract,
    "transfer(address,uint256)",
    options,
    [
      {
        type: "address",
        value: toAddress,
      },
      {
        type: "uint256",
        value: amount * 1000000,
      },
    ],
    tronWeb.address.toHex(fromAddress),
  );
  const signedTx = await tronWeb.trx.sign(tx.transaction);
  return tronWeb.trx.sendRawTransaction(signedTx);
}

module.exports = payTRC20;

This function works fine, but for some wallets it throws an error with the text:

callback is not defined

Version: "tronweb": "5.3.0"


Please tell me what the problem might be and how to fix it.

An important clarification: if you repeat on such an "incorrect" wallet, the error will be the same. If you transfer money to such a wallet through a mobile application, everything goes without errors.

vanodevium commented 1 year ago

As far as I could figure it out, problem is in two places:

This variable callback is not defined really.


But still, I'm really asking you to tell me why only on some wallets I see this error, even though the function code is the same for all.

start940315 commented 1 year ago

We have known this bug and it would not be a problem in v6. For now, I recommend you to console.log the toAddress and amount variable to check if there are some error data.

vanodevium commented 1 year ago

Thanx! But main question is: why some wallets have this error?

start940315 commented 1 year ago

Maybe they are using different version. Previous versions don't have this problem.

Ar1stotele commented 10 months ago

Hello, have you been able to resolve this issue? If not - you might have an error in this line value: amount * 1000000,. I had something similar.

Good luck.

start940315 commented 10 months ago

Fixed in TronWeb v6.0.0-beta.0. Welcome to try.