- Inherit the DAL contract created in the previous recipe:
pragma solidity^0.4.23;import "./DAL.sol";contract WinnableDAL is DAL { //...}
- Let's look into the winning process. Ask the user to select six numbers, each ranging from 0 to 15. Since the hex value in block hash ranges from 0-15 (0-F), it will be easier to verify the prediction.
- Once the future block is mined, allow the user to validate the predicted number against the generated block hash. For example, assume that the future block is 501232 and that the predicted number is 314721. After the future block is mined, the number is validated against the last five digits of the block hash.
- Calculate the winning amount based on how many correct guesses the user has made. ...