100% found this document useful (1 vote)
1K views48 pages

Solidity Programming Essentials: A Guide To Building Smart Contracts and Tokens Using The Widely Used Solidity Language 2nd Edition Ritesh Modi Download

The document is a promotional overview of the book 'Solidity Programming Essentials: A guide to building smart contracts and tokens using the widely used Solidity language' by Ritesh Modi. It includes links to download the book and mentions other related titles on Ethereum and smart contract development. The book aims to provide comprehensive knowledge on Solidity and its applications in blockchain technology.

Uploaded by

tlozceh9952
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
1K views48 pages

Solidity Programming Essentials: A Guide To Building Smart Contracts and Tokens Using The Widely Used Solidity Language 2nd Edition Ritesh Modi Download

The document is a promotional overview of the book 'Solidity Programming Essentials: A guide to building smart contracts and tokens using the widely used Solidity language' by Ritesh Modi. It includes links to download the book and mentions other related titles on Ethereum and smart contract development. The book aims to provide comprehensive knowledge on Solidity and its applications in blockchain technology.

Uploaded by

tlozceh9952
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 48

Solidity Programming Essentials: A guide to

building smart contracts and tokens using the


widely used Solidity language 2nd Edition Ritesh
Modi download
https://ebookmeta.com/product/solidity-programming-essentials-a-
guide-to-building-smart-contracts-and-tokens-using-the-widely-
used-solidity-language-2nd-edition-ritesh-modi/

Download full version ebook from https://ebookmeta.com


We believe these products will be a great fit for you. Click
the link to download now, or visit ebookmeta.com
to discover even more!

Building Games with Ethereum Smart Contracts:


Intermediate Projects for Solidity Developers Kedar
Iyer

https://ebookmeta.com/product/building-games-with-ethereum-smart-
contracts-intermediate-projects-for-solidity-developers-kedar-
iyer/

Beginning Ethereum Smart Contracts Programming: With


Examples in Python, Solidity, and JavaScript, 2nd
Edition Wei-Meng Lee

https://ebookmeta.com/product/beginning-ethereum-smart-contracts-
programming-with-examples-in-python-solidity-and-javascript-2nd-
edition-wei-meng-lee/

Blockchain and Ethereum Smart Contract Solution


Development: Dapp Programming with Solidity 1st Edition
Weijia Zhang

https://ebookmeta.com/product/blockchain-and-ethereum-smart-
contract-solution-development-dapp-programming-with-solidity-1st-
edition-weijia-zhang/

Between Romanticism and Modernism Four Studies in the


Music of the Later Nineteenth Century Carl Dahlhaus

https://ebookmeta.com/product/between-romanticism-and-modernism-
four-studies-in-the-music-of-the-later-nineteenth-century-carl-
dahlhaus/
Studies in Inductive Logic and Probability Volume 2
Richard C. Jeffrey (Editor)

https://ebookmeta.com/product/studies-in-inductive-logic-and-
probability-volume-2-richard-c-jeffrey-editor/

Power Electronics 1st Edition Daniel W. Hart

https://ebookmeta.com/product/power-electronics-1st-edition-
daniel-w-hart/

Freezer Burn: A Military Sci-fi Series (Waymaker Wars


Book 2) Rachel Aukes

https://ebookmeta.com/product/freezer-burn-a-military-sci-fi-
series-waymaker-wars-book-2-rachel-aukes/

Teaching for Successful Intelligence To Increase


Student Learning and Achievement 2nd Edition Robert J
Sternberg Elena L Grigorenko

https://ebookmeta.com/product/teaching-for-successful-
intelligence-to-increase-student-learning-and-achievement-2nd-
edition-robert-j-sternberg-elena-l-grigorenko/

The Ethics of Hooking Up Casual Sex and Moral


Philosophy on Campus 1st Edition James Rocha

https://ebookmeta.com/product/the-ethics-of-hooking-up-casual-
sex-and-moral-philosophy-on-campus-1st-edition-james-rocha/
Tempted by the Forbidden Mate 1st Edition Ellie Pond

https://ebookmeta.com/product/tempted-by-the-forbidden-mate-1st-
edition-ellie-pond/
Solidity
Programming
Essentials
Second Edition

A guide to building smart contracts and tokens using


the widely used Solidity language

Ritesh Modi

