5

I'm developing an application with which you can make ERC20 token transfers. When you make transfers from one account to another with a reasonable time between transfers it works correctly.

But when you make many transfers in a very short period of time from one account to another, like making 100 transfers one after another.

To make the transfers I am using the web3j library with version 4.5.15 and connects to the blockchain through Infura.

Why does this happen, and how can I fix it?

I leave you the code where the transfers are executed:

StaticGasProvider staticGasProvider = new StaticGasProvider(gasPrice, gasLimit);
TransactionManager transactionManager = new FastRawTransactionManager(web3j, "my_credentials", new NoOpProcessor(web3j));
ERC20 tokenContract = ERC20.load("token_address", web3j, transactionManager, staticGasProvider);
TransactionReceipt transactionReceipt = tokenContract.transfer("to_address", "amount").send();

Thanks for your help.

Regards

4
  • Please show the relevant code. Dec 15, 2020 at 16:19
  • The problem might the nonce isn't updated quickly enough. Take a look at this question ethereum.stackexchange.com/questions/34502/….
    – Ismael
    Dec 15, 2020 at 19:34
  • It is very difficult for us to help you if we can't see the code where you create, sign and broadcast the transactions.
    – Jesbus
    Dec 16, 2020 at 10:10
  • Sorry, my fault, I just added the code to make it easier to understand the problem Dec 16, 2020 at 14:33

1 Answer 1

4

As commented, showing your code will definitely help.

In the meantime, I also faced this issue from a backend in Node.js when I was launching several transactions almost simultaneously (in a public testnet).

Adding 'pending' when creating the nonce solved the issue:

    const nonce = await web3.eth.getTransactionCount(params.fromAddress, 'pending');

Please let us know if that is your case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.