Skip to content

Commit

Permalink
Clarified instructions for local node info (issue 01-edu#2411)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xalava committed Feb 16, 2024
1 parent 4730031 commit 42e4530
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions subjects/blockchain/local-node-info/README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
## Local Node Info
# Local Node Info

To start, we will create a simple page that displays basic information from our local node.
To get started, we will create a simple web page that displays basic information from our local node.

### Instructions

Create a web page, `localNodeInfo.html` that loads an ethereum library, connects to a local node at `http://localhost:8545` and displays basic information :
Create a web page called `localNodeInfo.html` that does the following:

- In an element with (`id`=`chainId`), the number ID of the current network
- In an element with `blockNumber` as `id` the number of blocks in the chain
1. Loads an Ethereum library, such as `ethers.js` or `web3.js`.
2. Connects to a local Ethereum node at `http://localhost:8545`.
3. Displays the following information on the page:
- The ID of the current network in an element with `chainId` as `id`.
- The number of blocks in the chain in an element with `blockNumber` as `id`.

![image](networkInfo.png)

![image](network-infos.png)

### Hint

You can use any library such as `ethers.js` or `web3.js` to connect to your local node.
🚫 Please be aware that the test environment restricts internet access for security reasons. Therefore, you need to download the library and import it locally.

Automated tests check for elements with specific IDs, the design is up to you.
🎨 Automated tests only check for the content of elements with specific IDs; the rest of the design is up to you.

Minimal structure:
🎁 Here is a minimal example structure for the HTML file:

```HTML
<!DOCTYPE html>
<body>
<span id="chainId"></span>
<span id="blockNumber"></span>

<script src="XXX"></script>
<script src="./XXX"></script>
<script type="module">
// Your code
</script>
Expand All @@ -34,6 +38,5 @@ Minimal structure:
```

### Notions

- [ethers Provider transaction-methods](https://docs.ethers.io/v5/api/providers/provider/#Provider--network-methods)
- [web3](https://web3js.readthedocs.io/en/v1.3.4/web3-eth.html)
- [web3 providers](https://docs.web3js.org/guides/web3_providers_guide/)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed subjects/blockchain/local-node-info/networkInfo.png
Binary file not shown.

0 comments on commit 42e4530

Please sign in to comment.