BIRMINGHAM—MUMBAI
Solidity Programming Essentials
Second Edition
Copyright © 2022 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or
transmitted in any form or by any means, without the prior written permission of the publisher,
except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the
information presented. However, the information contained in this book is sold without warranty,
either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors,
will be held liable for any damages caused or alleged to have been caused directly or indirectly by
this book.
Packt Publishing has endeavored to provide trademark information about all of the companies
and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing
cannot guarantee the accuracy of this information.
Associate Group Product Manager: Richa Tripathi
Publishing Product Manager: Gebin George
Senior Editor: Rohit Singh
Content Development Editor: Kinnari Chohan
Technical Editor: Maran Fernandes
Copy Editor: Safis Editing
Project Coordinator: Manisha Singh
Proofreader: Safis Editing
Indexer: Subalakshmi Govindan
Production Designer: Shankar Kalbhor
Marketing Coordinator: Sonakshi Bubbar
First published: April 2018
Second edition: May 2022
Production reference: 1200522
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-80323-118-1
www.packt.com
Contributors
About the author
Ritesh Modi is a technologist with more than 18 years of experience. He holds a master's
degree in science in AI/ML from LJMU. He has been recognized as a Microsoft Regional
Director for his contributions to building tech communities, products, and services. He
has published more than 10 tech books in the past and is a cloud architect, speaker, and
leader who is popular for his contributions to data centers, Azure, Kubernetes, blockchain,
cognitive services, DevOps, AI, and automation.

"I want to thank the people who have been close to me and supported me,
especially my wife, Sangeeta, my daughter, Avni, and my parents."
About the reviewer
Kevin Bluer is a lead blockchain engineer at ConsenSys, focusing on open source
development tooling such as Truffle and Ganache. Before Web3, he had over 15 years
of experience in software development, working with companies across the industrial
spectrum, including Microsoft, JPMorgan Chase, and Viacom. He is also an experienced
trainer and mentor, having worked with thousands of developers around the globe. Kevin
is also an active investor, photographer, and runner.
Table of Contents
Preface

Part 1: The Fundamentals of Solidity and


Ethereum
1
An Introduction to Blockchain, Ethereum, and Smart
Contracts
Technical requirements 4 Mining nodes 17
What is a blockchain? 5 Ethereum validators 17

The need for blockchain 6 Ethereum accounts 17


Understanding cryptography 7 Externally owned accounts 17
Hashing7 Contract accounts 18
Digital signatures 8 Ether, gas, and transactions 18
Reviewing blockchain and Ethereum
architecture9 Blocks23
Relationship between blocks 10 An end-to-end transaction 25
How transactions and blocks are Smart contract 26
related to each other 12 Writing smart contracts 26
Consensus13 The internals of smart contract
Proof of work 13 deployment32
Proof of stake 16 Summary33
Ethereum nodes 16 Questions33
EVM16 Further reading 33
vi Table of Contents

2
Installing Ethereum and Solidity
Technical requirements 36 Creating a private network 42
Ethereum networks 36 Installing Ganache 46
Main network 37 Installing the Solidity compiler 50
Test network 37 Installing the web3 framework 51
Private network 38
Installing and using MetaMask 52
Consortium network 38
Summary59
Installing and configuring Geth 38 Questions59
Installing Geth on macOS 39 Further reading 59
Installing Geth on Windows 39

3
Introducing Solidity
Technical requirements 62 Storage and memory data
The Ethereum Virtual Machine 62 locations79
Understanding Solidity and Rule one 79
Solidity files 63 Rule two 79
Rule three 80
Pragma63
Rule four 80
Comments64
Rule five 80
Importing Solidity code 65
Rule six 82
Contracts66
Rule seven 83
The structure of a contract 67 Rule eight 84
State variables 69
Using literals 85
Structure70
Modifiers 71 Understanding integers 86
Events73 Understanding Boolean 87
Enumeration74 The byte data type 88
Functions74 Understanding arrays 90
Exploring data types in Solidity 76 Fixed arrays 91
Dynamic arrays 91
Value types 76
Special arrays 93
Reference types 77
Array properties 95
Table of Contents vii

Knowing more about the Working with mappings 100


structure of an array 95 Summary104
Enumerations97 Questions105
Understanding the address Further reading 105
data type 99

4
Global Variables and Functions
Technical requirements 108 The difference between tx.origin and
msg.sender 114
Variable scoping 108
Type conversion 109 Cryptographic global variables 115
Implicit conversion 110 Address global variables 116
Explicit conversion 110 Contract global variables 116
Block and transaction Recovering addresses using
global variables 112 ecrecover117
Transaction- and message-related Summary122
global variables 114 Questions123
Further reading 123

5
Expressions and Control Structures
Technical requirements 126 Understanding the
Understanding Solidity do...while loop 131
expressions126 Understanding breaks  134
Understanding the if and if... Understanding continue  135
else decision control 128 Understanding return  136
Exploring while loops 129 Summary137
Questions137
Further reading 137
viii Table of Contents

Part 2: Writing Robust Smart Contracts


6
Writing Smart Contracts
Technical requirements 142 Polymorphism156
Smart contracts 142 Function polymorphism 156
Writing a smart contract 143 Contract polymorphism 157

Creating contracts 144 Method overriding 158


Using the new keyword 144 Abstract contracts 159
Using the address of a contract 147
Interfaces160
Contract constructor 148 Advanced interfaces 162
Contract composition 150 Library164
Inheritance150 Importing a library 165
Single inheritance 150
Multilevel inheritance 152 Summary166
Hierarchical inheritance 152 Questions167
Multiple inheritance 153 Further reading 167
Encapsulation155

