This question already has an answer here:

I am creating smart contracts with truffle and testrpc. When writing unit tests I wish to change the block time to simulate different times that smart contracts may be called. How does one set evm_increaseTime inside truffle console?

marked as duplicate by Achala Dissanayake, flygoing, ivicaa, Richard Horrocks, Ismael Feb 23 '18 at 14:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


You need to send JSON-RPC request to testrpc. Here is a helper function to call it from console:

const increaseTime = addSeconds => {
        jsonrpc: "2.0", 
        method: "evm_increaseTime", 
        params: [addSeconds], id: 0

Now you can use it to adjust time of the next block:

truffle(development)> web3.eth.getBlock(web3.eth.blockNumber).timestamp
truffle(development)> increaseTime(12345)
{ id: 0, jsonrpc: '2.0', result: 1500312345 }
truffle(development)> web3.eth.sendTransaction({from: web3.eth.accounts[0]})
truffle(development)> web3.eth.getBlock(web3.eth.blockNumber).timestamp
  • This doesn't work anymore. Using truffle 5.0.30 and web3 1.2.0, I'm getting Uncaught TypeError: callback is not a function – Paul Berg Aug 7 at 13:45

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