2

I have web application and background queue that executes long lasting tasks. Both of them using truffle-privatekey-provider with same private key to sign/send transactions.

Now I ma experiencing issue with nonce mismatch - when background worker makes 5 tasks its nonce increases to 5 from zero. Meanwhile web application doesn't knows about it and trying to use old nonce (1) and failed.

I do not want to calculate nonce before each transaction (moreover - I am using truffle-contract to abstract myself from raw transactions).

Is there any ways to solve it?

  • not sure what you are asking / or want to do but why dont you copy the instance {...web3} – Arash Kiani Aug 23 '18 at 15:34
  • @ArashKiani imagine one module, lets' say eth that contains provider and perform connection initialization. It exports connected web3 and contrac instances. When trying to use it from independent apps simultaneously you've got this problem. – Alex G.P. Aug 23 '18 at 15:39
  • interesting so you don't want to instantiate contract multiple times – Arash Kiani Aug 23 '18 at 15:43
  • use contract multiple times : const contract = new web3.eth.Contract(contractInterface,to,input) – Arash Kiani Aug 23 '18 at 15:44
  • I know how to use contract. Imagine you export contract from module and user it in 2 different processes. – Alex G.P. Aug 23 '18 at 15:45

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.