Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Ethereum Cookbook

You're reading from   Ethereum Cookbook Over 100 recipes covering Ethereum-based tokens, games, wallets, smart contracts, protocols, and Dapps

Arrow left icon
Product type Paperback
Published in Aug 2018
Publisher Packt
ISBN-13 9781789133998
Length 404 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Manoj P R Manoj P R
Author Profile Icon Manoj P R
Manoj P R
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Getting Started 2. Smart Contract Development FREE CHAPTER 3. Interacting with the Contract 4. The Truffle Suite 5. Tokens and ICOs 6. Games and DAOs 7. Advanced Solidity 8. Smart Contract Security 9. Design Decisions 10. Other Protocols and Applications 11. Miscellaneous 12. Other Books You May Enjoy

Control structures in Solidity

Most of the control structures from other languages are also supported in solidity. In this recipe, you will learn about supported control structures in solidity, along with examples. The semantics are very similar to C or JavaScript.

How to do it...

  1. If-else condition statements are used to perform different actions based on different conditions. Create a function, isValid, which returns true for input values greater than 10 and returns false otherwise:
pragma solidity ^0.4.23;

contract test {
function isValid(uint input) public pure
returns (bool) {
if (input > 10) {
return true;
} else {
return false;
}
}
}

Solidity doesn't support...

You have been reading a chapter from
Ethereum Cookbook
Published in: Aug 2018
Publisher: Packt
ISBN-13: 9781789133998
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime