Describe the bug
when trying to sign a batched transaction, it actually appear in the wrong order on metamask and force nonce that sends the transactions in the wrong order to the blockchain, resulting in a fail transaction due to that.
To Reproduce
Steps to reproduce the behavior:


Expected behavior
expected: 1st transaction is "approve", 2nd is the quickconvert
actual: 1st transaction is quickconvert (should be 2nd), 2nd is "approve" (should be 1st)
Screenshots
metamask interface display the transactions in the wrong order (notice order and nonce)


Browser details (please complete the following information):
Additional context
old UI handle the transactions incorrectly as well, where it orders them correctly but let the user sign the 2nd transaction first.
this is the popup you will see

@whymarrh @PaddyMc,
please let me know if you require additional information on this bug.
thanks,
@whymarrh @danfinlay,
bug #3425 was opened to fix an existing issue. the work was done and published yet it fixed nothing.
how can we reopen this topic and make sure it is sorted?
thanks,
any updates?
For me this is a problem with simple ERC-20 token, where I first call approve on it and then transferFrom (wrapped inside a call to my contract's method) to transfer tokens. If I batch them together, they are not shown in the correct order, so transferFrom is called before approve. Which of course does not work.
If someone can provide a sample dapp demonstrating how batching is not working correctly, I'll reopen this issue.
Hi @danfinlay,
If you try to convert any ERC20 token to another token using bancor.network, you will be able to see how batch transactions are not handled correctly on metamask.
I can provide more details yet it is all available both online and in this thread.
Best,
Hi everyone.
I get the same bug. Sometimes order is wrong when I use batch.
But this behavior is rather unstable. It occurs about 25%.
This is shown when order is incorrect (although caption says 1 of 2 )

And this is shown when the order is correct (approve transaction added first to the batch)

Also, more information found: When I batch.execute(), new chromium window is opened.
My colleague has slightly different behaviour: window is not opened automatically. If he presses metamask button on the toolbar, 1 of 2 transactions is always shown
Running into this issue as well! batch.execute() is confirming transactions in an incorrect order. Not an issue with other web3 providers I've tested with. Seems there are a few open issues related to this. Any ideas @danfinlay @kumavis ?
Can anyone provide a low-level example? batch.execute() is not a provider method, so it seems likely to me that this is the web3.js convenience library misbehaving. Some sample code would really be _the_ thing to allow easy fixing of this. Sorry it's just not high enough of a priority for me to go digging into Bancor's code, since the workaround (delay serial transactions) is so simple.
@danfinlay Here ya go: https://codesandbox.io/s/metamask-batchrequest-bug-demo-emnph?fontsize=14
Instructions:
Clicking "Send Batch Request" will attempt to batch submit 3 transactions to a contract I deployed to rinkeby with a method called setNumber which will revert if you try and set a number lower than the currently set number. Notice in this example I set up that the third transaction fails because metamask always submits what should be the 2nd transaction last (ie 1,3,2 instead of 1,2,3).
Works fine with any of the other providers.
Let me know if there's anything else you need to help reproduce and debug.
@danfinlay Trying to debug. I think the issue might be happening somewhere here? Or maybe earlier before that function is invoked. Any suspicions?
Also, until this is fixed, do you mind sharing that simple workaround you mentioned (delaying serial transactions)? Maybe in a forked version of that codesandbox I sent?
A fix is starting to roll out tomorrow. I recommend waiting.
Hey @danfinlay - looks like transactions are being ordered correctly now. Awesome! Not sure if y'all are still working on it, but noticing a few issues introduced:
1 even if there are 3 pending transactions in the batch to be confirmed.To illustrate: here's what a batch request of 3 transactions looks like for me now.

Thanks for the quick catches, @adamsoffer. We'll address these sooner than the batch bug. @rekmarks ^
A M A Z I N G !
@danfinlay thanks for finally sorting this out!
@adamsoffer thanks for picking up a long unresolved conversation and bringing it to resolution!
@adamsoffer just wanted to note that those UX issues you described should not be an issue as of 7.7.2
Most helpful comment
@danfinlay Here ya go: https://codesandbox.io/s/metamask-batchrequest-bug-demo-emnph?fontsize=14
Instructions:
Clicking "Send Batch Request" will attempt to batch submit 3 transactions to a contract I deployed to rinkeby with a method called
setNumberwhich will revert if you try and set a number lower than the currently set number. Notice in this example I set up that the third transaction fails because metamask always submits what should be the 2nd transaction last (ie 1,3,2 instead of 1,2,3).Works fine with any of the other providers.