7
Solidity Functions, Modifiers, and Fallbacks
Technical requirements 170 The address call method 181
Function input and output 170 The address callcode method 185
The address delegatecall method 185
Modifiers 172
The address staticcall method 186
Visibility scope 175
View, constant, and pure The fallback and receive
functions176 functions187
Address-related functions 179 Summary191
The address send method 179 Questions191
The address transfer method 181 Further reading 192
Table of Contents ix

8
Exceptions, Events, and Logging
Technical requirements 194 Try-catch in Solidity  209
Exception handling 194 Events and logging 214
Require197 Summary218
Assert  202 Questions219
Revert  204
Further reading 219

9
Basics of Truffle and Unit Testing
Technical requirements 222 Interactively working with
Application development life Truffle 232
cycle management 222 Summary234
Introducing Truffle 223 Questions235
Development with Truffle 225 Further reading 235
Testing with Truffle 230

10
Debugging Contracts
Technical requirements 238 Using a block explorer 244
Overview of debugging 238 Summary247
The Remix editor 238 Questions247
Using events 244 Further reading 247
x Table of Contents

Part 3: Advanced Smart Contracts


11
Assembly Programming
Technical requirements 252 Working with storage slots 261
An introduction to Solidity and Calling contract functions 263
its advantages 252 Determining contract
Getting started with Assembly addresses  265
programming253 Summary266
Scopes and blocks 256 Questions267
Returning values 257 Further reading 267
Working with memory slots 258

12
Upgradable Smart Contracts
Technical requirements 270 Implementing simple solutions
Learning what constitutes with inheritance 277
upgradability270 Implementing simple solutions
Understanding dependency with composition 281
injection272 Implementing advanced
Providing instance addresses during solutions using proxy contracts 285
contract deployment 273 Writing upgradable contracts
Providing instance addresses following with upgradable storage 290
contract deployment 274
Summary292
Reviewing problematic smart Questions292
contracts275 Further reading 292

13
Writing Secure Contracts
Technical requirements 294 Reentrancy attack 296
SafeMath and under/overflow The EtherPot contract 297
attacks294 The Hacker contract 299
Table of Contents xi

Solutions to the reentrancy Summary305


problem300 Questions306
Security best practices 304 Further reading 306

14
Writing Token Contracts
Technical requirements 308 The ERC721 implementation 323
Introducing tokens 308 EIP223  330
ERC20 Tokens 309 ERC165334

ERC20 standard 310 Summary337


ERC20 functionality  310
Questions338
ERC20 events 312
Further reading 338
Non-fungible tokens 320
ERC721322

15
Solidity Design Patterns
Technical requirements 340 Data cohesion 349
Introducing entity modeling 340 Out-of-bounds nested structure 349
Static data within a nested structure 349
Ethereum storage 341
The nested structure will not change in
Data types in Ethereum 341
the near future 349
Understanding data modeling Containment relationship 349
in Solidity 343 Having few relationships 350
Nested versus reference fields 343
Performing data modeling
Exploring types of relationships346 using an example 350
One-to-one relationships 347 Structures350
One-to-many relationships 347 State variables 351
Many-to-many relationships 348 Adding Employees 351
Retrieving a single Employees record 352
Reviewing the rules for Updating Employees 352
embedding structures 348 Retrieving all Employees 353
xii Table of Contents

Ownership in smart contracts 354 Transfer of the ownership of assets


Exploring ownership in Solidity 354 within a smart contract 364

Modifier 356 Stoppable/haltable smart


contract pattern 366
Establishing ownership of a
smart contract 357 Summary368
Multiownership359 Questions369
Transfer of ownership 361 Further reading 369
MultiSig contracts 363
Assessments
Index
Other Books You May Enjoy
Preface
I am not sure when there was last so much of a discussion about a single technology
across governments, organizations, communities, and individuals. Blockchain is a
technology that is being discussed and debated at length across the world and in many
organizations, and with reason. Blockchain is not a technology that has a limited effect
on our lives. It has and will have widespread ramifications in our lives. The day is not far
off when blockchain will touch almost every aspect of our daily activities—paying bills,
making transactions with any organization, receiving a salary, verifying our identity,
receiving educational results, and so on. This is just the beginning, and we have just
started to understand the meaning of decentralization and its impact.
I have been working on blockchain for quite some time now and have been a
crypto-investor for a while. I am a technologist and am completely fascinated by
Bitcoin because of the architectural marvel it is. I have never come across such a
superior thought process and architecture that actually solves not only economic and
social problems but also some technically unsolved problems, such as Byzantine general
problems and fault tolerance. It solves the problem of distributed computing at large.
Ethereum is built in a similar fashion, and I was in awe when I first heard about and
experienced smart contracts. Smart contracts are one of the greatest innovations to deploy
decentralized applications on blockchain and extend it easily with custom logic, policies,
and rules.
I have thoroughly enjoyed writing this book and sincerely hope that you also enjoy
reading about and implementing Solidity. I have brought in a lot of my Solidity experience
and try to make the most of it. I hope this book makes you a better Solidity developer and
a superior programmer.
Do let me know if there is anything I can do to make your experience better with this
book. I am all ears. Happy learning!
xiv Preface

