I have the following code snippet:
pragma solidity ^0.5.1;
contract Puzzle {
address payable public owner ;
bool public locked ;
uint public reward ;
bytes32 public diff ;
bytes public solution ;
constructor () public {
owner = msg.sender ;
reward = msg.value ;
locked = false ;
diff = bytes32 (11111); // pre - defined difficulty
}
I am getting the following error:
solc Puzzle_sha256.sol Puzzle_sha256.sol:14:12: Error: Explicit type conversion not allowed from "int_const 11111" to "bytes32".
diff = bytes32 (11111); // pre – defined difficulty
^————-^
Some body please guide me.
Zulfi.
Best Answer
First, convert
int_const
touint256
then convert it tobytes32
.and there is another problem with your contract.
You are using
msg.sender
andmsg.value
in yourconstructor
. For that you need to mark yourconstructor
aspayable
.