I am designing a lottery smart contract. A winning ticket number is drawn from a pool of tickets. In order to do this, I use the following code:
bytes32 blockhash = block.blockhash(block.number - 1); uint32 winner = uint32(blockhash) % ticketamount;
Is this a reliable and secure way to do this? I was reading online about the risks associated with using the blockhash and how this could be manipulated, however I do not fully understand the risks involved and would like further clarification into the safety of using the above code.