Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Solidity Programming Essentials

You're reading from  Solidity Programming Essentials

Product type Book
Published in Apr 2018
Publisher Packt
ISBN-13 9781788831383
Pages 222 pages
Edition 1st Edition
Languages

Table of Contents (17) Chapters

Title Page
Copyright and Credits
Packt Upsell
Contributors
Preface
Introduction to Blockchain, Ethereum, and Smart Contracts Installing Ethereum and Solidity Introducing Solidity Global Variables and Functions Expressions and Control Structures Writing Smart Contracts Functions, Modifiers, and Fallbacks Exceptions, Events, and Logging Truffle Basics and Unit Testing Debugging Contracts Other Books You May Enjoy Index

Writing a simple contract


A contract is declared using the contract keyword along with an identifier, as shown in the following code snippet:

contract SampleContract {
}

Within the brackets comes the declaration of state variables and function definitions. A complete definition of contract was discussed in Chapter 3, Introducing Solidity, and I am providing it again for quick reference. This contract has state variables, struct definitions, enum declarations, function definitions, modifiers, and events. State variables, structs, and enums were discussed in detail in Chapter 4, Global Variables and Functions. Functions, modifiers, and events will be discussed in detail over the next two chapters. Take a look at the following screenshot of a code snippet depicting contract:

lock icon The rest of the chapter is locked
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 $15.99/month. Cancel anytime}