Skip to Content
Mastering Blockchain Programming with Solidity
book

Mastering Blockchain Programming with Solidity

by Jitendra Chittoda
August 2019
Intermediate to advanced
486 pages
13h 52m
English
Packt Publishing
Content preview from Mastering Blockchain Programming with Solidity

Custom data types with struct

Just like other languages such as C++, Solidity also supports defining structs. Structs are custom-defined data types that can group multiple variables in a single struct variable to form a new type.

By default, all struct values are initialized using their default values. For example, uint values will be initialized with 0bool values will be initialized with false; and address values will be initialized with 0x0, as follows:

contract LoanStruct {    //Definition of struct    struct LoanData {        address borrower;        address lender;        uint256 loanAmount;    }}
0x0 is the short form of a specific Ethereum address, 0x0000000000000000000000000000000000000000. This address is also used for logging purposes, especially when minting ...
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

Mastering Ethereum

Mastering Ethereum

Andreas M. Antonopoulos, Gavin Wood
Complete Cryptocurrency and Blockchain Course | Learn Solidity

Complete Cryptocurrency and Blockchain Course | Learn Solidity

Ravinder Deol, Codestars By Rob Percival, Thomas Wiesner

Publisher Resources

ISBN: 9781839218262Supplemental Content