0

solidity ^0.4.19 (works)

uint256 randNonce++;
return uint256(keccak256(msg.sender, randNonce, now))

solidity ^0.4.24 (throws)

uint256 randNonce++;
return uint256(keccak256(abi.encodePacked(msg.sender, randNonce, now)));

throws: Type uint256 is not implicitly convertible to expected type uint8

1

Is it possible your function returns(uint8) ?

This compiles:

pragma solidity 0.4.24;

contract HashToUint {

    uint256 randNonce;

    function test() public returns(uint) {
        randNonce++;
        return uint(keccak256(abi.encodePacked(msg.sender, randNonce, now)));
    }
}

Hope it helps.

  • Solved the issues! embarrassing ;) – Senju Jul 5 '18 at 6:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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