Where Can Buy Beginning Ethereum Smart Contracts Programming: With Examples in Python, Solidity, and JavaScript Lee Ebook With Cheap Price
Where Can Buy Beginning Ethereum Smart Contracts Programming: With Examples in Python, Solidity, and JavaScript Lee Ebook With Cheap Price
com
https://textbookfull.com/product/beginning-
ethereum-smart-contracts-programming-with-
examples-in-python-solidity-and-javascript-lee/
https://textbookfull.com/product/biota-grow-2c-gather-2c-cook-loucas/
textbookfull.com
https://textbookfull.com/product/ethereum-for-architects-and-
developers-with-case-studies-and-code-samples-in-solidity-
springerlink-online-service/
textbookfull.com
https://textbookfull.com/product/the-visual-elements-design-a-
handbook-for-communicating-science-and-engineering-1st-edition-
frankel/
textbookfull.com
Problems in organic structure determination : a practical
approach to NMR spectroscopy First Issued In Hardback
2017. Edition Linington
https://textbookfull.com/product/problems-in-organic-structure-
determination-a-practical-approach-to-nmr-spectroscopy-first-issued-
in-hardback-2017-edition-linington/
textbookfull.com
https://textbookfull.com/product/civil-society-second-edition-the-
critical-history-of-an-idea-john-r-ehrenberg/
textbookfull.com
https://textbookfull.com/product/love-and-marriage-across-social-
classes-in-american-cinema-1st-edition-stephen-sharot-auth/
textbookfull.com
https://textbookfull.com/product/the-oxford-handbook-of-plato-gail-
fine/
textbookfull.com
Beginning Ethereum
Smart Contracts
Programming
With Examples in Python,
Solidity and JavaScript
Wei-Meng Lee
Beginning Ethereum Smart Contracts Programming:
With Examples in Python, Solidity and JavaScript
Wei-Meng Lee
Ang Mo Kio, Singapore
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub via the book’s product page, located at www.apress.com/9781484250853. For more
detailed information, please visit http://www.apress.com/source-code.
Contents
Introduction�����������������������������������������������������������������������������������������������������������xvii
Index��������������������������������������������������������������������������������������������������������������������� 289
Introduction
Welcome to Beginning Ethereum Smart Contracts Programming!
This book is a quick guide to getting started with Ethereum Smart Contracts
programming. It first starts off with a discussion on blockchain and the motivations
behind it. You will learn what is a blockchain, how blocks in a blockchain are chained
together, and how blocks get added to a blockchain. You will also understand how
mining works and discover the various types of nodes in a blockchain network.
Once that is out of the way, we will dive into the Ethereum blockchain. You will
learn how to use an Ethereum client (Geth) to connect to the Ethereum blockchain and
perform transactions such as sending ethers to another account. You will also learn how
to create private blockchain networks so that you can test them internally within your
own network.
The next part of this book will discuss Smart Contracts programming, a unique
feature of the Ethereum blockchain. Readers will be able to get jumpstarted on Smart
Contracts programming without needing to wade through tons of documentation. The
learn-by-doing approach of this book makes you productive in the shortest amount
of time. By the end of this book, you would be able to write smart contracts, test them,
deploy them, and create web applications to interact with them.
The last part of this book will touch on tokens, something that has taken the
cryptocurrency market by storm. You would be able to create your own tokens and
launch your own ICO and would be able to write token contracts that allow buyers to buy
tokens using Ethers.
This book is for those who want to get started quickly with Ethereum Smart
Contracts programming. Basic programming knowledge and an understanding of
Python or JavaScript are recommended.
I hope you will enjoy working on the sample projects as much as I have enjoyed
working on them!
CHAPTER 1
Understanding Blockchain
One of the hottest technologies of late is Blockchain. But what exactly is a blockchain?
And how does it actually work? In this chapter, we will explore the concept of blockchain,
how the concept was conceived, and what problems it aimed to solve. By the end of this
chapter, the idea and motivation behind blockchain would be crystal clear.
Hold on tight, as I’m going to discuss a lot of concepts in this chapter. But if you
follow along closely, you’ll understand the concepts of blockchain and be on your way to
creating some really creative applications on the Ethereum blockchain in the upcoming
chapters!
Placement of Trusts
All these boil down to one key concept – placement of trust. And that is, we place our
trust on a central body. Think about it, in our everyday life, we place our trusts on banks,
and we place our trusts on our governments.
Even for simple mundane day-to-day activities, we place our trusts in central bodies.
For example, when you go to the library to borrow a book, you trust that the library
would maintain a proper record of the books that you have borrowed and returned.
The key theme is that we trust institutions but don’t trust each other. We trust our
government, banks, even our library, but we just don’t trust each other. As an example,
consider the following scenario. Imagine you work at a cafe, and someone walks up
to you and offers you a US ten-dollar bill for two cups of coffee. And another person
who offers to pay you for the two cups of coffee using a handwritten note saying he
owes you ten dollars. Which one would you trust? The answer is pretty obvious, isn’t it?
Naturally you would trust the US ten-dollar bill, as opposed to the handwritten note.
This is because you understand that using the ten-dollar bill, you can use it elsewhere
to exchange for other goods or services, and that it is backed by the US government. In
contract, the handwritten note is not backed by anyone else (except perhaps the person
who wrote it), and hence it has literally no value.
2
Chapter 1 Understanding Blockchain
Now let’s take the discussion a bit further. Again, imagine you are trying to sell
something. Someone comes up to you and suggests paying for your goods using the
currencies as shown in Figure 1-1.
Would you accept the currencies as shown in the figure? Here, you have two different
currencies – one from Venezuela and one from Zimbabwe. In this case, the first thing
you consider is whether these currencies are widely accepted and also your trust in these
governments. You might have read from the news about the hyperinflation in these two
countries, and that these currencies might not retain its value over time.
And so, would you accept these currencies as payment?
T rust Issues
Earlier on, I mentioned that people trust institutions and don’t trust each other. But even
established economies can fail, such as in the case of the financial crisis of the United
States in 2007–2008. Investment bank Lehman Brothers collapsed in September 2008
because of the subprime mortgage market. So, if banks from established economies can
3
Chapter 1 Understanding Blockchain
collapse, how can people in less developed countries trust their banks and governments?
Even if the banks are trusted, your deposits may be monitored by the government, and
they could arrest you based on your transactions.
As we have seen in the example in the previous section, there are times when people
don’t trust institutions, especially if the political situation in that country is not stable.
All these discussions bring us to the next key issue – even though people trust
institutions, institutions can still fail. And when people lose trust in institutions, people
turn to cryptocurrencies. In the next section, we will discuss how we can solve the trust
issues using decentralization, a fundamental concept behind cryptocurrency.
E xample of Decentralization
To understand how decentralization solves the trust issue, let’s consider a real-life example.
Imagine a situation where you have three persons with DVDs that they want to share
with one another (see Figure 1-2).
4
Chapter 1 Understanding Blockchain
The first thing they need to do is to have someone keep track of the whereabouts
of each DVD. Of course, the easiest is for each person to keep track of what they have
borrowed and what they have lent, but since people inherently do not trust each other,
this approach is not very popular among the three persons.
To solve this issue, they decided to appoint one person, say B, to keep a ledger, to
hold a record of the whereabouts of each DVD (see Figure 1-3).
5
Chapter 1 Understanding Blockchain
This way, there is a central body to keep track of the whereabouts of each DVD. But
wait, isn’t this the problem with centralization? What happens if B is not trustworthy?
Turns out that B has the habit of stealing DVDs, and he in fact could easily modify the
ledger to erase the record of DVDs that he has borrowed. So, there must be a better way.
And then, someone has an idea! Why not let everyone keep a copy of the ledger
(see Figure 1-4)? Whenever someone borrows or lent a DVD, the record is broadcast to
everyone, and everyone records the transaction.
6
Chapter 1 Understanding Blockchain
We say that the record keeping is now decentralized! We now have three persons
holding the same ledger. But wait a minute. What if A and C conspire to change the
records together so that they can steal the DVDs from B? Since majority wins, as long
as there is more than 50% of the people with the same records, the others would have
to listen to the majority. And because there are only three persons in this scenario, it is
extremely easy to get more than 50% of the people to conspire.
The solution is to have a lot more people to hold the ledger, especially people who
are not related to the DVDs sharing business (see Figure 1-5).
7
Chapter 1 Understanding Blockchain
Figure 1-5. Getting a group of unrelated people to help keep the records
This way, it makes it more difficult for one party to alter the records on the ledger,
and that in order to alter a record, it would need to involve a number of people altering
the record all at the same time, which is a time-consuming affair. And this is the key idea
behind distributed ledger, or commonly known as blockchain.
8
Chapter 1 Understanding Blockchain
Figure 1-6. Transactions form a block, and then blocks are then chained
Based on what we have discussed, we can now summarize a few important points:
9
Chapter 1 Understanding Blockchain
Figure 1-7. Every blockchain has a beginning block known as the genesis block
The blocks are connected to each other cryptographically, the details in which we
will discuss in the sections ahead. The first block in a blockchain is known as the genesis
block.
So, the next important questions is – how do you chain the blocks together?
We are now ready to discuss how blocks in a blockchain are chained together. To
chain the blocks together, the content of each block is hashed and then stored in the next
block (see Figure 1-8). That way, if any transactions in a block is altered, that is going to
invalidate the hash of the current block, which is stored in the next block, which in turn
is going to invalidate the hash of the next block, and so on.
11
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
Chapter 1 Understanding Blockchain
Observe that when hashing the content of a block, the hash of the previous block is
hashed together with the transactions. However, do take note that this is a simplification
of what is in a block. Later on, we will dive into the details of a block and see exactly how
transactions are represented in a block.
Storing the hash of the previous block in the current block assures the integrity of the
transactions in the previous block. Any modifications to the transaction(s) within a block
causes the hash in the next block to be invalidated, and it also affects the subsequent
blocks in the blockchain. If a hacker wants to modify a transaction, not only must he
modify the transaction in a block but all other subsequent blocks in the blockchain. In
addition, he needs to synchronize the changes to all other computers on the network,
which is a computationally expensive task to do. Hence, data stored in the blockchain
is immutable, for they are hard to change once the block they are in is added to the
blockchain.
Up to this point, you have a high-level overview of what constitutes a blockchain and
how the blocks are chained together. In the next section, you will understand the next
important topic in blockchain – mining.
M
ining
Whenever you talk about blockchain or cryptocurrencies, there is always one term that
comes up – mining. In this section, you will learn what is mining, and what goes on
behind the scene.
Mining is the process of adding blocks to a blockchain. In a blockchain network,
such as the Bitcoin or Ethereum network, there are different types of computers known
as nodes. Computers on a blockchain that add blocks to the blockchain are known as
miner nodes (or mining nodes, or more simply miners).
We will talk about the different types of nodes later on in this course, but for now, we
want to talk about a particular type of node, known as the miner node. The role of the
miner node is to add blocks to the blockchain.
But how are blocks added?
B
roadcasting Transactions
When a transaction is performed, the transaction is broadcasted to the network (see
Figure 1-9).
12
Chapter 1 Understanding Blockchain
Figure 1-9. Transactions are broadcasted to mining nodes, which then assemble
them into blocks to be mined
Each mining node may receive them at different times. As a node receives
transactions, it will try to include them in a block. Observe that each node is free to
include whatever transactions they want in a block. In practice, which transactions get
included in a block depends on a number of factors, such as transaction fees, transaction
size, order of arrival, and so on.
At this point, transactions that are included in a block but which are not yet added
to the blockchain are known as unconfirmed transactions. Once a block is filled with
transactions, a node will attempt to add the block to the blockchain.
Now here comes the problem – with so many miners out there, who gets to add the
block to the blockchain first?
13
Chapter 1 Understanding Blockchain
Figure 1-10. Hashing the block to meet the network difficulty target
In order to successfully add a block to the blockchain, a miner would hash the
content of a block and check that the hash meets the criteria set by the difficulty target.
For example, the resultant hash must start with five zeros and so on.
As more miners join the network, the difficultly level increases, for example, the
hash must now start with six zeros and so on. This allows the blocks to be added to the
blockchain at a consistent rate.
But, wait a minute, the content of a block is fixed, and so no matter how you hash it,
the resultant hash is always the same. So how do you ensure that the resultant hash can
meet the difficulty target? To do that, miners add a nonce to the block, which stands for
number used once (see Figure 1-11).
14
Chapter 1 Understanding Blockchain
Figure 1-11. Adding a nonce to change the content of the block in order to meet
the network difficulty target
The first miner who meets the target gets to claim the rewards and adds the block to
the blockchain. It will broadcast the block to other nodes so that they can verify the claim
and stop working on their current work of mining their own blocks. The miners would
drop their current work, and the process of mining a new block starts all over again.
The transactions that were not included in the block that was successfully mined will be
added to the next block to be mined.
In the case of Bitcoin, the block reward initially was 50 BTC and will halve every 210,000
blocks. At the time of writing, the block reward is currently at 12.5 BTC, and it will eventually
be reduced to 0 after 64 halving events. For Ethereum, the reward for mining a block is
currently 2 ETH (Ether).
15
Chapter 1 Understanding Blockchain
For Bitcoin, the network adjusts the difficulty of the puzzles so that a new block is being mined
roughly every 10 minutes. For Ethereum, a block is mined approximately every 14 seconds.
Proof of Work
The process in which blocks are mined and added to the blockchain is known as the
Proof of Work (PoW). It is difficult to produce the proof but very easy to validate. A good
example of Proof of Work is cracking a combination lock – it takes a lot of time to find the
right combination, but it is easy to verify once the combination is found.
Proof of Work uses tremendous computing resources – GPUs are required, while
CPU speed is not important. It also uses a lot of electricity, because miners are doing the
same work repeatedly – find the nonce to meet the network difficulty for the block.
A common question is why you need to use a powerful GPU instead of CPU for
mining? Well, as a simple comparison, a CPU core can execute 4 32-bit instructions per
clock, whereas a GPU like the Radeon HD 5970 can execute 3200 32-bit instructions per
clock. In short, the CPU excels at doing complex manipulations to a small set of data,
whereas the GPU excels at doing simple manipulations to a large set of data. And since
mining is all about performing hashing and finding the nonce, it is a highly repetitive
task, something that GPU excels in.
Tip When a miner has successfully mined a block, he earns mining fees as well
as transaction fees. That’s what keeps miners motivated to invest in mining rigs
and keep them running 24/7, thereby incurring substantial electricity bills.
Immutability of Blockchains
In a blockchain, each block is chained to its previous block through the use of a
cryptographic hash. A block’s identity changes if the parent’s identity changes. This in
turn causes the current block’s children to change, which affects the grandchildren, and
so on. A change to a block forces a recalculation of all subsequent blocks, which requires
enormous computation power. This makes the blockchain immutable, a key feature of
cryptocurrencies like Bitcoin and Ethereum.
16
Random documents with unrelated
content Scribd suggests to you:
banished after it had been put in force went away and made no
attempt to come back; but in June 1659 four who were more resolute
and determined appeared in Boston with the avowed intention of
defying the law. They were William Robinson, Marmaduke
Stevenson, Nicholas Davis, and Mary Dyer. They were arrested and
sentenced to banishment (September 12th), with the threat that they
should suffer death if they remained or returned to the colony.
Nicholas Davis and Mary Dyer “found freedom to depart; but the
other two were constrained in the love and power of the Lord not to
depart, but to stay in the jurisdiction, and to try the bloody law unto
20
death.” They withdrew to the New Hampshire settlements, but in
about four weeks returned to Boston prepared to die, and were
joined there by Mary Dyer, who had decided to share their fate. They
were arraigned before the General Court, which was then in session,
and admitting that they were the persons banished by the last Court
of Assistants, were sentenced to be hanged in a week from that time
21
(October 19th). The authorities evidently were afraid of popular
sympathy, for they gave orders for a military guard of one hundred
men to conduct them to the gallows, while another military force was
charged to watch the rest of the town, and the selectmen were
instructed to “press ten or twelve able and faithful persons every
night to watch the town and guard the prison.”
Neither side would yield: the Quakers had come back with the
declared purpose of dying for their faith and for the principle of
religious liberty; the authorities did not dare to withdraw from the
position in which they had rashly placed themselves, and the leaders
do not seem to have had any desire to do so. They felt that the
question of their authority was at stake, and that if they yielded their
power over the people would be gone. They were willing to claim for
themselves and their institutions the protection of the laws of
England, but they would not admit any appeal to those laws when
they conflicted with the colonial regulations. They claimed to own the
colony in full sovereignty, in virtue of their charter on the one hand
and their deeds from the Indians on the other, and they argued that
they had the same right to exclude obnoxious and dangerous
persons, and to destroy them if they persistently thrust themselves
upon them, that a householder has of resisting a burglar, or a
shepherd of killing the wolves that break into his sheepfold.
It is a great mistake to say that they had come to the colony from
a zeal for religious liberty. What they had come for was to be in a
place where they could order religious affairs to suit themselves. As
Besse, the Quaker historian, shrewdly remarks: “They appear not so
inconsistent with themselves as some have thought, because when
under oppression they pleaded for liberty of conscience, they
understood it not as the natural and common right of all mankind, but
22
as a peculiar privilege of the orthodox.”
The tragedy was performed on the twenty-seventh day of
October 1659; the prisoners, walking hand in hand, were brought to
the gallows by the soldiers. They were insulted in their last moments
by the bigoted Wilson, and when they tried to address the people
their voices were drowned by the beating of the drums. Robinson
and Stevenson died bravely, and Mary Dyer mounted the ladder to
meet her fate; her skirts were tied, the rope was about her neck, and
she was on the point of being “turned off,” when she was released by
the magistrates in consideration of the intercession of her son, who
had come up from Rhode Island to try to save his mother’s life. She
unwillingly accepted the grudging gift, and went back to Rhode
23
Island.
The popular feeling was so strong against the magistrates for
their severity, that they thought it best to put forth a declaration, in
which they argued that their proceedings were justified by the law of
self-defence, and by the precedent of the English laws against the
Jesuits; and they calmly stated that what they had done was only to
present the point of their sword in their own defence, that the
Quakers who had rushed upon it had become “felons de se,” and
that their former proceedings and their mercy to Mary Dyer upon the
“inconsiderable intercession” of her son “manifestly evinced that they
24
desired their lives absent rather than their death present.”
The bodies of the unfortunate men were treated with indecent
brutality, and were buried naked beneath the gallows. Mrs. Dyer
remained away for six months, and then the spirit moved her to
return once more and die. Her husband wrote to Endicott to beg her
life, but without avail. No mercy could be shown her as long as she
defied the law. It is said that her life was offered her if she would
promise to keep out of the colony henceforth, but she declined to
25
receive the favor. “In obedience to the will of the Lord I came,” said
she, “and in his will I abide faithful to the death.”
Meanwhile the prisons and the house of correction had been the
fate of other delinquents, and the jailer and executioner had had
plenty of employment with the scourge. The Southwicks, with their
eldest son Josiah, were whipped, fined, and imprisoned for
withdrawing from the public services and worshipping by
themselves, and their two younger children were ordered to be sold
26
as slaves to the West Indies in satisfaction of the fines imposed.
W. Shattuck was whipped, fined, and imprisoned. Sarah Gibbons
and Dorothy Waugh were whipped. Hored Gardner, a woman with a
sucking babe, and a young girl who came into the colony with her,
were scourged with the “three-fold knotted whip, and during her
tortures she prayed for her persecutors.”
William Brand was thrown into the House of Correction, and,
refusing to work, was beaten constantly by the brutal jailer with a
tarred rope an inch thick. The pathetic record says: “His back and
arms were bruised black, and the blood was hanging as in bags
under his arms, and so into one was his flesh beaten that the sign of
27
a particular blow could not be seen, for all became as a jelly.”
William Leddra and Rouse, whose ears had been cut off, were
ordered to be whipped twice a week with increasing severity until
they consented to work, and were at last dismissed from the colony
under pain of death if they returned.
Patience Scott, a girl eleven years old, was imprisoned as a
Quaker, but discharged, after a period of detention, in consideration
of her youth; but her mother, Catherine Scott, for reproving the
magistrates for a deed of darkness, was whipped ten stripes,
although she was admitted by them to be otherwise of blameless life
and conversation.
Christopher Holden, who, in spite of losing his ears in 1658, had
returned once more, was banished upon pain of death by the same
28
court that had hanged Robinson and Stevenson. Seven or eight
persons were fined, some as high as ten pounds, for entertaining
Quakers, and Edward Wharton, for piloting them from one place to
another, was ordered to be whipped twenty stripes, and bound to his
good behavior. Divers others were then brought upon trial, “for
adhering to the cursed sect of Quakers, not disowning themselves to
be such, refusing to give civil respect, leaving their families and
relations, and roaming from place to place vagabonds like”; and
Daniel Gold was sentenced to be whipped thirty stripes, Robert
Harper fifteen, and they, with Alice Courland, Mary Scott, and Hope
Clifton, banished upon pain of death; William Kingswill whipped
fifteen stripes; Margaret Smith, Mary Trask, and Provided Southwick
29
ten stripes each, and Hannah Phelps admonished. In November,
William Leddra, who had been released, returned, and was at once
arrested. On his trial the opportunity of withdrawal was again
extended, but he refused to accept it, and was executed March 1,
1661. As he ascended the ladder he was heard to say: “All that will
be Christ’s disciples must take up the cross,” and just as he was
being thrown from its rounds, he cried in the words of Stephen, “Lord
Jesus, receive my spirit.” Wenlock Christison, who had been before
this sentenced to death, but allowed to leave the colony, had
returned, and during Leddra’s trial he came boldly before the Court
and told the astonished judges: “I am come here to warn you that ye
shed no more innocent blood.” He was at once arrested, and was
brought up for trial three months later. There was an unusual
difference of opinion in regard to the case, and the condemnation
was only secured by the violence of Endicott, who was able to
browbeat the others into consent. But the sentence they passed was
never executed. The people were tired of bloodshed, and the
opposition which was shown in the General Court to any further
proceedings was so great as to make a change in the law
30
necessary.
The humanity of the delegates to the Court was probably
considerably quickened by a sense of the dangerous position in
which the colony stood since the restoration of Charles II., who, they
might naturally fear, would call them to an account for their
proceedings, especially as the colony had allowed nearly a year to
pass without any recognition of the change in the political situation.
The General Court attempted to save its dignity by interposing a
still greater number of shameful and unusual punishments between
the first offence and the death penalty, and declared that, “being
desirous to try all means with as much lenity as might consist with
safety to prevent the intrusions of the Quakers, who had not been
restrained by the laws already provided, they would henceforth order
that such intruders should be tied to a cart’s tail and whipped from
town to town toward the borders of the jurisdiction. Should they
return after being dealt with thus thrice, they were to be branded with
the letter R on their left shoulder, and be severely whipped and sent
away again at the cart’s tail. Should they again return, they were to
31
be liable to the former law of banishment under pain of death.”
It is quite possible that this appeared to be lenity to men like
Endicott and Norton, but it is very doubtful whether the Quakers so
considered it. It did not prevent, though it anticipated, an order from
the king directing that any Quakers imprisoned or under sentence
32
should be released and sent to England for trial. To make this still
more galling to the pride of the colony, it was sent by Samuel
Shattuck, a Salem Quaker, who had been banished from the colony
under pain of death if he should return, and who, we cannot doubt,
thoroughly enjoyed his mission and the humiliation of Endicott. For a
short time the order was obeyed and then the “lenient” laws were put
in force again; and, as many delicately nurtured Quaker women
found to their cost, the “tender mercies” of the saints were cruel.
Palfrey remarks, with great gratification apparently, that “no hanging,
no branding, ever took place by force of this law,” but that “under its
provisions for other penalties the contest was carried on for a
considerable time longer.”
It would be wearisome to cite all of the subsequent proceedings;
a few of them will suffice to show that the treatment of the Quakers
still continued to be extremely severe, and that in spite of it all they
persisted in braving the threats of the magistrates. It was not until
1679, when religious toleration was forced against their wills upon
the good Christians of Massachusetts, that the Quakers found any
safety within the boundaries of the colony.
In 1661, when the Quakers were set free at the command of the
king, some of them were whipped at the cart’s tail twenty stripes
33
apiece, on the ground that they were vagabonds.
In 1662, Josiah Southwick, who had returned from his
banishment, was whipped at the cart’s tail in Boston, Roxbury, and
Dedham, and dismissed into the woods with a warning not to return.
The magistrates apparently had found that their old style of whipping
was too humane; for the whip used on this and several subsequent
occasions was made, not of cord, “but of dried guts like the bass
strings of a bass viol,” with three knots at each end—a weapon
which, according to contemporary testimony, made holes in the back
34
that one could put pease into.
In December 1662 Ann Coleman, Mary Tompkins, and Alice
Ambrose were stripped to the waist and whipped at the cart’s tail in
Dover, Hampton, and Salisbury, and were forced to walk the entire
distance in slush and snow up to their knees. The “lenient” sentence
required indeed that they should be whipped in each town in the
jurisdiction, but the constable at Newbury found in the warrant some
flaw by which he was able to release them. On their return to Dover,
they were seized by the constables by night, dragged face
downwards over snow and stumps to the river, one of them at least
was doused in the stream and dragged after a canoe, and they were
only released because the storm was too severe for their tormentors
35
to brave. Ann Coleman, again, with four friends, was whipped
36
through Salem, Boston, and Dedham. Elizabeth Hooton, a woman
of over sixty years of age, Fox’s first convert, was first imprisoned,
and then carried two days’ journey into the wilderness, “among
wolves and bears,” and left there to shift for herself. On returning,
she was kept in a dungeon at Cambridge two days without food, tied
to the whipping-post and flogged there, then taken to Watertown,
where she was flogged with willow rods, flogged again at Dedham,
and then carried into the woods as before. Coming back once more
to fetch her clothes from Cambridge, she and a companion, “an
ancient woman,” and her daughter were whipped in private, in spite
of which we find her coming once more to Boston, and on that
37
occasion she was whipped again at the cart’s tail. Mary Tompkins,
Alice Ambrose, and Ann Needham also appear again and again in
the records of suffering. One Edward Wharton, who was most
resolute in defying the authorities, was constantly under arrest, and
even a bare enumeration of his floggings would fill a page.
In 1665 Deborah Wilson, for going naked through the streets of
Salem “for a sign,” was whipped; but the constable executed his
office so mercifully that he was displaced. There is a pathetic
incident mentioned by Bishop, the Quaker historian, that “her tender
husband, though not altogether of her way, followed after,” as she
underwent her punishment, “clapping his hat sometimes between the
38
whip and her back.”
Eliakim Wardwell, at Newbury, was fined heavily in 1665 for
entertaining Wenlock Christison; and this injustice in addition to the
other cruel acts, so affected his wife Lydia that, although a modest
and delicate woman, she came naked into the meeting at Newbury,
as a testimony against them. She was seized and hurried away to
the court at Ipswich, which sentenced her to be whipped at the
nearest tavern post. Bishop says:
both now are able to respect each other’s loyalty of purpose and
fidelity to their respective conceptions of truth.
NOTES.
1
Vide infra, Note 6.
2
George Fox, Journal. It is well to notice that of the ministers
mentioned by Fox by name or parish, Nath. Stevens, the rector
of Fenny Drayton, was a Presbyterian of some eminence, and
was ejected for non-conformity in 1662. So also was Matthew
Cradock, the “priest of Coventry,” who was a distinguished
non-conformist divine. The priest at Mansetter, who advised
tobacco and psalm-singing, kept his living during the whole
period of the Commonwealth, and so may be presumed not to
have been a “Churchman” in the commonly received sense of
the term. “One Macham,” of whom Fox speaks, and who
seems to have treated him with more sympathetic kindness
than any of the others, was a loyal Churchman and was
sequestered in 1645, as a penalty for his adherence to the
bishop and the king to whom he had sworn allegiance. It is
rather surprising to find historians in general, even those who
should be better informed, assuming that, because these men
were filling the parishes of the Church of England, they were,
therefore, Church of England clergymen.
3
Bishop, George, New England Judged, London, 1661, pp. 14–
25.
4
Geo. E. Ellis, Memorial History of Boston, vol. i. p. 181.
5
Hubbard’s History of New England, p. 553.
6
Massachusetts Records, iv. (1), 276.
7
Bishop, 5–13.
8
Hazard, Historical Collections, ii. 349. Rhode Island Records, i.
374.
9
Mass. Records, iv. (1), 277.
10
Bishop, 38, 39.
11
Bishop, 40, 42.
12
Mass. Records, iv. (1), 308. Bishop, 50.
13
Mass. Records, iv. (1), 325.
14
Bishop, 72, 73.
15
Mass. Records, iv. (1), 345, 346.
16
Mass. Archives, vol. x. p. 246.
17
Mass. Records, iv. (1), 348. (In payment for this work Norton
received five hundred acres of land, a good price for a sermon.
Ibid., p. 397.)
18
The Heart of New England Rent at the Blasphemies of the
Present Generation. Printed by Samuel Green, Cambridge in
New England, 1659. The arguments used in this declaration
are so characteristic of the spirit of the times that the following
extract may be useful. The author has been demonstrating that
the Quakers were heretical on various points of the faith, and
that the Scriptures authorize the punishment of false believers.
He continues:
“But other Scriptures omitted, I shall here transcribe only two
more, both of which are eminently pregnant with this truth:
wherein also are cases put between the cause of God and our
near relations, on purpose to provide against obstructions in
this great business of religion.
The first we have Deut. xiii. per totum.
Relating to all times succeeding that constitution; ‘If thy
brother, the son of thy mother, or thy son, or thy daughter, or
the wife of thy bosom, or thy friend, which is as thine own soul,
entice thee secretly, saying, Let us go and serve other gods,
which thou hast not known, thou, nor thy fathers; Thou shalt
not consent unto him, nor hearken unto him; neither shalt thine
eyes pity him, neither shalt thou spare, neither shalt thou
conceal him.’ vers. 6, 8. The second we have Zech. xiii. 1, 3.
Expressly relating unto the times of the Gospel. In that day,
viz.: after the Coming of the Messiah in the time of the Gospel
when the families of the tribes shall mourne Chapt. xii. 11. The
familie of the house of David apart, & the familie of the house
of Nathan apart, etc. There shall be a fountain opened, i. e. the
doctrine of Christ under Moses’ dispensation is compared to a
fountain vailed, 2 Cor. iii. 13, etc. Under the Gospel
dispensation to a fountain opened. The vail of the Temple &
the ceremonial law being taken away. And it shall come to
pass that when any shall yet Prophecie, then his father & his
mother that begat him, shall thrust him through, when he
prophecieth. These words [thrust him through] may be
understood either of a Capital punishment judicially dispensed,
or of any other smart punishment piercing though not Capital.
* * * * *
“Wee through grace abhorre prejudicing the liberty of
conscience the least measure, and account such report of us
to be a slander. And through the same grace; Wee both dread,
and beare witness against, liberty of heresy, liberty to
Blaspheme the Blessed Trinity, the Person and Office of Christ,
the holy-Scripture, the tabernacle of God, and those that dwell
in heaven. Howsoever fallaciously transformed into, and
misrepresented under the plausible vizard of liberty of
conscience falsely so called. We say Religion is to be
perswaded with Scripture-reasons, not Civil weapons: with
Arguments, not with punishments. But blasphemies immediate
and heresies carried on with an high hand, and persisted in are
to be suppressed with weapons and punishments; where
reasons, and arguments cannot prevail.
We distinguish between Heresie (Quiet and alone,
Turbulent, i. e. incorrigible) accompanied with soliciting the
people to apostacy from the Faith of Christ to defection from
the churches, to Sedition in the Commonwealth. And that after
due meanes of conviction, and Authoritative prohibition.
We subject not any to Civil or Corporal punishment for
heresie, if quiet and alone. We do not inflict any Church-
censure in case of heresie, without doctrinal conviction on the
Churche’s part, and contumacy on the delinquent’s part
foregoing.
In case of Heresie incorrigible, in conjunction with
endeavours to seduce others thereunto, and tending to the
disturbing of Publick-order, we acknowledge it to be the pious
Wisdom of the Magistrate to proceed gradually, and where
gentler meanes may rationally be looked at as effectual, there
to abstain from the use of any severer remedie.
And according to this method, hath been the gradual
proceeding of the Magistrate here, with those (hitherto
incorrigible) Quakers, who from England have unreasonably
and insolently obtruded themselves upon us. 1. Instructing
them. 2. Restraining them untill an opportunity for their returne.
3. Publishing a law to warne and prohibite both them and all
others of that sect, from Coming into this jurisdiction: otherwise
to expect the house of Correction. And in case they returned
yet again, then to loose one of their eares, etc.
At last upon experience of their bold contempt of these
inferior restraints, and that after their being sent away again
and again, they continue to return yet again and again; to the
seducing of diverse, the disturbance, vexation and hazard of
the whole Colonie. The Court finding the Law passed, to be an
insufficient fence against these persons, proceeded to a
Sentence of Banishment.
Their restraint before the Law published, was but restraint in
the Prison, until an opportunity of shipping them away. They
who after the Law was published, would that notwithstanding,
break in upon us from England, or other forraign parts, by
Rode-Island, after their correction received, and discharging
their dues, might return again to the Island, if they pleased.
The wolfe which ventures over the wild Sea, out of a ravening
desire to prey upon the sheep, when landed, discovered and
taken, hath no cause to complain, though for the security of the
flock, he be penned up, with the door opening unto the fold fast
shut; but having another door purposely left open, whereby he
may depart at his pleasure either returning from whence he
came, or otherwise quitting the place.
Their Sentence of Banishment as Circumstanced, by an
Impartial and equal eye, may be looked upon as an Act which
the court was forced unto se defendendo, in defence of
Religion, themselves, the Churches, and this poore State and
People from Ruine: which the principles of confusion, daylie
and studiously disseminated by them, threatened to bring all
unto, if not seasonably prevented. Exile from a wilderness,
from a place of exile; though voluntarie, from a place;
confinement whereunto would indeed justly be called exile, is
an easie exile.” (Pages 48, 49, 53, 54.)
19
Rhode Island Records, i. 376–378. See also the letter of the
General Assembly, 378–380.
20
Bishop, 95.
21
Mass. Records, iv. (1), 383.
22
The Sufferings of the People called Quakers, by Jos. Besse,
London, 1753, ii. p. 177.
23
Bishop, 89–95, 109.
24
Hubbard’s History of New England, p. 173. See also an
Address to the King (Charles II.), Dec. 19, 1660, in which the
colonial authorities argue as follows: “Concerning the Quakers,
open and capitall blasphemers, open seducers from the
glorious Trinity, the Lord’s Christ, our Lord Jesus Christ, etc.
the blessed gospell, and from the Holy Scriptures as the rule of
life, open enemies to government itself as established in the
hands of any but men of their oune principles, malignant and
assiduous promoters of doctrines directly tending to subvert
both our churches and state, after all other meanes for a long
time used in vajne, wee were at last constrejned, for our oune
safety, to pass a sentence of banishment against them, vpon
pajne of death. Such was theire daingerous, impetuous, &
desperat turbulency, both to religion & the state civil &
ecclesiastical, as that how vnwillingly soever, could it have binn
avoyded, the magistrate at last, in conscience both to God and
Man, judged himself called for the defense of all, to keep the
passage with the point of the sword held towards them. This
could do no harm to him that would be warned thereby: theire
wittingly rushing themselves therevpon was theire oune act, &
wee, wth all humility, conceive a cryme bringing theire blood on
theire oune head. The Quakers died, not because of theire
other crymes, how capitall soever, but vpon theire superadded
presumptuous & incorrigible contempt of authority; breaking in
vpon vs notwthstanding theire sentence of banishment made
knoune to them. Had they not binn restreigned, so farr as
appeared, there was too much cause to feare that wee
ourselves must quickly haue dyed, or worse; and such was
theire insolency, that they would not be restreined but by
death; nay, had they at last but promised to depart the
jurisdiction, and not to returne wthout leaue from authority, wee
should haue binn glad of such an opportunity to haue sayd
they should not dye.” Mass. Records, iv. (1), 450–453. Bishop,
113.
25
Mass. Records, iv. (1), 419.
26
Mass. Records, iv. (1), 366. Bishop, 90, 91.
27
Bishop, 44–48, 52–54.