1

I have a contract being an ERC-20 token. I want to perform two idendical transfers (sender, receiver and amounts are the same).

I am using the contract objects from Web3j:

MyToken token = MyToken.load(tokenAddress, web3j, credentials, DefaultGasProvider()));
token.transfer(recipient, amount).send();
token.transfer(recipient, amount).send();

However, the secont transaction fails with "Known transaction" error. How can I make this work and successfully perform two distinct, but identical transactions?

  • I don't remember exactly but I think you have to use FastRawTransactionManager. It will cache the previous nonce and increment with a new transaction. – Ismael Sep 6 '19 at 13:50
  • Helped. Unfortunately it is not possible to do it using the generated contract classes - I needed to create and send raw transactions on my own. Thank you! :) – Mitu Sep 7 '19 at 18:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.