Who this book is for


This book is primarily aimed at beginners who would like to get started with Solidity
programming to develop an Ethereum smart contract. No prior knowledge of the EVM is
required, but knowing the basics of any programming language will help you follow along.

What this book covers


Chapter 1, Introduction to Blockchain, Ethereum, and Smart Contracts, takes you through
the fundamentals of blockchain, its terminology and jargon, its advantages, the problems
it's trying to solve, and its industry relevance. It will explain the important concepts
and architecture in detail. This chapter will also teach you about concepts specific to
Ethereum, such as externally owned accounts, contract accounts, and its currency in
terms of gas and Ether. Ethereum is heavily based on cryptography, so you'll also learn
about hash, encryption, and the usage of keys for creating transactions and accounts. How
transactions and accounts are created, how gas is paid for each transaction, the difference
between message calls and transactions, and the storage of code and state management
will be explained in detail.
Chapter 2, Installing Ethereum and Solidity, takes you through creating a private
blockchain using the Ethereum platform. It will provide step-by-step guidance for creating
a private chain. Another important tool in the Ethereum ecosystem is Ganache, which
is mainly used for development and testing purposes. This chapter will also show the
process of installing Ganache and using it for developing, testing, and deploying Solidity
contracts. You will also install MetaMask, which is a wallet and can interact with any kind
of Ethereum network. MetaMask is used to create new accounts, interact with contracts,
and use them. The mining of transactions will also be shown in this chapter. Remix is a
great tool for authoring Solidity contracts, shown toward the end of the chapter.
Chapter 3, Introducing Solidity, begins the Solidity journey. In this chapter, you'll learn
the basics of Solidity by understanding its different versions and how to use a version
using pragma. Another important aspect of this chapter is understanding the big picture
of authoring smart contracts. Smart contract layout will be discussed in depth using
important constructs such as state variables, functions, constant functions, events,
modifiers, fallbacks, enums, and structs. This chapter discusses and implements the most
important element of any programming language—data types and variables. Data types
can be simple or complex; there can be value and reference types and storage and memory
types—all these types of variables will also be shown using examples.
Another Random Scribd Document
with Unrelated Content
By Christopher Morley

CONTENTS

The Perfect Reader 1


The Autogenesis of a Poet 5
The Old Reliable 19
In Memoriam, Francis Barton Gummere 23
Adventures at Lunch Time 30
Secret Transactions of the Three Hours for Lunch Club 36
Initiation 42
Creed of the Three Hours for Lunch Club 47
A Preface to the Profession of Journalism 51
Fulton Street, and Walt Whitman 57
McSorley's 63
A Portrait 69
Going to Philadelphia 73
Our Tricolour Tie 86
The Club of Abandoned Husbands 95
West Broadway 100
The Rudeness of Poets 106
1100 Words 110
Some Inns 115
The Club in Hoboken 124
The Club at Its Worst 129
A Suburban Sentimentalist 133
Gissing 138
A Dialogue 143
At the Gasthof zum Ochsen 147
Mr. Conrad's New Preface 151
The Little House 155
Tadpoles 158
Magic in Salamis 162
Consider the Commuter 167
The Permanence of Poetry 178
Books of the Sea 182
Fallacious Meditations on Criticism 192
Letting Out the Furnace 202
By the Fireplace 206
A City Note-Book 210
Thoughts in the Subway 229
Dempsey vs. Carpentier 234
A Letter to a Sea Captain 239

PIPEFULS
By Christopher Morley
Illustrated By Walter Jack Duncan

CONTENTS

PAGE
Preface vii
On Making Friends 3
Thoughts on Cider 10
One-Night Stands 18
The Owl Train 25
Safety Pins 29
Confessions of a “Colyumist” 34
Moving 42
Surf Fishing 48
“Idolatry” 52
The First Commencement Address 60
The Downfall of George Snipe 63
Meditations of a Bookseller 66
If Buying a Meal Were Like Buying
71
a House
Adventures in High Finance 74
On Visiting Bookshops 78
A Discovery 83
Silas Orrin Howes 91
Joyce Kilmer 97
Tales of Two
109
Cities
I. Philadelphia:
An Early Train
Ridge Avenue
The University and the Urchin
Pine Street
Pershing in Philadelphia
Fall Fever
Two Days Before Christmas
In West Philadelphia
Horace Traubel
II. New York: 163
The Anatomy of Manhattan
Vesey Street
Brooklyn Bridge
Three Hours for Lunch
Passage from Some Memoirs
First Lessons in Clowning
House Hunting
Long Island Revisited
On Being in a Hurry
Confessions of a Human Globule
Notes on a Fifth Avenue Bus
Sunday Morning
Venison Pasty
Grand Avenue, Brooklyn
On Waiting for the Curtain to Go
236
Up
Musings of John Mistletoe 240
The World's Most Famous Oration 242
On Laziness 244
Teaching the Prince to Take Notes 249
A City Notebook 253
On Going to Bed 270

SONGS FOR A LITTLE HOUSE


By Christopher Morley

CONTENTS

SONGS FOR A LITTLE HOUSE


BAYBERRYCANDLES
SECRET LAUGHTER
A CHARM FOR OUR NEW FIREPLACE
SIX WEEKS OLD
THE YOUNG MOTHER
PETER PAN
THE 5:42
READING ALOUD
THE MOON-SHEEP
MAR QUONG, CHINESE LAUNDRYMAN
THE MILKMAN
IN HONOUR OF TAFFY TOPAZ
THE CEDAR CHEST
O PRAISE ME NOT THE COUNTRY
ANIMAL CRACKERS
THE WAKEFUL HUSBAND
LIGHT VERSE
FULL MOON
MY WIFE
WASHING THE DISHES
THE FURNACE
THE CHURCH OF UNBENT KNEES
THE NEW ALTMAN BUILDING
THE MADONNA OF THE CURB
MY PIPE
TO A GRANDMOTHER

A HANDFUL OF SONNETS
I
II
PEDOMETER
ARS DURA
O. HENRY—APOTHECARY
FOR THE CENTENARY OF KEATS'S SONNET (1816)
TWO O'CLOCK
THE COMMERCIAL TRAVELLER
THE WEDDED LOVER
TO YOU, REMEMBERING THE PAST
THE LAST SONNET

THE WAR
IRONY
TO A FRENCH BABY
AFTER HEARING GERMAN MUSIC
IN MEMORY OF THE AMERICAN AVIATORS KILLED IN FRANCE
THE FLAGS ON FIFTH AVENUE
"THEY"
BALLAD OF FRENCH RIVERS
PEASANT AND KING
TILL TWISTON WENT
TO RUDYARD KIPLING
TO A U-BOAT
KITCHENER
MARCH 1915
DEAD SHIPS
ENGLAND, JULY 1913 (TO RUPERT BROOKE)
TO THE OXFORD MEN IN THE WAR
FOR THE PRESENT TIME
AMERICA, 1917
ON VIMY RIDGE

HAY FEVER, AND OTHER LITERARY POLLEN


HAY FEVER, IF RUDYARD KIPLING HAD IT
HAY FEVER, IF AMY LOWELL HAD IT
HAY FEVER, IF HILAIRE BELLOC HAD IT
HAY FEVER, IF EDGAR LEE MASTERS HAD IT
HYMN TO THE DAIRYMAIDS ON BEACON STREET
ON FIRST LOOKING INTO A SUBWAY EXCAVATION
BALLAD OF NEW AMSTERDAM
CASUALTY
AT THE WOMEN'S CLUBS
ELEGY WRITTEN IN A COUNTRY COAL-BIN
MOONS WE SAW AT SEVENTEEN
AT THE DOG SHOW
THE OLD SWIMMER
TO ALL MY FRIENDS
A GRUB STREET RECESSIONAL

CHIMNEYSMOKE
By Christopher Morley
CONTENTS

PAGE
TO THE LITTLE HOUSE 19
A GRACE BEFORE WRITING 20
DEDICATION FOR A FIREPLACE 21
TAKING TITLE 22
THE SECRET 25
ONLY A MATTER OF TIME 26
AT THE MERMAID CAFETERIA 28
OUR HOUSE 29
ON NAMING A HOUSE 31
A HALLOWE'EN MEMORY 32
REFUSING YOU IMMORTALITY 35
BAYBERRY CANDLES 36
SECRET LAUGHTER 37
SIX WEEKS OLD 38
A CHARM 41
MY PIPE 42
THE 5:42 44
PETER PAN 48
IN HONOR OF TAFFY TOPAZ 49
THE CEDAR CHEST 50
READING ALOUD 51
ANIMAL CRACKERS 52
THE MILKMAN 55
LIGHT VERSE 56
THE FURNACE 57
WASHING THE DISHES 58
THE CHURCH OF UNBENT KNEES 61
ELEGY WRITTEN IN A COUNTRY COAL-BIN 62
THE OLD SWIMMER 66
THE MOON-SHEEP 70
SMELLS 71
SMELLS (JUNIOR) 72
MAR QUONG, CHINESE LAUNDRYMAN 75
THE FAT LITTLE PURSE 76
THE REFLECTION 80
THE BALLOON PEDDLER 82
LINES FOR AN ECCENTRIC'S BOOK PLATE 86
TO A POST-OFFICE INKWELL 89
THE CRIB 90
THE POET 94
TO A DISCARDED MIRROR 97
TO A CHILD 98
TO A VERY YOUNG GENTLEMAN 100
TO AN OLD-FASHIONED POET 104
BURNING LEAVES IN SPRING 105
BURNING LEAVES, NOVEMBER 106
A VALENTINE GAME 107
FOR A BIRTHDAY 108
KEATS 111
TO H. F. M., A SONNET IN SUNLIGHT 113
QUICKENING 114
AT A WINDOW SILL 115
THE RIVER OF LIGHT 116
OF HER GLORIOUS MADNESS 118
IN AN AUCTION ROOM 119
EPITAPH FOR A POET WHO WROTE NO POETRY 120
SONNET BY A GEOMETER 121
TO A VAUDEVILLE TERRIER 122
TO AN OLD FRIEND 125
TO A BURLESQUE SOUBRETTE 126
THOUGHTS WHILE PACKING A TRUNK 129
STREETS 130
TO THE ONLY BEGETTER 131
PEDOMETER 133
HOSTAGES 134
ARS DURA 137
O. HENRY—APOTHECARY 138
FOR THE CENTENARY OF KEATS'S SONNET 139
TWO O'CLOCK 140
THE COMMERCIAL TRAVELLER 141
THE WEDDED LOVER 142
TO YOU, REMEMBERING THE PAST 143
CHARLES AND MARY 144
TO A GRANDMOTHER 145
DIARISTS 146
THE LAST SONNET 147
THE SAVAGE 148
ST. PAUL'S AND WOOLWORTH 149
ADVICE TO A CITY 150
THE TELEPHONE DIRECTORY 151
GREEN ESCAPE 153
VESPER SONG FOR COMMUTERS 157
THE ICE WAGON 158
AT A MOVIE THEATRE 161
SONNETS IN A LODGING HOUSE 163
THE MAN WITH THE HOE (PRESS) 167
DO YOU EVER FEEL LIKE GOD? 168
RAPID TRANSIT 170
CAUGHT IN THE UNDERTOW 171
TO HIS BROWN-EYED MISTRESS 172
PEACE 173
SONG, IN DEPRECATION OF PULCHRITUDE 175
MOUNTED POLICE 176
TO HIS MISTRESS, DEPLORING THAT HE IS NOT
179
AN ELIZABETHAN GALAXY
THE INTRUDER 181
TIT FOR TAT 182
SONG FOR A LITTLE HOUSE 185
THE PLUMPUPPETS 186
DANDY DANDELION 190
THE HIGH CHAIR 192
LOVE AT FIRST SIGHT 193
AUTUMN COLORS 197
THE LAST CRICKET 198
TO LOUISE 199
CHRISTMAS EVE 203
EPITAPH ON THE PROOFREADER OF THE
204
ENCYCLOPEDIA BRITANNICA
THE MUSIC BOX 205
TO LUATH 209
THOUGHTS ON REACHING LAND 212
A SYMPOSIUM 214
TO A TELEPHONE OPERATOR WHO HAS A BAD
218
COLD
NURSERY RHYMES FOR THE TENDER-HEARTED 219
THE TWINS 227
A PRINTER'S MADRIGAL 228
THE POET ON THE HEARTH 230
O PRAISE ME NOT THE COUNTRY 231
A STONE IN ST. PAUL'S GRAVEYARD 235
THE MADONNA OF THE CURB 236
THE ISLAND 240
SUNDAY NIGHT 242
ENGLAND, JULY, 1913 246
CASUALTY 250
A GRUB STREET RECESSIONAL 251
PRELIMINARY INSTRUCTIONS FOR A FUNERAL
253
SERVICE

ILLUSTRATIONS

This hearth was built for thy delight— Frontispiece


And by a friend's bright gift of wine,
23
I dedicate this house of mine
And of all man's felicities— 33
A little world he feels and sees:
39
His mother's arms, his mother's knees—
The 5:42 47
And Daddy once said he would like to be me
53
Having cocoa and animals once more for tea!
But heavy feeding complicates
59
The task by soiling many plates
How ill avail, on such a frosty night 65
The old swimmer 69
But Katie, the cook, is more splendid than all— 73
Perhaps it's a ragged child crying 79
The Balloon Peddler 85
If you appreciate it more
87
Than I—why don't return it!
And then one night— 93
The human cadence and the subtle chime
95
Of little laughters—
What years of youthful ills and pangs and bumps— 103
A Birthday 109
You must be rigid servant of your art! 123
You came, and impudent and deuce-may-care
127
Danced where the gutter flamed with footlight fire
Hostages 135
My eyes still pine for the comely line
155
Of an outbound vessel's hull
A man ain't so secretive, never cares
165
What kind of private papers he leaves lay—
Mounted Police 177
Courtesy 183
The Plumpuppets 189
... It's hard to have to tell
195
How unresponsive I have found her
... When you see, this Great First Time,
201
Lit candles on a Christmas Tree!
The music box 207
Solugubrious 217
In the midnight, like yourself,
221
I explore the pantry shelf!
The Twins 227
O praise me not the country 233
The wail of sickly children— 239
Ah, does the butcher—heartless clown—
245
Beget that shadow on her brow?

TALES FROM A ROLLTOP


DESK
By Christopher Morley
Illustrated By Walter Jack Duncan

CONTENTS

TALES FROM A ROLLTOP DESK


