Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signing multiple transactions with BatchRequest #1321

Closed
eolszewski opened this issue Jan 25, 2018 · 7 comments
Closed

Signing multiple transactions with BatchRequest #1321

eolszewski opened this issue Jan 25, 2018 · 7 comments

Comments

@eolszewski
Copy link

var batch = new web3.BatchRequest();
    await Promise.all(users.map(async user => {
        const signedTx = await web3.eth.accounts.signTransaction({
            chainId: "0x03",
            to: user.wallet,
            value: value * 1000000000000000000,
            gas: 2500000
        }, PRIVATE_KEY);
        batch.add(web3.eth.sendSignedTransaction.request(signedTx.rawTransaction,'receipt', console.log));
    }));
    batch.execute()

When executing this, I am getting replacement transaction underpriced.

The goal is to have one account send ETH to multiple accounts in a 'cohort transaction' within a system. The nonces are different, so I'm not sure why I'm getting the error stating that this is a replacement transaction...

@subramanianv
Copy link

I think you got to increase the nonce each time

@eolszewski
Copy link
Author

@subramanianv web3 automatically increments the nonce here, this is seen when logging each signedTx as it is created.

@Andromelus
Copy link

Andromelus commented Jan 26, 2018

I don't really know how batch works internally, but is there a possibility that it actually gets all the nonces at once. Then the first tx will pass, but not the others (if sent from the same address)?

@eolszewski
Copy link
Author

This doesn't seem possible, I had to just loop through and put a delay between the sending of each signed transactions

@emiliomarin
Copy link

@eolszewski Hi, did you ever get the batch working for sending multiple transactions? Right now I have working a script that makes individual tx and wanted to group them to save gas... But not getting many results. Thanks!

@sssubik
Copy link

sssubik commented Jun 24, 2020

Hey @eolszewski @PeterTheOne @emiliomarin does using batch request work or providing a delay between each txn work? Please any help will be highly appreciated

@iradofurioso
Copy link

I'm trying to sign multiple vouchers. User uploads an image and defines the quantity I need to create one signed voucher for each copy. For one voucher I manage to work using sendAsync the problem Is when I try to sign more than one. I tried to provide sendAsync to batch.add but I'm receiving an error since sendAsync and even send don't return a value. Any idea how I can handle it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants