In a nutshell Im not understanding why my deployed TimedCrowdsale never opens
Deploying a TimeCrowdsale contract to the Truffle development network
In my migration script I deploy the TimeCrowdsale contract. After deployment I realise the crowdsale never gets to open state. Every time i run the debug script i get the same result.
Executing crowdsale_debug.js
crowdsale open?: false
crowdsale opening time: 1641354700
crowdsale closing time: 1641355000
Latest block timestamp: 1641354615
The isOpen() function of the TimedCrowdsale.sol is as follow
function isOpen() public view returns (bool) {
return block.timestamp >= _openingTime && block.timestamp <= _closingTime;
}
I know that in testing you can use the openzep testhelpers to advance time. But how will I do so outside of testing?
The block timestamp is lower than the opening time. So this part of the expression returns false
// 1641354615 >= 1641354700 // false
block.timestamp >= _openingTime
which causes the isOpen()
function to return false
.
You can increase the Ganache (Truffle development network) time using the evm_increaseTime
JSON-RPC method, passing it the amount of seconds as the only parameter.
Outside of the test script, you can send a CURL request to your local Ganache network:
curl -X POST \
http://localhost:7545 \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "1.0",
"id": "curltest",
"method": "evm_increaseTime",
"params": [
100000
]
}'