THE PRIZE PACKAGE
ADVICE TO TO LOVELORN
THE CURIOUS CASE OF KENELM DIGBY
GLORIA AND THE GARDEN OF SWEDEN
THE COMMUTATION CHOPHOUSE
THE PERT LITTLE HAT
URN BURIAL
THE BATTLE OF MANILA ENVELOPES
THE CLIMACTERIC
PUNCH AND JUDY
REFERRED TO THE AUTHOR
*** END OF THE PROJECT GUTENBERG EBOOK INDEX OF THE
PROJECT GUTENBERG WORKS OF CHRISTOPHER MORLEY ***

Updated editions will replace the previous one—the old editions will
be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States copyright in
these works, so the Foundation (and you!) can copy and distribute it
in the United States without permission and without paying
copyright royalties. Special rules, set forth in the General Terms of
Use part of this license, apply to copying and distributing Project
Gutenberg™ electronic works to protect the PROJECT GUTENBERG™
concept and trademark. Project Gutenberg is a registered trademark,
and may not be used if you charge for an eBook, except by following
the terms of the trademark license, including paying royalties for use
of the Project Gutenberg trademark. If you do not charge anything
for copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such as
creation of derivative works, reports, performances and research.
Project Gutenberg eBooks may be modified and printed and given
away—you may do practically ANYTHING in the United States with
eBooks not protected by U.S. copyright law. Redistribution is subject
to the trademark license, especially commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the free


distribution of electronic works, by using or distributing this work (or
any other work associated in any way with the phrase “Project
Gutenberg”), you agree to comply with all the terms of the Full
Project Gutenberg™ License available with this file or online at
www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand, agree
to and accept all the terms of this license and intellectual property
(trademark/copyright) agreement. If you do not agree to abide by all
the terms of this agreement, you must cease using and return or
destroy all copies of Project Gutenberg™ electronic works in your
possession. If you paid a fee for obtaining a copy of or access to a
Project Gutenberg™ electronic work and you do not agree to be
bound by the terms of this agreement, you may obtain a refund
from the person or entity to whom you paid the fee as set forth in
paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only be


used on or associated in any way with an electronic work by people
who agree to be bound by the terms of this agreement. There are a
few things that you can do with most Project Gutenberg™ electronic
works even without complying with the full terms of this agreement.
See paragraph 1.C below. There are a lot of things you can do with
Project Gutenberg™ electronic works if you follow the terms of this
agreement and help preserve free future access to Project
Gutenberg™ electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright law
in the United States and you are located in the United States, we do
not claim a right to prevent you from copying, distributing,
performing, displaying or creating derivative works based on the
work as long as all references to Project Gutenberg are removed. Of
course, we hope that you will support the Project Gutenberg™
mission of promoting free access to electronic works by freely
sharing Project Gutenberg™ works in compliance with the terms of
this agreement for keeping the Project Gutenberg™ name associated
with the work. You can easily comply with the terms of this
agreement by keeping this work in the same format with its attached
full Project Gutenberg™ License when you share it without charge
with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.

1.E. Unless you have removed all references to Project Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project Gutenberg™
work (any work on which the phrase “Project Gutenberg” appears,
or with which the phrase “Project Gutenberg” is associated) is
accessed, displayed, performed, viewed, copied or distributed:
This eBook is for the use of anyone anywhere in the
United States and most other parts of the world at no
cost and with almost no restrictions whatsoever. You
may copy it, give it away or re-use it under the terms
of the Project Gutenberg License included with this
eBook or online at www.gutenberg.org. If you are not
located in the United States, you will have to check the
laws of the country where you are located before using
this eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is derived


from texts not protected by U.S. copyright law (does not contain a
notice indicating that it is posted with permission of the copyright
holder), the work can be copied and distributed to anyone in the
United States without paying any fees or charges. If you are
redistributing or providing access to a work with the phrase “Project
Gutenberg” associated with or appearing on the work, you must
comply either with the requirements of paragraphs 1.E.1 through
1.E.7 or obtain permission for the use of the work and the Project
Gutenberg™ trademark as set forth in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is posted


with the permission of the copyright holder, your use and distribution
must comply with both paragraphs 1.E.1 through 1.E.7 and any
additional terms imposed by the copyright holder. Additional terms
will be linked to the Project Gutenberg™ License for all works posted
with the permission of the copyright holder found at the beginning
of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files containing a
part of this work or any other work associated with Project
Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute this


electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the Project
Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or
expense to the user, provide a copy, a means of exporting a copy, or
a means of obtaining a copy upon request, of the work in its original
“Plain Vanilla ASCII” or other form. Any alternate format must
include the full Project Gutenberg™ License as specified in
paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™ works
unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or providing


access to or distributing Project Gutenberg™ electronic works
provided that:

• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt
that s/he does not agree to the terms of the full Project
Gutenberg™ License. You must require such a user to return or
destroy all copies of the works possessed in a physical medium
and discontinue all use of and all access to other copies of
Project Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project Gutenberg™


