Skip to content

Commit b94e088

Browse files
committed
add callouts, version update, style nits
1 parent 5ebdd0b commit b94e088

File tree

1 file changed

+28
-20
lines changed

1 file changed

+28
-20
lines changed

pages/lessons/fundamentals/wolovim-part-1.mdx

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ There are many ways to describe Ethereum, but at its heart is a blockchain. Bloc
4545

4646
Each block has a reference to the block that came before it; the `parentHash` is simply the hash of the previous block.
4747

48-
> Note: Ethereum makes regular use of hash functions to produce fixed-size values (“hashes”). Hashes play an important role in Ethereum, but you can safely think of them as unique IDs for now.
49-
>
48+
<Callout emoji='💡' size='md' variant='info'>
49+
**Note:** Ethereum makes regular use of hash functions to produce fixed-size values (“hashes”). Hashes play an important role in Ethereum, but you can safely think of them as unique IDs for now.
50+
</Callout>
5051

5152
![https://cdn-images-1.medium.com/max/2400/1*WfNXz5Svsxk9yB-PEIM9BQ.png](https://cdn-images-1.medium.com/max/2400/1*WfNXz5Svsxk9yB-PEIM9BQ.png)
5253

@@ -60,18 +61,19 @@ The only way for the blockchain to verify that asset was truly sent from one use
6061

6162
This new decentralized tech stack has spawned new developer tools. Such tools exist in many programming languages, but we’ll be looking through the Python lens. To reiterate: even if Python isn’t your language of choice, it shouldn’t be much trouble to follow along.
6263

63-
Python developers that want to interact with Ethereum are likely to reach for **[Web3.py](https://web3py.readthedocs.io/)**. Web3.py is a library that greatly simplifies the way you connect to an Ethereum node, then send and receive data from it.
64+
Python developers that want to interact with Ethereum are likely to reach for **[web3.py](https://web3py.readthedocs.io/)**. web3.py is a library that greatly simplifies the way you connect to an Ethereum node, then send and receive data from it.
6465

65-
> Note: “Ethereum node” and “Ethereum client” are often used interchangeably. In either case, it refers to the software that a participant in the Ethereum network runs. This software can read block data, receive updates when new blocks are added to the chain, broadcast new transactions, and more.
66-
>
66+
<Callout emoji='💡' size='md' variant='info'>
67+
**Note:** “Ethereum node” and “Ethereum client” are often used interchangeably. In either case, it refers to the software that a participant in the Ethereum network runs. This software can read block data, receive updates when new blocks are added to the chain, broadcast new transactions, and more.
68+
</Callout>
6769

68-
Ethereum clients can be configured to be reachable by [IPC](https://en.wikipedia.org/wiki/Inter-process_communication), HTTP, or Websockets. Web3.py refers to these connection options as **providers**. You’ll want to choose one of the three providers to configure so that Web3.py knows how to communicate with your node.
70+
Ethereum clients can be configured to be reachable by [IPC](https://en.wikipedia.org/wiki/Inter-process_communication), HTTP, or Websockets. web3.py refers to these connection options as **providers**. You’ll want to choose one of the three providers to configure so that web3.py knows how to communicate with your node.
6971

7072
![https://cdn-images-1.medium.com/max/1600/1*OrElsXOF45w-AgBuezCqjQ.png](https://cdn-images-1.medium.com/max/1600/1*OrElsXOF45w-AgBuezCqjQ.png)
7173

72-
Configure the Ethereum node and Web3.py to communicate via the same protocol, e.g., IPC in this diagram.
74+
Configure the Ethereum node and web3.py to communicate via the same protocol, e.g., IPC in this diagram.
7375

74-
Once Web3.py is properly configured, you can begin to interact with the blockchain. Here’s a couple of Web3.py usage examples as a preview of what’s to come:
76+
Once web3.py is properly configured, you can begin to interact with the blockchain. Here’s a couple of web3.py usage examples as a preview of what’s to come:
7577

7678
```python
7779
# read block data:
@@ -85,19 +87,20 @@ w3.eth.send_transaction({'from': ..., 'to': ..., 'value': ...})
8587

8688
In this walkthrough, we’ll just be working within a Python interpreter. We won't be creating any directories, files, classes or functions.
8789

88-
> Note: In the examples below, commands that begin with $ are intended to be run in the terminal. (Do not type the $, it just signifies the start of the line.)
89-
>
90+
<Callout emoji='💡' size='md' variant='info'>
91+
**Note:** In the examples below, commands that begin with `$` are intended to be run in the terminal. (Do not type the `$`, it just signifies the start of the line.)
92+
</Callout>
9093

91-
First, install [IPython](https://ipython.org/) for a user-friendly environment to explore in. IPython offers tab completion, among other features, making it much easier to see what’s possible within Web3.py.
94+
First, install [IPython](https://ipython.org/) for a user-friendly environment to explore in. IPython offers tab completion, among other features, making it much easier to see what’s possible within web3.py.
9295

9396
```bash
9497
$ pip install ipython
9598
```
9699

97-
Web3.py is published under the name `web3`. Install the latest version like so:
100+
web3.py is published under the name `web3`. Install the latest version like so:
98101

99102
```bash
100-
$ pip install web3==6.0.0b8
103+
$ pip install web3
101104
```
102105

103106
One more thing – we're going to simulate a blockchain later, which requires a couple more dependencies. You can install those via:
@@ -134,8 +137,13 @@ Besides being a gateway to Ethereum, the [Web3](https://web3py.readthedocs.io/e
134137

135138
In an Ethereum application, you will commonly need to convert currency denominations. The Web3 module provides a couple of helper methods just for this: [from_wei](https://web3py.readthedocs.io/en/stable/web3.main.html#web3.Web3.fromWei) and [to_wei](https://web3py.readthedocs.io/en/stable/web3.main.html#web3.Web3.toWei).
136139

137-
> Note: Computers are notoriously bad at handling decimal math. To get around this, developers often store dollar amounts in cents. For example, an item with a price of $5.99 may be stored in the database as 599.A similar pattern is used when handling transactions in ether. However, instead of two decimal points, ether has 18! The smallest denomination of ether is called wei, so that’s the value specified when sending transactions.1 ether = 1000000000000000000 wei1 wei = 0.000000000000000001 ether
138-
>
140+
<Callout emoji='💡' size='md' variant='info'>
141+
**Note:** Computers are notoriously bad at handling decimal math. To get around this, developers often store dollar amounts in cents. For example, an item with a price of $5.99 may be stored in the database as 599. A similar pattern is used when handling transactions in ether. However, instead of two decimal points, ether has 18! The smallest denomination of ether is called *wei*, so that’s the value specified when sending transactions.
142+
143+
1 ether = 1000000000000000000 wei
144+
145+
1 wei = 0.000000000000000001 ether
146+
</Callout>
139147

140148
Try converting some values to and from wei. Note that there are [names for many of the denominations](https://web3py.readthedocs.io/en/stable/examples.html#converting-currency-denominations) in between ether and wei. One of the better known among them is **gwei**, as it’s often how transaction fees are represented.
141149

@@ -151,22 +159,22 @@ Other utility methods on the Web3 module include data format converters (e.g., 
151159

152160
### **Talk to the chain**
153161

154-
The convenience methods are lovely, but let’s move on to the blockchain. The next step is to configure Web3.py to communicate with an Ethereum node. Here we have the option to use the IPC, HTTP, or Websocket providers.
162+
The convenience methods are lovely, but let’s move on to the blockchain. The next step is to configure web3.py to communicate with an Ethereum node. Here we have the option to use the IPC, HTTP, or Websocket providers.
155163

156164
We won't be going down this path, but an example of a complete workflow using the HTTP Provider might look something like this:
157165

158166
- Download an Ethereum node, e.g., [Geth](https://geth.ethereum.org/).
159167
- Start Geth in one terminal window and wait for it to sync the network. The default HTTP port is `8545`, but is configurable.
160-
- Tell Web3.py to connect to the node via HTTP, on `localhost:8545`.`w3 = Web3(Web3.HTTPProvider('http://127.0.0.1:8545'))`
168+
- Tell web3.py to connect to the node via HTTP, on `localhost:8545`.`w3 = Web3(Web3.HTTPProvider('http://127.0.0.1:8545'))`
161169
- Use the `w3` instance to interact with the node.
162170

163-
While this is one “real” way to do it, the syncing process takes hours and is unnecessary if you just want a development environment. Web3.py exposes a fourth provider for this purpose, the **EthereumTesterProvider**. This tester provider links to a simulated Ethereum node with relaxed permissions and fake currency to play with.
171+
While this is one “real” way to do it, the syncing process takes hours and is unnecessary if you just want a development environment. web3.py exposes a fourth provider for this purpose, the **EthereumTesterProvider**. This tester provider links to a simulated Ethereum node with relaxed permissions and fake currency to play with.
164172

165173
![https://snakecharmers.ethereum.org/content/images/2020/08/Screen-Shot-2020-08-31-at-2.38.23-PM.png](https://snakecharmers.ethereum.org/content/images/2020/08/Screen-Shot-2020-08-31-at-2.38.23-PM.png)
166174

167175
The EthereumTesterProvider connects to a simulated node and is handy for quick development environments.
168176

169-
That simulated node is called [**eth-tester**](https://github.com/ethereum/eth-tester) and we installed it as part of the `pip install "web3[tester]"` command. Configuring Web3.py to use this tester provider is as simple as:
177+
That simulated node is called [**eth-tester**](https://github.com/ethereum/eth-tester) and we installed it as part of the `pip install "web3[tester]"` command. Configuring web3.py to use this tester provider is as simple as:
170178

171179
```python
172180
In [4]: w3 = Web3(Web3.EthereumTesterProvider())
@@ -284,7 +292,7 @@ The latter looks good! The balance went from 1,000,000 to 1,000,003 ether. But w
284292

285293
<Callout emoji='💡' size='md' variant='info'>
286294
**Note**: On the public network, transaction fees are variable based on network demand and how quickly you'd like a transaction to be processed.
287-
</Callout>
295+
</Callout>
288296

289297
### **And breathe**
290298

0 commit comments

Comments
 (0)