Truffle: Using Web3 1.0 BatchRequests with Truffle contract calls

Created on 28 Oct 2018  路  3Comments  路  Source: trufflesuite/truffle

Issue

Get an error when using Web3 1.0 batch requests with truffle contract calls:

TypeError: Cannot set property 'requestManager' of null
    at Batch (./node_modules/web3-core-requestmanager/src/batch.js:29:25)
    at module.exports (./migrations/migrate_to_latest.js:50:26)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7

I've Googled around a bit for this, but I can't really see any attempts of people trying to use batch requests with truffle, or whether it's intended to be supported.

Steps to Reproduce

Create a web3 BatchRequest and add a truffle call to it:

let batch = web3.BatchRequest();
batch.add(newPoolOwners.setContribution(
    ownersObj.owners[i].address, 
    ownersObj.owners[i].tokenAmount
));

Expected Behavior

Batch request is built with multiple transactions and executes fine.

Actual Results

Error above is given.

Environment

  • Operating System: W10 Pro
  • Ethereum client: Ganache CLI v6.1.6 (ganache-core: 2.1.5)
  • Truffle version (truffle version):
Truffle v4.1.14 (core: 4.1.14)
Solidity v0.4.24 (solc-js)
  • node version (node --version): v8.9.3
  • npm version (npm --version): 6.4.1

All 3 comments

@jleeh Web3.js 1.0 is only supported in Truffle v5 beta or higher. Please try out the beta by running the following commands:

npm uninstall -g truffle
npm install -g truffle@beta

And let me know if that works for you. Thanks!

I tried with Truffle v5 and got the same error I mentioned in the original issue. I'm going to close this issue as I think it's deps problem rather than an actual one, then I just ran single TX's rather than batching. Thanks for the help though @gnidan

@jleeh Were you able to solve this issue?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Katsu1991 picture Katsu1991  路  3Comments

ferittuncer picture ferittuncer  路  3Comments

timothywangdev picture timothywangdev  路  3Comments

tcurdt picture tcurdt  路  3Comments

EmanHerawy picture EmanHerawy  路  3Comments