I'm having a problem with the blockhash function at remix.ethereum.org. Despite several attempts with different codes the blockhash function always causes problems and the result is that all variables are returned with a value of zero.
In the case below, the _previousBlockNumber variable always return zeroed. If the blockhash function line is commented out then the error does not occur and at least the _previousBlockNumber variable returns correctly.
I've tried several different versions of compilers.
pragma solidity ^0.5.5;
contract Test {
constructor() public {
}
function rand() public view returns(uint,bytes32) {
uint _previousBlockNumber;
bytes32 _previousBlockHash;
_previousBlockNumber = uint(block.number - 1);
bytes32 _previousBlockHash = bytes32(blockhash(_previousBlockNumber));
return (_previousBlockNumber,_previousBlockHash);
}
}
It's a bug issue?
Thanks for any help.