I’m debugging a contract and the global LatestTimestamp
instruction is putting 0 on the stack. Does anyone know a reason for this? I’m running against a private node
Just a guess : maybe that’s a limitation of dryrun, and it would work cirrectly on mainnet ?
Does that mean there’s no way to debug timestamp-related logic?
“No way to debug” is a pretty strong statement.
Don’t you think so ?
How’s about sending transactions to testnet, and examining the blocks, or even better - using local private network, or a sandbox ?
That is not a replacement for debugging. I am already using a private sandbox. If I am using tealdbg
to debug my contract, and some of that relies on checking that global LatestTimestamp
is greater or less than a stored unix timestamp value, I have to comment it out to get the code following it to execute
Edit: I should be more specific. I meant debugging using tealdbg
, which is the most efficient way to debug during development
@casper , yes I know that the tealdbg is a great tool for debugging. I just wanted to make sure you’re aware of other means to verify the correctness of your smart contract.
Would it be better if it was “just working” ? Probably.
I think that what you’re after is not a dryrun debugger ( tealdbg ) which works “detached” from the blockchain, but rather a “live” debugger. Note that live debuggers are less intuitive since repeated execution could execute diffrently.
Thanks @tsachi. I had hoped that the global LatestTimestamp
would be available, taken as a snapshot at the time of the dryrun txn
I have discovered you can set a latestTimestamp
field on the JavaScript SDK’s createDryRun
method. This seems to do the trick.
(the below uses the getUnixTime
function from the date-fns
library)
const dryRun = await algosdk.createDryrun({
client: algodClient,
txns,
latestTimestamp: getUnixTime(new Date()),
});