Web3.js: batch request throws error

Created on 12 Sep 2018  路  1Comment  路  Source: ChainSafe/web3.js

I have a parity poa network running and when I try to make batch requests I get the error:

Error: JSONRPC method should be specified for params: "undefined"!
    at Object.Jsonrpc.toPayload (/Users/aaron/workspace/nw_test/node_modules/web3-core-requestmanager/src/jsonrpc.js:42:15)
    at /Users/aaron/workspace/nw_test/node_modules/web3-core-requestmanager/src/jsonrpc.js:84:24
    at Array.map (<anonymous>)
    at Object.Jsonrpc.toBatchPayload (/Users/aaron/workspace/nw_test/node_modules/web3-core-requestmanager/src/jsonrpc.js:83:21)
    at RequestManager.sendBatch (/Users/aaron/workspace/nw_test/node_modules/web3-core-requestmanager/src/index.js:163:27)
    at Batch.execute (/Users/aaron/workspace/nw_test/node_modules/web3-core-requestmanager/src/batch.js:50:25)
    at decryptedAccount.signTransaction.then.signedTx (/Users/aaron/workspace/nw_test/makeTx.js:46:26)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

My code is:

    const batch = new web3.BatchRequest();

    return decryptedAccount.signTransaction(rawTransaction)
        .then(signedTx => {
            batch.add(web3.eth.sendSignedTransaction(signedTx.rawTransaction));
            batch.execute();
        })
        .catch(console.error);

web3 version: 1.0.0-beta.36
node version: 8.9.3

bug

Most helpful comment

The problem is that you're using the batch request the wrong way.

Try it with:

batch.add(web3.eth.sendSignedTransaction.request(signedTx.rawTransaction);

>All comments

The problem is that you're using the batch request the wrong way.

Try it with:

batch.add(web3.eth.sendSignedTransaction.request(signedTx.rawTransaction);
Was this page helpful?
0 / 5 - 0 ratings

Related issues

webersson picture webersson  路  3Comments

zamoore picture zamoore  路  3Comments

sundbry picture sundbry  路  3Comments

TinyWJL picture TinyWJL  路  3Comments

mishell-trickster picture mishell-trickster  路  3Comments