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?

1 Answer 1


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. Feb 21, 2019 at 13:05
  • changing "sendAsync" to "send" gives me Uncaught TypeError: callback is not a function
    – Jim
    Oct 2, 2021 at 0:07
  • @Jim i got the same error, have you find any solution?
    – gabkov
    Apr 21, 2022 at 7:22
  • Maybe try to change web3.currentProvider.send.bind(web3.currentProvider)? Jul 26, 2022 at 9:03
  • @gabkov To fix the "callback is not a function" you need to pass a second parameter to the "send" function because the newer version of it takes a function as its second parameter. Example: <code> web3.currentProvider.send({ jsonrpc: "2.0", method: "evm_increaseTime", params: [864000], id: 0 },(err1) => { if(err1){ return reject(err1); } });</code> Aug 10, 2022 at 6:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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