electronic work or group of works on different terms than are set
forth in this agreement, you must obtain permission in writing from
the Project Gutenberg Literary Archive Foundation, the manager of
the Project Gutenberg™ trademark. Contact the Foundation as set
forth in Section 3 below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on, transcribe
and proofread works not protected by U.S. copyright law in creating
the Project Gutenberg™ collection. Despite these efforts, Project
Gutenberg™ electronic works, and the medium on which they may
be stored, may contain “Defects,” such as, but not limited to,
incomplete, inaccurate or corrupt data, transcription errors, a
copyright or other intellectual property infringement, a defective or
damaged disk or other medium, a computer virus, or computer
codes that damage or cannot be read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except for


the “Right of Replacement or Refund” described in paragraph 1.F.3,
the Project Gutenberg Literary Archive Foundation, the owner of the
Project Gutenberg™ trademark, and any other party distributing a
Project Gutenberg™ electronic work under this agreement, disclaim
all liability to you for damages, costs and expenses, including legal
fees. YOU AGREE THAT YOU HAVE NO REMEDIES FOR
NEGLIGENCE, STRICT LIABILITY, BREACH OF WARRANTY OR
BREACH OF CONTRACT EXCEPT THOSE PROVIDED IN PARAGRAPH
1.F.3. YOU AGREE THAT THE FOUNDATION, THE TRADEMARK
OWNER, AND ANY DISTRIBUTOR UNDER THIS AGREEMENT WILL
NOT BE LIABLE TO YOU FOR ACTUAL, DIRECT, INDIRECT,
CONSEQUENTIAL, PUNITIVE OR INCIDENTAL DAMAGES EVEN IF
YOU GIVE NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of receiving
it, you can receive a refund of the money (if any) you paid for it by
sending a written explanation to the person you received the work
from. If you received the work on a physical medium, you must
return the medium with your written explanation. The person or
entity that provided you with the defective work may elect to provide
a replacement copy in lieu of a refund. If you received the work
electronically, the person or entity providing it to you may choose to
give you a second opportunity to receive the work electronically in
lieu of a refund. If the second copy is also defective, you may
demand a refund in writing without further opportunities to fix the
problem.

1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of damages.
If any disclaimer or limitation set forth in this agreement violates the
law of the state applicable to this agreement, the agreement shall be
interpreted to make the maximum disclaimer or limitation permitted
by the applicable state law. The invalidity or unenforceability of any
provision of this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the Foundation,


the trademark owner, any agent or employee of the Foundation,
anyone providing copies of Project Gutenberg™ electronic works in
accordance with this agreement, and any volunteers associated with
the production, promotion and distribution of Project Gutenberg™
electronic works, harmless from all liability, costs and expenses,
including legal fees, that arise directly or indirectly from any of the
following which you do or cause to occur: (a) distribution of this or
any Project Gutenberg™ work, (b) alteration, modification, or
additions or deletions to any Project Gutenberg™ work, and (c) any
Defect you cause.

Section 2. Information about the Mission


of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new computers.
It exists because of the efforts of hundreds of volunteers and
donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project Gutenberg™’s
goals and ensuring that the Project Gutenberg™ collection will
remain freely available for generations to come. In 2001, the Project
Gutenberg Literary Archive Foundation was created to provide a
secure and permanent future for Project Gutenberg™ and future
generations. To learn more about the Project Gutenberg Literary
Archive Foundation and how your efforts and donations can help,
see Sections 3 and 4 and the Foundation information page at
www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-profit
501(c)(3) educational corporation organized under the laws of the
state of Mississippi and granted tax exempt status by the Internal
Revenue Service. The Foundation’s EIN or federal tax identification
number is 64-6221541. Contributions to the Project Gutenberg
Literary Archive Foundation are tax deductible to the full extent
permitted by U.S. federal laws and your state’s laws.

The Foundation’s business office is located at 809 North 1500 West,


Salt Lake City, UT 84116, (801) 596-1887. Email contact links and up
to date contact information can be found at the Foundation’s website
and official page at www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission of
increasing the number of public domain and licensed works that can
be freely distributed in machine-readable form accessible by the
widest array of equipment including outdated equipment. Many
small donations ($1 to $5,000) are particularly important to
maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws regulating


charities and charitable donations in all 50 states of the United
States. Compliance requirements are not uniform and it takes a
considerable effort, much paperwork and many fees to meet and
keep up with these requirements. We do not solicit donations in
locations where we have not received written confirmation of
compliance. To SEND DONATIONS or determine the status of
compliance for any particular state visit www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states where


we have not met the solicitation requirements, we know of no
prohibition against accepting unsolicited donations from donors in
such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot make


any statements concerning tax treatment of donations received from
outside the United States. U.S. laws alone swamp our small staff.

Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.

Section 5. General Information About


Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could be
freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose network of
volunteer support.
Project Gutenberg™ eBooks are often created from several printed
editions, all of which are confirmed as not protected by copyright in
the U.S. unless a copyright notice is included. Thus, we do not
necessarily keep eBooks in compliance with any particular paper
edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg Literary
Archive Foundation, how to help produce our new eBooks, and how
to subscribe to our email newsletter to hear about new eBooks.

You might also like