Skip to Content
Ethereum Cookbook
book

Ethereum Cookbook

by Manoj P R
August 2018
Intermediate to advanced
404 pages
11h 19m
English
Packt Publishing
Content preview from Ethereum Cookbook

How to do it…

  1. Inherit the DAL contract created in the previous recipe:
pragma solidity^0.4.23;import "./DAL.sol";contract WinnableDAL is DAL {    //...}
  1. 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.
  2. 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.
  3. Calculate the winning amount based on how many correct guesses the user has made.  ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Building Ethereum Dapps

Building Ethereum Dapps

Roberto Infante
Ethereum For Dummies

Ethereum For Dummies

Michael G. Solomon

Publisher Resources

ISBN: 9781789133998Supplemental Content