Skip to content

Commit 964529a

Browse files
committed
chore: address pr review on pt 2
1 parent 94c5a4b commit 964529a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/pages/lessons/fundamentals/eth-intro-part-2.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ This is an important takeaway: **the only way to affect a change on the blockcha
9696

9797
### Transferring ether
9898

99-
Recall that `EthereumTesterProvider` enables a test environment seeded with accounts and fake ether. Let's start by viewing some test accounts and an account balance:
99+
Do you recall that `EthereumTesterProvider` enables a test environment seeded with accounts and fake ether? Let's start by viewing some test accounts and an account balance:
100100

101101
```python
102102
In [1]: w3 = Web3(Web3.EthereumTesterProvider())
@@ -130,11 +130,11 @@ Then send one of those fake ether over to the new account:
130130
In [8]: tx_hash = w3.eth.send_transaction({
131131
'from': acct_one,
132132
'to': acct_two.address,
133-
'value': Web3.toWei(1, 'ether')
133+
'value': Web3.to_wei(1, 'ether')
134134
})
135135
```
136136

137-
This transaction will execute immediately, but some important details are hidden from view. web3.py is smart enough to know that `EthereumTesterProvider` is managing `acct_one` and that we're using a test environment. For our convenience, `acct_one` is "unlocked," meaning transactions from the account are approved (signed) by default.
137+
This transaction will execute immediately, but some important details are hidden from view. web3.py is smart enough to know that `EthereumTesterProvider` is managing `acct_one` and that we're using a test environment. For our convenience, `acct_one` is "unlocked", meaning transactions from the account are approved (signed) by default.
138138

139139
So, what does a transaction look like if not from an unlocked account? To find out, let's send some ether from `acct_two` – an account not managed by `EthereumTesterProvider`. This more manual process takes three steps: 1) specify the transaction details, 2) sign the transaction, then 3) broadcast the transaction to the network.
140140

@@ -155,7 +155,7 @@ In[10]: signed = w3.eth.account.sign_transaction(tx, acct_two.key)
155155
In[11]: tx_hash = w3.eth.send_raw_transaction(signed.rawTransaction)
156156
```
157157

158-
Let's break that down. Step 1 defines a Python dictionary with the required transaction fields. We briefly learned about gas (transaction fees) in Part 1, but nonce may be new territory. In Ethereum, a **nonce** is simply the transaction count of the account. The Ethereum protocol keeps track of this value to prevent double-spending.
158+
Let's break that down. Step 1 defines a Python dictionary with the required transaction fields (A dictionary, or `dict`, is a Python type similar to an object in other programming languages). We briefly learned about gas (transaction fees) in Part 1, but nonce may be new territory. In Ethereum, a **nonce** is simply the transaction count of the account. The Ethereum protocol keeps track of this value to prevent double-spending.
159159

160160
Since this is the first transaction being made by `acct_two`, its nonce is zero. If you supply the wrong value, the result is an invalid transaction and is rejected by web3.py:
161161

@@ -165,7 +165,7 @@ ValidationError: Invalid transaction nonce: Expected 0, but got 4
165165

166166
Note that a nonce is still required when sending a transaction from `acct_one`, but `EthereumTesterProvider` keeps track of transaction counts for managed accounts and adds the appropriate nonce to new transactions.
167167

168-
Another detail you may have noticed is that a `from` value is missing from `tx`. In this case, the `sign_transaction` method can infer the sender's address from their private key. Again, a public address can be derived from a private key, but a private key cannot be reverse engineered from its public address.
168+
Another detail you may have noticed is that a `from` value is missing from the `tx` dict. In this case, the `sign_transaction` method can infer the sender's address from their private key. Again, a public address can be derived from a private key, but a private key cannot be reverse engineered from its public address.
169169

170170
Finally, a "raw" transaction is just the transaction data and signature represented as bytes. Under the hood, `send_transaction` performs the same encoding required by `send_raw_transaction`.
171171

@@ -186,7 +186,7 @@ tx = {
186186
}
187187
```
188188

189-
Besides requiring more gas, the only other distinction in a contract deployment transaction is the absence of a `to` value. The rest of the process is identical to a standard transfer of ether.
189+
Besides requiring more gas, the only other distinction in a contract deployment transaction is the absence of a `to` value. Intuitively, this makes some sense: if you're not sending value to another user or interacting with a deployed smart contract, the only option remaining is the deployment of a new contract which does not yet have a public address. The rest of the process is identical to a standard transfer of ether.
190190

191191
### Interacting with smart contracts
192192

@@ -208,7 +208,7 @@ tx_hash = Example.constructor().transact()
208208

209209
Transactions are the only way to affect the state of the blockchain, but they aren't the only way an account can be utilized. Simply proving ownership of a particular account can be useful in its own right.
210210

211-
As an example, OpenSea, an Ethereum marketplace, will allow you to bid on items for sale by signing a message with your account. Only when an auction expires or the seller accepts your offer is an actual transaction placed. Similarly, the app uses signed messages as a form of authentication before showing you some account details.
211+
As an example, an NFT marketplace may allow you to bid on items for sale by signing a message with your account. Only when an auction expires or the seller accepts your offer is an actual transaction executed. (Important caveat: in order to execute a trade, you will have to have already approved the marketplace's ability to move your tokens.) The same marketplace can also use signed messages as a form of authentication before showing you some account details.
212212

213213
Unlike transactions, signed messages cost nothing. They aren't broadcast to the network and aren't included in a block. A message is simply a bit of data signed with a private key. As you would expect, the private key of the sender remains hidden, but the receiver can mathematically prove the public address of the sender. In other words, the message sender can't be spoofed.
214214

0 commit comments

Comments
 (0)