Solidity programming essentials: a beginner's guide to build smart contracts for Ethereum and blockchain 9781788831383, 1788831381, 9781788838375, 1788838378

Learn the most powerful and primary programming language for writing smart contracts and find out how to write, deploy,

1,023 32 13MB

English Pages 222 [376] Year 2018

Report DMCA / Copyright

DOWNLOAD PDF FILE

Table of contents :
Title Page......Page 2
Copyright and Credits......Page 3
Solidity Programming Essentials......Page 4
Packt Upsell......Page 5
Why subscribe?......Page 6
PacktPub.com......Page 7
Contributors......Page 8
About the author......Page 9
About the reviewer......Page 10
Packt is searching for authors like you......Page 14
Preface......Page 25
Who this book is for......Page 27
What this book covers......Page 11
To get the most out of this book......Page 28
Download the example code files......Page 29
Conventions used......Page 31
Get in touch......Page 33
Reviews......Page 34
Introduction to Blockchain, Ethereum, and Smart Contracts......Page 35
What is a blockchain?......Page 37
Why blockchains?......Page 40
Cryptography......Page 42
Symmetric encryption and decryption......Page 43
Asymmetric encryption and decryption......Page 44
Hashing......Page 45
Digital signatures......Page 49
Ether......Page 50
Gas......Page 52
Blockchain and Ethereum architecture......Page 53
How are blocks related to each other?......Page 56
How are transactions and blocks related to each other?......Page 58
Ethereum nodes......Page 60
EVM......Page 61
Ethereum mining nodes......Page 62
How does mining work?......Page 64
Ethereum accounts......Page 67
Externally owned accounts......Page 68
Contract accounts......Page 69
Transactions......Page 70
Blocks......Page 76
An end-to-end transaction......Page 79
What is a contract?......Page 81
What is a smart contract?......Page 82
How to write smart contracts?......Page 83
How are contracts deployed?......Page 90
Summary......Page 92
Installing Ethereum and Solidity......Page 93
Ethereum networks......Page 95
Main network......Page 96
Test network......Page 97
Ropsten......Page 98
Rinkeby......Page 99
Kovan......Page 100
Private network......Page 101
Consortium network......Page 102
Geth......Page 103
Installing Geth on Windows......Page 104
Creating a private network......Page 109
ganache-cli......Page 119
Solidity compiler......Page 124
The web3 JavaScript library......Page 125
Mist wallet......Page 128
MetaMask......Page 132
Summary......Page 140
Introducing Solidity......Page 141
Ethereum Virtual Machine......Page 143
Solidity and Solidity files......Page 144
Pragma......Page 145
Comments......Page 147
The import statement......Page 149
Contracts......Page 150
Structure of a contract......Page 152
State variables......Page 154
Structure......Page 157
Modifiers......Page 159
Events......Page 161
Enumeration......Page 163
Functions......Page 164
Data types in Solidity......Page 167
Value types......Page 168
Passing by value......Page 170
Reference types......Page 171
Passing by reference......Page 173
Storage and memory data locations......Page 174
Rule 1......Page 176
Rule 2......Page 177
Rule 3......Page 178
Rule 4......Page 179
Rule 5......Page 180
Rule 6......Page 182
Rule 7......Page 184
Rule 8......Page 186
Literals......Page 188
Integers......Page 189
Boolean......Page 192
The byte data type......Page 194
Arrays......Page 197
Fixed arrays......Page 198
Dynamic arrays......Page 199
Special arrays......Page 200
The bytes array......Page 201
The String array......Page 203
Array properties......Page 204
Structure of an array......Page 205
Enumerations......Page 207
Address......Page 209
Mappings......Page 210
Summary......Page 216
Global Variables and Functions......Page 217
The var type variables......Page 218
Variables hoisting......Page 220
Variable scoping......Page 222
Type conversion......Page 224
Implicit conversion......Page 225
Explicit conversion......Page 226
Block and transaction global variables......Page 229
Transaction and message global variables......Page 231
Difference between tx.origin and msg.sender......Page 234
Cryptography global variables......Page 235
Address global variables......Page 237
Contract global variables......Page 238
Summary......Page 239
Expressions and Control Structures......Page 240
Solidity expressions......Page 241
The if decision control......Page 247
The while loop......Page 249
The for loop......Page 251
The do...while loop......Page 253
The break statement......Page 255
The continue statement......Page 257
The return statement......Page 259
Summary......Page 261
Writing Smart Contracts......Page 262
Smart contracts......Page 263
Writing a simple contract......Page 264
Creating contracts......Page 266
Using the new keyword......Page 267
Using address of a contract......Page 269
Constructors......Page 271
Contract composition......Page 273
Inheritance......Page 274
Single inheritance......Page 275
Multi-level inheritance......Page 277
Hierarchical inheritance......Page 278
Multiple inheritance......Page 279
Encapsulation......Page 283
Polymorphism......Page 284
Function polymorphism......Page 285
Contract polymorphism......Page 287
Method overriding......Page 289
Abstract contracts......Page 291
Interfaces......Page 293
Summary......Page 295
Functions, Modifiers, and Fallbacks......Page 296
Function input and output......Page 298
Modifiers......Page 301
The view, constant, and pure functions......Page 305
The address functions......Page 309
The send method......Page 310
The transfer method......Page 312
The call method......Page 313
The callcode method......Page 317
The delegatecall method......Page 318
The fallback function......Page 319
Summary......Page 323
Exceptions, Events, and Logging......Page 324
Error handling......Page 326
The require statement......Page 327
The assert statement......Page 329
The revert statement......Page 331
Events and logging......Page 332
Summary......Page 338
Truffle Basics and Unit Testing......Page 339
Application development life cycle management......Page 340
Truffle......Page 341
Development with Truffle......Page 344
Testing with Truffle......Page 352
Summary......Page 356
Debugging Contracts......Page 357
Debugging......Page 358
The Remix editor......Page 359
Using events......Page 365
Using a Block Explorer......Page 366
Summary......Page 372
Other Books You May Enjoy......Page 373
Leave a review - let other readers know what you think......Page 376

Solidity programming essentials: a beginner's guide to build smart contracts for Ethereum and blockchain
 9781788831383, 1788831381, 9781788838375, 1788838378

  • 0 0 0
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up
File loading please wait...
Recommend Papers