Instant ebooks textbook Hands On Smart Contract Development with Solidity and Ethereum From Fundamentals to Deployment 1st Edition Kevin Solorio download all chapters
Instant ebooks textbook Hands On Smart Contract Development with Solidity and Ethereum From Fundamentals to Deployment 1st Edition Kevin Solorio download all chapters
com
https://ebookmeta.com/product/hands-on-smart-contract-
development-with-solidity-and-ethereum-from-fundamentals-to-
deployment-1st-edition-kevin-solorio/
OR CLICK BUTTON
DOWNLOAD NOW
https://ebookmeta.com/product/building-games-with-ethereum-smart-
contracts-intermediate-projects-for-solidity-developers-kedar-iyer/
ebookmeta.com
https://ebookmeta.com/product/axisymmetry-in-mechanical-
engineering-1st-edition-emanuel-willert/
ebookmeta.com
Metal Nano 3D Superlattices Synthesis Properties and
Applications 1st Edition Marie-Paule Pileni
https://ebookmeta.com/product/metal-nano-3d-superlattices-synthesis-
properties-and-applications-1st-edition-marie-paule-pileni/
ebookmeta.com
https://ebookmeta.com/product/digital-research-methods-for-
translation-studies-julie-mcdonough-dolmaya/
ebookmeta.com
https://ebookmeta.com/product/physics-of-biological-action-and-
perception-1st-edition-mark-l-latash/
ebookmeta.com
https://ebookmeta.com/product/dragon-s-tears-1st-edition-eva-chase/
ebookmeta.com
https://ebookmeta.com/product/paving-the-way-the-first-american-women-
law-professors-law-in-the-public-square-book-1-1st-edition-kay/
ebookmeta.com
Hands-On
Smart Contract
Development
with Solidity & Ethereum
From Fundamentals to Deployment
Kevin Solorio,
Randall Kanna
& David H. Hoover
Hands-On Smart Contract
Development with Solidity and
Ethereum
From Fundamentals to Deployment
The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. Hands-On Smart Contract Development
with Solidity and Ethereum, the cover image, and related trade dress are trademarks of O’Reilly Media,
Inc.
The views expressed in this work are those of the authors, and do not represent the publisher’s views.
While the publisher and the authors have used good faith efforts to ensure that the information and
instructions contained in this work are accurate, the publisher and the authors disclaim all responsibility
for errors or omissions, including without limitation responsibility for damages resulting from the use of
or reliance on this work. Use of the information and instructions contained in this work is at your own
risk. If any code samples or other technology this work contains or describes is subject to open source
licenses or the intellectual property rights of others, it is your responsibility to ensure that your use
thereof complies with such licenses and/or rights.
978-1-492-04526-7
[LSI]
Table of Contents
Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
2. Decentralized Applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Tokens 23
ERC-20 23
Non-Fungible Token (ERC-721) 25
Supply Chain 26
Permanent Records 28
iii
Evaluating Blockchain for Your Application 29
Verifiable 29
Transparent 29
Resilient 29
Summary 30
iv | Table of Contents
Setting the Beneficiary and Custodian 101
Editing the Beneficiary 104
Making Donations 109
Structs 111
Mappings 112
Donation Tests 112
myDonations 116
Fundraiser Totals 119
Events 124
Withdrawing Funds 126
Fallback Functions 131
Summary 134
7. FundraiserFactory. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Migrating Our FundraiserFactory 135
Creating Fundraisers 137
Viewing Available Fundraisers 142
Testing Pagination When Empty 142
Testing the Limit 144
Testing the Offset 147
Setting Up the UI 151
Summary 152
Table of Contents | v
Dev Setup 164
Truffle 165
React Truffle Box Setup 166
Importing our Greeter Contracts 172
Adding Our Greeter Contract Functionality 173
Setting Our Greeting Through React 175
Summary 176
vi | Table of Contents
External Auditing 240
Auditing Companies 240
Solidified 240
Free Auditing Resources 240
Growing Your Auditing Skills 241
Summary 241
Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
We wrote this book to make smart contract development more accessible and easy to
understand for beginners looking to explore developing on the blockchain.
It can be daunting when you have terms such as networks, nodes, and forks being
thrown around. This book will help you learn how to create and test your own smart
contract, create a frontend for users to interact with, and more. We wrote this book
because we want to provide a resource for people who want to break into the field but
don’t know where to start. We’ve had so many people ask us how they can get started
and tell us how overwhelmed they feel about diving into the blockchain. Even engi‐
neers with years of experience don’t know where to start when trying to dive into
smart contract development.
This book will guide you through the entire process of building a smart contract like
you would in the real world, and deploying it to help users interact with it through an
application.
This book is for anyone who wants to dive into blockchain development and get
hands-on experience writing smart contracts. You should have an editor as well as
some basic engineering knowledge like how to start a terminal.
There are various ways you can get involved in the community and learn more about
smart contract development beyond this book. Here are a few to check out.
Mastering Ethereum
O’Reilly has another book, Mastering Ethereum by Andreas Antonopoulos and Gavin
Wood, which is a deep dive on Ethereum. While this book focuses on getting hands-
on experience with smart contract development, Mastering Ethereum will provide you
with a deeper dive into topics like cryptography, wallets, transactions, and more.
ix
ConsenSys Academy
ConsenSys, the global blockchain company, offers a course on Ethereum develop‐
ment. The course is available twice a year and the company hires from within the
program. The 11-week course offers active support from instructors and a connec‐
tion with the rest of the cohort.
The nice thing about the ConsenSys course is that it offers a certification upon com‐
pletion of the quizzes and the final project. The top students in the cohort are also
considered for employment inside ConsenSys.
B9 Academy
If you’re just starting out with Ethereum and want to learn more, B9 Academy offers
a free Ethereum course available to anyone. Introduction to Ethereum for Developers
gives you an overview of the basics of Ethereum. The course will walk through an
introduction to Ethereum development such as how private keys work, what a merkle
tree is, what the differences are between the types of networks, and more. While no
certification is offered for the free course, this is a great way to dip your toes into
Ethereum development and determine if a paid course might be for you.
Another option is the paid course from B9, which is one of the best online courses on
Ethereum currently available. The course has extensive content and offers a certificate
upon completion. You’ll build three projects and have access to the B9 Slack, which is
a great resource for connecting with other people in the community and getting help
with Ethereum questions or projects. The course also offers instructors for tutoring
and mentorship throughout the duration of the course. If you do well on the final
exam, you’ll receive the B9 certification.
x | Preface
Constant width italic
Shows text that should be replaced with user-supplied values or by values deter‐
mined by context.
Preface | xi
If you feel your use of code examples falls outside fair use or the permission given
above, feel free to contact us at [email protected].
Our unique network of experts and innovators share their knowledge and expertise
through books, articles, conferences, and our online learning platform. O’Reilly’s
online learning platform gives you on-demand access to live training courses, in-
depth learning paths, interactive coding environments, and a vast collection of text
and video from O’Reilly and 200+ other publishers. For more information, please
visit http://oreilly.com.
How to Contact Us
Please address comments and questions concerning this book to the publisher:
We have a web page for this book, where we list errata, examples, and any additional
information. You can access this page at https://oreil.ly/handsOn-smart-contract-dev-
solidity-ethereum.
Email [email protected] to comment or ask technical questions about this
book.
For more information about our books, courses, conferences, and news, see our web‐
site at http://www.oreilly.com.
Find us on Facebook: http://facebook.com/oreilly
Follow us on Twitter: http://twitter.com/oreillymedia
Watch us on YouTube: http://www.youtube.com/oreillymedia
xii | Preface
Acknowledgments
We would like to thank our editor, Melissa Potter from O’Reilly, for all the feedback
and guidance as we were writing this book. We would also like to thank our tech
reviewers, Brian Wu, John Mardlin, and Destry Saul, for their detailed feedback and
recommendations on how to improve our examples. Thanks also go to our earlier
reviewers Alina Chu, Phillip Birtcher, and Corey Haines for their insights as we were
just getting started in our writing journey.
Kevin would like to thank his partner Alyssa for all the support and encouragement
during crunch time. He would also like to thank his mother Peggy and brother Luis
for always encouraging him to take chances and pursue his dreams.
Randall would like to thank her partner Jack for supporting her in everything she
does. Always. And her family of authors who inspired her to write this book and
always have grit. And her Aunt Kat, who always gives encouragement and support at
any hour of the day and any day of the week.
Dave would like to thank Kevin and Randall for working valiantly to finish this book!
Also thanks to Brian Forde for nudging him down the blockchain rabbit hole, and
Conrad Barski for his mentoring, leadership, and camaraderie. Finally, he would like
to thank his partner Heather Corallo for her encouragement and insights.
Preface | xiii
Other documents randomly have
different content
Bram stared at the farmhouse, the windows of which were shining
like jewels in the setting sun. He felt sick and cold.
What was the meaning of this secret visit of Chris Cornthwaite to
Claire on his wedding day?
CHAPTER XIII.
AN ILL-MATCHED PAIR.
Bram was away much longer than the ten days he had expected.
Difficulties arose in the transaction of the affair which had called him
to London; he had to take a trip to Brussels, to return to London, and
then to visit Brussels again. It was two months after his departure
from Sheffield before he came back.
In the meantime old Abraham Elshaw, his namesake, had died. A
letter was forwarded to Bram informing him of the fact, and also that
by the direction of the deceased the precious box in which the old
man had kept his property had been sent to Bram’s address at
Hessel.
Bram acknowledged the letter, and sent directions to his landlady for
the safe keeping of the box containing his legacy.
When he got back home to his lodging, one cold night at the end of
November, Bram received the box, and set about examining its
contents. It was a strong oak miniature chest, hinged and padlocked.
As there was no key, Bram had to force the padlock. The contents
were varied and curious. On the top was a Post Office Savings Bank
book, proving the depositor to have had two hundred and thirty-five
pounds to his credit. Next came a packet of papers relating to old
Elshaw’s transactions with a building society, by the failure of which
he appeared to have lost some ninety-six pounds. Then there were
some gas shares and some deeds which proved him to have been
the owner of certain small house property in the village where he had
lived. Next came a silver teapot, containing nothing but some scraps
of tissue paper and a button. And at the bottom of the box was a
very old-fashioned man’s gold watch, with a chased case, a large
oval brooch containing a woman’s hair arranged in a pattern on a
white ground, and a broken gold sleeve-link.
Bram, who, from inquiries he had made, considered himself at liberty
to apply all the money to his own uses, the other relations of old
Abraham not being near enough or dear enough to have a right to a
share, looked thoughtfully at the papers, and then put them carefully
away. He knew what the old man had apparently not known, that
there were formalities to be gone through before he could claim the
house property. He should have to consult a solicitor. There was no
doubt that his windfall would prove more valuable than he had
expected, and again his thoughts flew to Claire, and he asked
himself whether there was a chance that he might be able to devote
his little fortune to the building of that palace which his love had
already planned—in the air.
He told himself that he was a fool to be so diffident, but he could not
drive the feeling away. The truth was that there was still at the
bottom of his heart some jealousy left of the lively Chris, some proud
doubt whether Claire’s heart was as free as she had declared it to
be.
But if, on the one hand, she had spoken compassionately of her
erring cousin, there was to be remembered, as a set-off against that,
the delicious moment when she had stood contented in the shelter of
Bram’s own arms on that memorable evening when he had, for the
second time, protected her from the violence of her father.
On the whole, Bram felt that it was time to make the plunge; now,
when he had money at his command, when he was in a position to
take her right out of her dangers and her difficulties. With Theodore,
who was not without intelligence, a bargain could be made, and
Bram could not doubt that this moment, when the supplies had been
cut off at Holme Park, and the farm was going to ruin, would be a
favorable one for his purpose.
He resolved to go boldly to Claire the very next day.
When the morning broke, a bright, clear morning, with a touch of
frost in the air, Bram sprung out of bed with the feeling that there
were great things to be done. The sun was bright on the hill when he
started, though down far below his feet the town lay buried in a
smoky mist. Just before he reached the farmyard gate he paused,
looking eagerly for the figure which was generally to be seen busily
engaged about the place at this hour of the morning.
But he was disappointed. Claire was nowhere to be seen.
Reluctantly Bram went on his way down the hill, when the chirpy,
light voice of Theodore Biron, calling to him from the front of the
house, made him stop and turn round. Mr. Biron was in riding
costume, with a hunting crop in his hand. He was very neat, very
smart, and far more prosperous-looking than he had been for some
time. He played with his moustache with one hand, while with the
other he jauntily beckoned Bram to come back.
“Hallo!” said Bram, returning readily enough on the chance of seeing
Claire. “Where are you off to so early, Mr. Biron? I didn’t think you
ever tried to pick up the worm.”
“Going to have a day with the hounds,” replied Theodore cheerfully.
“They meet at Clinker’s Cross to-day. I picked up a clever little mare
the other day—bought her for a mere song, and I am going to try her
at a fence or two. Come round and see her. Do you know anything
about hunters, Elshaw?”
“No,” replied the astonished Bram, who knew that Mr. Biron’s purse
had not lately allowed him to know much about hunters either.
“Ah!” said Theodore, as he opened the garden gate for Bram to
enter, and led him into the house. “All the better for you. When
you’ve once got to think you know something about horse-flesh, you
can’t sit down quietly without a decent nag or two in your stable.”
And Mr. Biron, whose every word caused Bram fresh astonishment,
flung back the door of the kitchen with a jaunty hand.
Bram followed him, but stopped short at the sight which met his
eyes.
Springing up with a low cry from a stool by the fire on Bram’s
entrance, Claire, with a face so white, so drawn that he hardly knew
her, stared at him with a fixed look of horror which seemed to freeze
his blood.
“Miss Claire!” he said hoarsely.
She said nothing. With her arms held tightly down by her sides, she
continued to stare at him as if at some creature the sight of whom
had seized her with unspeakable terror. He came forward, much
disturbed, holding out his hand.
“Come, come, Claire, what’s the matter with you? Aren’t you glad to
see Bram Elshaw back among us?” said Theodore impatiently.
Still she did not move. Bram, chilled, frightened, did not know what to
do. Mr. Biron left the outer door, by which he stood, and advanced
petulantly towards his daughter. But before he could reach her she
staggered, drew away from him, and with a frightened glance from
Bram to him, fled across the room and disappeared.
Bram was thrown into the utmost consternation by this behavior. He
had turned to watch the door by which she had made her escape,
when Theodore seized him by the arm, and dragged him impatiently
towards the outer door.
“Come, come,” said he, “don’t trouble your head about her. She’s not
been well lately; she’s been out of sorts. I’ve talked of leaving the
place, and she doesn’t like the idea. She’ll soon be herself again.
Her cousin Chris has been round two or three times since his return
from his honeymoon trying to cheer her up. But she won’t be
cheered; I suppose she enjoys being miserable sometimes. Most
ladies do.”
Bram, who had followed Mr. Biron with leaden feet across the
farmyard towards the stables, felt that a black cloud had suddenly
fallen upon his horizon. The mention of Chris filled him with poignant
mistrust, with cruel alarm. He felt that calamity was hanging over
them all, and that the terrible look he had seen in Claire’s eyes was
prophetic of coming evil. He hardly saw the mare of which Theodore
was so proud; hardly heard the babble, airily ostentatious, cheerily
condescending, which Claire’s father dinned into his dull ears. He
was filled with one thought. These new extravagances of
Theodore’s, the look in Claire’s face, were all connected with Chris,
and with his renewed visits. Bram felt as if he should go mad.
When he reached the office he watched for an opportunity to get
speech alone with Christian. But he was unsuccessful. Bram did not
even see him until late in the day.
Long before that Bram had had an interview with the elder Mr.
Cornthwaite, which only confirmed his fears. He had to give an
account to the head of the firm of the business he had transacted
while away. He had carried it through with great ability, and Mr.
Cornthwaite complimented him highly upon the promptitude,
judgment, and energy he had shown in a rather difficult matter.
“My son Christian was perfectly right,” Mr. Cornthwaite went on, “in
recommending me to send you away on this affair, Elshaw. You
seem to have an old head upon young shoulders. I only hope he
may do half as well on the mission with which he himself is to be
entrusted.”
Bram looked curious.
“Is Mr. Christian going away again so soon, sir?” asked he.
Mr. Cornthwaite, whose face bore traces of some unaccustomed
anxiety, frowned.
“Yes,” he answered shortly. “I am sorry to say that he and his wife
don’t yet rub on so well as one could wish together. You see I tell you
frankly what the matter is, and you can take what credit you please
to yourself for having predicted it. No doubt they will shake down in
time, but on all accounts I think it is as well, as there happens to be
some business to be done down south, to send him away upon it. He
will only be absent a few weeks, and in the meantime any little
irritation there may be on both sides will have had time to rub off.”
Bram looked blank indeed.
He was more anxious than ever for a few words alone with Chris, but
he was unable to obtain them. When his employer’s son appeared at
the office, which was not till late in the day, he carefully avoided the
opportunity Bram sought. After shaking hands with him with a dash
and an effusion which made it impossible for the other to draw back,
even if he had been so inclined, Chris, with a promise of “seeing him
presently,” went straight into his father’s private office, and did not
reappear in the clerks’ office at all.
In spite of the boisterous warmth of his greeting, Bram had noticed in
Christian two things. The first was a certain underlying coldness and
reserve, which put off, under an assumption of affectionate
familiarity, the confidences which had been the rule between them.
The other was the fact that Christian looked thin and worried.
Bram lingered about the office till long after his usual hour of leaving
in the hope of catching Christian. And it was at last only by chance
that he learnt that Chris had gone some two hours before, and,
further, that he was to start for London that very evening.
Now, this discovery worried Bram, and set him thinking. The
intercourse between him and Christian had been of so familiar a kind
that this abrupt departure, without any sort of leave-taking, could
only be the result of some great change in Christian’s feeling
towards himself. So strong, although vague, were his fears that
Bram when he left the office went straight to the new house in a
pretty suburb some distance out of Sheffield, where Christian had
settled with his bride. Here, however, he was met with the
information that Mr. Christian had already started on his journey, and
that he had gone, not from his own, but from his father’s house.
As Bram left the house he saw the face of young Mrs. Christian
Cornthwaite at one of the windows. She looked pale, drawn,
unhappy, and seemed altogether to have lost the smug look of self-
satisfaction which he had disliked in her face on his first meeting with
her.
Much disturbed, Bram went away, and returned to his lodging,
passing by the farm, where there was no sign of life to induce him to
pause. It was nine o’clock, and as there was no light in any of the
windows, he concluded that Mr. Biron had gone to bed, tired out with
his day’s hunting, and that Claire had followed his example.
He felt so restless, so uneasy, however, that instead of passing on
he lingered about, walking up and down, watching the blank, dark
windows, almost praying for a flicker of light in any one of them for a
sign of the life inside.
After an hour of this unprofitable occupation, he took himself to task
for his folly, and went home to bed.
On the following morning, before he was up, there was a loud
knocking at the outer door of the cottage where he lived. Bram, with
a sense of something wrong, something which concerned himself,
ran down himself to open it.
In the middle of the little path stood Theodore Biron, with the same
clothes that he had worn on the morning of the previous day, but
without the hunting-crop.
He was white, with livid lips, and his limbs trembled.
“What’s the matter?” asked Bram in a muffled voice.
“Claire, my daughter Claire!” stammered Theodore in a voice which
sounded shrill with real feeling. All the jauntiness, all the vivacity, had
gone out of him. He shivered with something which was keener than
cold.
“Well?” said Bram, with a horrible chill at his heart.
“She’s—she’s gone, gone!” said Theodore, reeling back against the
fence of the little garden. “She’s run away. She’s run right away.
She’s left me, left her poor old father! Don’t you understand? She is
gone, man, gone!”
And Mr. Biron, for once roused to genuine emotion, broke into sobs.
Bram stood like a stone.
CHAPTER XV.
PARENT AND LOVER.