I expected to be able to print out the time in a contract but...
print(current_time());
didn't get compiled and I get the error "use of undeclared identifier 'current_time'"
EOS.IO Stack Exchange is a question and answer site for users and developers of distributed applications built on top of the blockchain operating system, EOS.IO. It only takes a minute to sign up.
Sign up to join this communityI expected to be able to print out the time in a contract but...
print(current_time());
didn't get compiled and I get the error "use of undeclared identifier 'current_time'"
Time is treated in a special way inside the blockchain. The main reason for the limitation is that the blockchain data needs to be consistent and reproducible so playback of the blockchain reaches the same state.
This should work:
print(now());
In more recent version of eosio.cdt, now(), which used to return the seconds since the beginning of the unix epoch, has been removed.
The new way of doing this would be:
#include <eosio/system.hpp>
print(current_time_point().sec_since_epoch());