I am using truffle 5 and ganache-cli. I've imported increaseTime as

import increaseTime from './helper/increaseTime';

and the increaseTime.js file is like this

export default function increaseTime(addSeconds) {
  const id = Date.now();

  return new Promise((resolve, reject) => {
      jsonrpc: '2.0',
      method: 'evm_increaseTime',
      params: [addSeconds],
    }, (err1) => {
      if (err1) return reject(err1);

        jsonrpc: '2.0',
        method: 'evm_mine',
        id: id + 1,
      }, (err2, res) => (err2 ? reject(err2) : resolve(res)));

I am trying to use change the time to insert the follow code

await increaseTime(24 * 60 * 60);   

But I've got error message,

TypeError: web3.currentProvider.sendAsync is not a function

Am I doing something wrong?


Change web3.currentProvider.sendAsync to web3.currentProvider.send

With truffle 5 you are using web3 1.0. However, the sendAsync is the legacy function of 0.20.

  • 1
    BTW, web3.currentProvider.send also works in Truffle 4.x (web3 0.x, as you mentioned), so your solution is compatible with both versions. – goodvibration Feb 21 '19 at 13:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.