You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pages/lessons/fundamentals/wolovim-part-1.mdx
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,20 +11,20 @@ icons:
11
11
12
12
# **A Developer's Guide to Ethereum, Pt. 1**
13
13
14
-
So, you’ve heard about this [Ethereum](https://ethereum.org/) thing and are ready to venture down the rabbit hole? This post will quickly cover some blockchain basics, then get you interacting with a simulated Ethereum node – reading block data, checking account balances, and sending transactions. Along the way, we’ll highlight the differences between traditional ways of building apps and this new decentralized paradigm.
14
+
So, you’ve heard about this [Ethereum](https://ethereum.org/) thing and are ready to venture down the rabbit hole? This post will quickly cover some blockchain basics, then get you interacting with a simulated Ethereum node – reading block data, checking account balances, and sending transactions. Along the way, we’ll highlight the differences between traditional ways of building apps and this new decentralized paradigm. Some code is included, but the focus is on the concepts, not a final product.
15
15
16
16
### **(Soft) prerequisites**
17
17
18
-
This post aspires to be accessible to a wide range of developers. Python tools will be involved, but they are just a vehicle for the ideas – no problem if you are not a Python developer. I will, however, be making just a few assumptions about what you already know, so we can quickly move on the Ethereum-specific bits.
18
+
This post aspires to be accessible to a wide range of developers. Python tools will be involved, but they are just a vehicle for the ideas. Reproducing the code is not required, but may help the ideas sink in. For those coding along, I'm making just a few assumptions about what you already know, so we can quickly move on the Ethereum-specific bits.
19
19
20
-
Assumptions:
20
+
Assumptions, if you are going to reproduce the code:
21
21
22
22
- you can get around in a terminal,
23
23
- you've written a few lines of Python code,
24
24
- Python version 3.7 or greater is installed on your machine (use of a [virtual environment](https://realpython.com/effective-python-environment/#virtual-environments) is strongly encouraged), and
25
25
- you’ve used `pip`, Python’s package installer.
26
26
27
-
Again, if any of these are untrue, or you don’t plan to reproduce the code in this article, just follow along conceptually.
27
+
Again, if any of these are untrue, just follow along conceptually.
28
28
29
29
### **Blockchains, briefly**
30
30
@@ -142,7 +142,7 @@ In [1]: from web3 import Web3
142
142
143
143
Besides being a gateway to Ethereum, the [Web3](https://web3py.readthedocs.io/en/stable/overview.html#base-api) module offers a few convenience functions. Let’s explore a couple.
144
144
145
-
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).
145
+
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.from_wei) and [to_wei](https://web3py.readthedocs.io/en/stable/web3.main.html#web3.Web3.to_wei).
146
146
147
147
<Calloutemoji='💡'size='md'variant='info'>
148
148
**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.
@@ -263,21 +263,21 @@ A lot of information gets returned about a block, but just a couple things to po
263
263
264
264
### **Tour stop #3: transactions**
265
265
266
-
We’re stuck at block zero until there’s a transaction to mine, so let’s give it one. Send a few test ether from one account to another:
266
+
We’re stuck at block zero until there’s a transaction to mine, so let’s give it one. If you wanted to send a few test ether from one account to another that code would look something like this:
267
267
268
268
```python
269
269
In [10]: tx_hash = w3.eth.send_transaction({
270
270
'from': w3.eth.accounts[0],
271
271
'to': w3.eth.accounts[1],
272
-
'value': w3.toWei(3, 'ether')
272
+
'value': w3.to_wei(3, 'ether')
273
273
})
274
274
```
275
275
276
-
This is typically the point where you’d wait for several seconds for your transaction to get included in a new block. The full process goes something like this:
276
+
In the "real" version, this is typically the point where you’d wait for several seconds for your transaction to get included in a new block. The full process goes something like this:
277
277
278
-
1. Submit a transaction and hold on to the transaction hash. Until it's included, the transaction is “pending.”`tx_hash = w3.eth.send_transaction({ ... })`
279
-
2. Wait for the transaction to be included:`w3.eth.wait_for_transaction_receipt(tx_hash)`
280
-
3. To view the successful transaction:`w3.eth.get_transaction(tx_hash)`
278
+
1. Submit a transaction and hold on to the transaction hash. Until it's included, the transaction is “pending.”`tx_hash = w3.eth.send_transaction({ ... })`
279
+
2. Wait for the transaction to be included:`w3.eth.wait_for_transaction_receipt(tx_hash)`
280
+
3. To view the successful transaction:`w3.eth.get_transaction(tx_hash)`
281
281
282
282
Our simulated environment will add the transaction in a new block instantly, so we can immediately view the transaction:
0 commit comments