Skip to content

Commit fbf2afa

Browse files
committed
Clean code.
1 parent a30bfcb commit fbf2afa

31 files changed

+697
-251
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.DS_Store
2+
artifacts/
23
node_modules/

README.md

Lines changed: 6 additions & 230 deletions
Original file line numberDiff line numberDiff line change
@@ -1,240 +1,14 @@
1-
# ⛓️ Blockchain Lab
1+
# 📧 Crypto Lab
22

3-
## 1. Download and Install Docker
4-
5-
https://www.docker.com/get-started
6-
7-
Start the newly installed **Docker** application.
8-
9-
## 2. Run Debian linux
10-
11-
### 2.1 Mac
12-
13-
Open the Terminal (`Terminal`) app and run:
14-
15-
```sh
16-
docker run -it debian
17-
```
18-
19-
### 2.2 Windows
20-
21-
#### 2.2.1 Instal Terminal app
22-
23-
It is recommended that you install the Terminal app for Windows available at:
24-
25-
[https://www.microsoft.com/en-us/p/windows-terminal/9n0dx20hk701](https://www.microsoft.com/en-us/p/windows-terminal/9n0dx20hk701)
26-
27-
Open the Terminal (`Terminal`) app and run:
28-
29-
```sh
30-
docker run -it debian
31-
```
32-
33-
> ### Reuse a previous container
34-
>
35-
> Or to reuse your a previously started container run:
36-
>
37-
>```sh
38-
>docker attach $(docker start $(docker ps -l -q))
39-
> ```
40-
41-
### 2.3 Command prompt
42-
43-
You will evenutually see a line similar to this:
44-
45-
```sh
46-
root@5555b7f58ebe:/#
47-
```
48-
49-
This is the _command prompt_ of the Debian operating system that is now running within a container on your computer.
50-
51-
#### 2.3.1 Verify
52-
53-
Type the following command to show the Debian version:
54-
55-
```sh
56-
cat /etc/os-release
57-
```
58-
59-
It should output `Debian GNU/Linux 12 (bookworm)` amongt other information.
60-
61-
## 3. Install Ethereum client
62-
63-
### 3.1 Install `wget`
64-
65-
`wget` is a utility which can download files from the internet. To install `wget` run:
66-
67-
```sh
68-
apt-get update && apt-get install -y wget
69-
```
70-
71-
### 3.2 Download `geth`
72-
73-
`geth ` is the most popular Ethereum client. It is written in the _Go_ programming language.
74-
75-
To download `geth`,
76-
77-
if you have processor with an x64 architecture (e.g., AMD, Intel), run:
78-
79-
```sh
80-
cd && wget -O geth.tar.gz https://gethstore.blob.core.windows.net/builds/geth-alltools-linux-amd64-1.13.4-3f907d6a.tar.gz
81-
```
82-
83-
if you have processor with an ARM architecture (e.g., Apple M1), run:
84-
85-
```sh
86-
cd && wget -O geth.tar.gz https://gethstore.blob.core.windows.net/builds/geth-alltools-linux-arm64-1.13.4-3f907d6a.tar.gz
87-
```
88-
89-
### 3.3 Install `geth`
90-
91-
To unpack and install then downloaded program files run:
92-
93-
```sh
94-
cd && tar -xvf geth.tar.gz --exclude=COPYING --strip-components=1 && rm geth.tar.gz && chmod u+x * && mv * /usr/bin
95-
```
96-
97-
### 3.4 Verify result
98-
99-
Type the following command to show the location of the `geth` program:
100-
101-
```sh
102-
which geth
103-
```
104-
105-
It should output `/usr/bin/geth`.
106-
107-
## 4. 🥨 "Look ma, I gots them blockchains!"
108-
109-
### 4.1 Run your own Ethereum node
110-
111-
You are now ready to participate in the Ethereum network. To start you local node run:
112-
113-
```sh
114-
geth
115-
```
116-
117-
If you follow the output, you will notice that your node will do the following:
118-
119-
1. Find _peers_
120-
2. Once found, it will start downloading a local copy of the blockchain
121-
122-
> If it fails to find any peers, it might be because your operating system firewall or the network is blocking the connections.
123-
>
124-
> Try following:
125-
>
126-
> 1. Connect to a less restrictive network, like your mobile phone hotspot
127-
> 1. ⚠️ Temporarily disable the firewall in the operating system settings (do not forget to enable the firewall after lab session)
128-
129-
If you want to stop your node press `CTRL+C`.
130-
131-
### 4.2 Interact with the blockchain using your Ethereum node CLI
132-
133-
To interact with the blockchain using your Ethereum node's CLI (command line interface a.k.a. console) run:
134-
135-
```sh
136-
geth --syncmode light --verbosity 1 console
137-
```
138-
139-
> You can find the reference for the console commands in the [Web3 documentation](https://web3js.readthedocs.io/en/v1.2.11/).
140-
141-
### 4.2.1 View peers
142-
143-
To view the peer nodes that you are currently connected to:
144-
145-
```js
146-
admin.peers
147-
```
148-
149-
You will notice that each peer has a remote IP address (here the IP address is `94.176.237.140`):
150-
151-
```js
152-
remoteAddress: "94.176.237.140:30303"
153-
```
154-
155-
You can query the peer's IP address using a [Geolocation tool](https://tools.keycdn.com/geo) to find out where they are.
156-
157-
### 4.2.2 View blocks
158-
159-
Take a look at block number `3`:
160-
161-
```js
162-
eth.getBlock(3)
163-
```
164-
165-
Take a look at the latest block number:
166-
167-
```js
168-
eth.blockNumber
169-
```
170-
171-
Take a look at the latest block:
172-
173-
```js
174-
eth.getBlock(eth.blockNumber)
175-
```
176-
177-
### 4.2.3 View some funny stuff in block number 14000
178-
179-
Block number `14000` has an interesting message in it's _extra data_:
180-
181-
```js
182-
web3.toAscii(eth.getBlock(14000).extraData)
183-
```
184-
185-
Now take look at the _extra data_ in the latest block:
186-
187-
```js
188-
web3.toAscii(eth.getBlock(eth.blockNumber).extraData)
189-
```
190-
191-
### 4.2.4 Dive deeper into block transactions
192-
193-
Take a look at block `1000000`:
194-
195-
```js
196-
eth.getBlock(1000000)
197-
```
198-
199-
Block `1000000` has two transactions. Take a look at the first transaction in that block:
200-
201-
```js
202-
eth.getTransaction("0xea1093d492a1dcb1bef708f771a99a96ff05dcab81ca76c31940300177fcf49f")
203-
```
204-
205-
Take a look at how much Ether the account that mined the last block has:
206-
207-
```js
208-
web3.fromWei(eth.getBalance(eth.getBlock(eth.blockNumber).miner), "Ether")
209-
```
210-
211-
### 4.2.5 Create a new account
212-
213-
Create a new account:
214-
215-
```js
216-
personal.newAccount()
217-
```
218-
219-
## 4.2.6 Exit the Geth console
220-
221-
Exit the console:
222-
223-
```js
224-
exit
225-
```
226-
227-
# ✉️ Crypto Lab
228-
229-
## 1. Install Docker
3+
## 1. Install Docker Desktop
2304

2315
On Mac:
2326

233-
[https://download.docker.com/mac/stable/Docker.dmg](https://download.docker.com/mac/stable/Docker.dmg)
7+
[https://docs.docker.com/desktop/setup/install/mac-install/](https://docs.docker.com/desktop/setup/install/mac-install/)
2348

2359
On Windows:
23610

237-
[https://download.docker.com/win/stable/Docker%20Desktop%20Installer.exe](https://download.docker.com/win/stable/Docker%20Desktop%20Installer.exe)
11+
[https://docs.docker.com/desktop/setup/install/windows-install/](https://docs.docker.com/desktop/setup/install/windows-install/)
23812

23913
## 2. Run Debian linux
24014

@@ -357,6 +131,7 @@ Create a private key:
357131
```sh
358132
openssl genpkey -algorithm RSA -out private.txt
359133
```
134+
360135
#### 4.2.1 View the private key
361136

362137
View the created private key:
@@ -372,6 +147,7 @@ Derive a public key:
372147
```sh
373148
openssl rsa -pubout -in private.txt -out public.txt
374149
```
150+
375151
#### 4.2.4 View the public key
376152

377153
View the created public key:

contracts/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# 📜 Smart Contracts
2+
3+
Minimal smart contract examples.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

package.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

web3-erc20/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ <h4 class="ui dividing header">System log</h4>
3737
<br/>
3838
</div>
3939
<script type="module">
40-
const node = "https://eth-mainnet.gateway.pokt.network/v1/lb/29934f7f10137fb45e8609a0";
40+
const node = "https://ethereum-rpc.publicnode.com";
4141
const provider = new ethers.JsonRpcProvider(node);
4242

4343
document.querySelector("#getBlockNumber").addEventListener("click", async () =>

0 commit comments

Comments
 (0)