Testing Your Luck: Generating an Ethereum Wallet and Checking Its Balance

Testing Your Luck: Generating an Ethereum Wallet and Checking Its Balance

Have you ever wondered what it would be like to randomly generate an Ethereum wallet and check if it has any balance? Well, let’s be honest—it’s a near-impossible dream, but that doesn’t mean we can’t have some fun testing our luck!

In this blog post, we’ll explore a simple Python script that generates an Ethereum wallet and checks its balance. If you’re the luckiest person in the world, who knows? You might just stumble upon an old wallet with some forgotten ETH!

Setting Up Your Environment

Before running the script, ensure you have Python installed along with the required dependencies. You can install the necessary package using:

1
pip install eth_account --break-system-packages

This will install the eth_account package, which allows us to generate Ethereum wallets programmatically.

Bypassing Public Node Rate Limits

If you want to check balances at scale, relying on public Ethereum nodes isn’t practical since they often limit requests to 5-10 per second. You might consider running your own Ethereum node using services like Infura, Alchemy, or a self-hosted Geth node. This way, you can perform unlimited checks without hitting request limits. Check my lastest post for the tutorial to install Ethereum node. In this example, the IP of Ethereum node is: 192.168.1.150

The Ethereum Wallet Generator

Here’s a simple Python script that generates an Ethereum private key, derives the corresponding public address, and checks the balance:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import requests
import json
import secrets
import threading
import time
from eth_account import Account

def generate_eth_account():
"""
Generate a new Ethereum account with a private key.

:return: Tuple (private_key, address)
"""
private_key = "0x" + secrets.token_hex(32)
account = Account.from_key(private_key)
return private_key, account.address

def get_eth_balance(node_url, address):
"""
Fetch the Ethereum balance of a given address from a JSON-RPC node.

:param node_url: The URL of the Ethereum node (e.g., http://192.168.1.150:8080)
:param address: The Ethereum address to query
:return: Balance in Ether (float)
"""
payload = {
"jsonrpc": "2.0",
"method": "eth_getBalance",
"params": [address, "latest"],
"id": 1
}

headers = {"Content-Type": "application/json"}

try:
response = requests.post(node_url, headers=headers, data=json.dumps(payload))
response_data = response.json()

if "result" in response_data:
wei_balance = int(response_data["result"], 16)
ether_balance = wei_balance / 1e18
return ether_balance
else:
return 0.0
except requests.exceptions.RequestException as e:
return 0.0

global_counter = 0
good = 0
counter_lock = threading.Lock()
start_time = time.time()
num_threads = 300 # Adjust the number of threads as needed

def process_account(node_url):
"""
Generate an Ethereum account, get its balance, and save results to files.
Runs indefinitely.
"""
global global_counter, num_threads, good, start_time
while True:
private_key, address = generate_eth_account()
balance = get_eth_balance(node_url, address)

log_entry = f"{address} {private_key} {balance}\n"

with open("log.txt", "a") as log_file:
log_file.write(log_entry)

if balance != 0.0:
with open("good.txt", "a") as good_file:
good_file.write(log_entry)
good += 1

with counter_lock:
global_counter += 1
if global_counter % 1000 == 0:
elapsed_time = time.time() - start_time
print(f"{global_counter} checked | Runtime: {elapsed_time:.2f} seconds | Total {num_threads} threads | Total {good} good")
start_time = time.time()

def main():
node_url = "http://192.168.1.150:8080"


threads = [threading.Thread(target=process_account, args=(node_url,), daemon=True) for _ in range(num_threads)]

for thread in threads:
thread.start()

for thread in threads:
thread.join()

if __name__ == "__main__":
main()

Why Is This Fun but Unrealistic?

Ethereum addresses are derived from a 256-bit private key space, meaning there are 2^256 possible addresses. The chances of generating an address that already has ETH are astronomically small—essentially impossible. But hey, it’s still fun to dream, right?

Final Thoughts

Give it a shot and let me know if you hit the jackpot (spoiler: you won’t). 😆 Happy coding!

Installing an Ethereum Blockchain Node using Geth

Prerequisites

Ensure that your system meets the following requirements:

  • RAM: At least 16GB
  • Storage: At least 2TB
  • Internet: A stable and fast connection

All commands in this guide are executed as the root user.


1. Install Geth

Update and Install Dependencies

Run the following commands to update your system and install essential packages:

1
2
sudo apt update && sudo apt upgrade -y
sudo apt install -y git build-essential

Install Go (Golang)

Geth requires Go, so install it using the commands below:

1
2
wget https://go.dev/dl/go1.21.7.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.21.7.linux-amd64.tar.gz

Configure Environment Variables

Edit your ~/.bashrc file:

1
nano ~/.bashrc

Add the following lines at the end of the file:

1
2
3
export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin

Apply the changes:

1
source ~/.bashrc

Download and Build Geth

1
2
3
4
git clone https://github.com/ethereum/go-ethereum.git
cd go-ethereum
make geth
sudo cp build/bin/geth /usr/local/bin/

2. Running Geth

Create a Data Directory and Start Geth

1
2
3
4
5
6
7
mkdir ~/ethereum
geth --datadir ~/ethereum \
--http --http.port 8080 --http.addr "0.0.0.0" \
--syncmode "snap" \
--authrpc.addr "127.0.0.1" --authrpc.port 8551 \
--authrpc.jwtsecret ~/ethereum/geth/jwtsecret \
--maxpeers 100

This will start Geth and expose the JSON-RPC API on port 8080.

(Optional) Disable IPv6

If you experience network issues, disabling IPv6 can help:

1
2
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1

3. Install and Run Lighthouse (Consensus Layer)

Ethereum transitioned to Proof-of-Stake (PoS) in 2022. This means you need both:

  • Execution Layer (EL) → Geth
  • Consensus Layer (CL) → Lighthouse (or another beacon client)

Install Rust and Build Lighthouse

1
2
3
4
5
6
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
rustup update
git clone https://github.com/sigp/lighthouse.git
cd lighthouse
make

(Troubleshooting) Install Required Dependencies

If you encounter errors while running make, install clang and other required dependencies:

1
2
3
sudo apt install -y libc6-dev build-essential clang cmake
export CC=gcc
export CFLAGS="-I/usr/include"

Run Lighthouse

1
lighthouse beacon_node --network mainnet --datadir ~/beacon --http --http-address 0.0.0.0 --http-port 5052 --execution-endpoint http://127.0.0.1:8551 --execution-jwt ~/ethereum/geth/jwtsecret --checkpoint-sync-url https://mainnet-checkpoint-sync.attestant.io

You may check more endpoints at: (https://eth-clients.github.io/checkpoint-sync-endpoints/)

⚠️ Make sure Geth is running before starting Lighthouse.


4. Testing Your Ethereum Node

Once both Geth and Lighthouse are running, you can test your node by making an RPC call:

1
2
3
curl -X POST -H "Content-Type: application/json" \
--data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \
http://192.168.1.150:8080

If your node is running correctly, it will return something like:

1
{"jsonrpc":"2.0","id":1,"result":"0x0"}

(Replace 192.168.1.150 with your actual server IP.)


Final Notes

  • This tutorial sets up an Ethereum full node using Geth and Lighthouse.
  • Your node will synchronize with the Ethereum network, which can take time.
  • Ensure your system meets the hardware requirements to avoid performance issues.

Check status:

Command:

1
geth attach ~/ethereum/geth.ipc

In console:

1
eth.syncing

Example results:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{
currentBlock: 8959360,
healedBytecodeBytes: 0,
healedBytecodes: 0,
healedTrienodeBytes: 0,
healedTrienodes: 0,
healingBytecode: 0,
healingTrienodes: 0,
highestBlock: 21971505,
startingBlock: 0,
syncedAccountBytes: 29609285538,
syncedAccounts: 137604971,
syncedBytecodeBytes: 5151118382,
syncedBytecodes: 794044,
syncedStorage: 609184446,
syncedStorageBytes: 135929810634,
txIndexFinishedBlocks: 0,
txIndexRemainingBlocks: 1
}
1
net.peerCount

Hexo Copy Button For Code Block

Add Copy Button For Hexo Code Block

I am using Clipboard.js to achieve this.

Step 1:

Create a clipboard-use.js file in your JavaScript folder. In my case, the path is:
/var/www/myblog/themes/landscape/source/js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
!function (window, document) {
var initCopyCode = function() {
var copyHtml = '';
copyHtml += '<button class="btn-copy" data-clipboard-snippet>';
copyHtml += ' <i class="fa fa-copy"></i><span>Copy</span>';
copyHtml += '</button>';
$(".highlight .code pre").before(copyHtml);
new ClipboardJS('.btn-copy', {
target: function(trigger) {
return trigger.nextElementSibling;
}
});
};
initCopyCode();
}(window, document);

Step 2:

Add the script tag to the after-footer template. Make sure to place it below the jQuery script tag.
In my case, the file is located at:
/var/www/myblog/themes/landscape/layout/_partial/after-footer.ejs

1
2
3
4
<!-- Load Clipboard.js from CDN -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/clipboard.min.js"></script>
<!-- Load your custom script -->
<script type="text/javascript" src="/js/clipboard-use.js"></script>

Step 3:

Add the necessary CSS.
For this demo, I have added the styles in: /var/www/myblog/themes/landscape/source/css/style.styl

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//copy button in code block

.highlight{
position: relative;
}
.btn-copy {
display: inline-block;
cursor: pointer;
background-color: #eee;
background-image: linear-gradient(#fcfcfc,#eee);
border: 1px solid #d5d5d5;
border-radius: 3px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-webkit-appearance: none;
font-size: 13px;
font-weight: 700;
line-height: 20px;
color: #333;
-webkit-transition: opacity .3s ease-in-out;
-o-transition: opacity .3s ease-in-out;
transition: opacity .3s ease-in-out;
padding: 2px 6px;
position: absolute;
right: 5px;
top: 5px;
opacity: 0;
}
.highlight:hover .btn-copy{
opacity: 1;
}
.btn-copy span {
margin-left: 5px;
}

Step 4:

Run the following commands in your terminal:

1
2
3
cd /var/www/myblog/
hexo clean && hexo g
hexo server

Done 🎉

Your Hexo blog should now display a Copy button in the code blocks, allowing users to quickly copy the code. 🚀

Docker and Portainer Install Tutorial

Installing Docker, Docker Compose, and Portainer on Ubuntu

Prerequisites

  • A system running Ubuntu (20.04, 22.04, or later).
  • A user with sudo privileges.

Step 1: Update the System

1
sudo apt update && sudo apt upgrade -y

Step 2: Install Required Dependencies

1
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common

Step 3: Install Docker

Add Docker’s Official GPG Key:

1
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

Add the Docker Repository:

1
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Install Docker Engine:

1
2
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io

Verify Docker Installation:

1
docker --version

Enable and Start Docker Service:

1
sudo systemctl enable --now docker

Add Your User to the Docker Group (Optional):

1
2
sudo usermod -aG docker $USER
newgrp docker

Step 4: Install Docker Compose

Download and Install Latest Version:

1
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

Apply Executable Permissions:

1
sudo chmod +x /usr/local/bin/docker-compose

Verify Installation:

1
docker-compose --version

Step 5: Install Portainer

Create a Docker Volume for Portainer:

1
docker volume create portainer_data

Deploy Portainer Container:

1
2
3
4
5
6
7
docker run -d \
--name=portainer \
--restart=always \
-p 8000:8000 -p 9443:9443 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v portainer_data:/data \
portainer/portainer-ce:latest

Access Portainer Web UI:

Open a web browser and go to:

1
https://<your-server-ip>:9443

Create an admin account and start managing your containers.


Conclusion

You have successfully installed Docker, Docker Compose, and Portainer on Ubuntu. 🎉 Happy containerizing!

Who am I

Who am I?

Hi there! I’m just a curious soul who loves dabbling in the world of IT. I enjoy learning about coding, design, and all things tech-related, but let’s be real — I’m more of a “copy and paste” kind of person than a hardcore developer. If there’s a snippet of code or a cool design trick out there, you can bet I’ll grab it, tweak it, and make it my own!

What really gets me excited is playing around with AI. I love using it to mess with computers — whether it’s generating something fun, automating a boring task, or just seeing what crazy things I can make happen. Technology is like a playground for me, and AI is my favorite toy.

So yeah, that’s me in a nutshell: a bit lazy, a lot curious, and always ready to experiment with the next cool thing I find online. Stick around if you’re into quick hacks and AI-powered adventures!

Code Disclaimer

Hey, listen up! Every single piece of code you see on this page? Yup, it’s all copy and paste. I didn’t write it from scratch — I snagged it from somewhere out there in the wild internet, tweaked it a bit, and bam, here it is.

Warning

Big fat warning: I’m not responsible if you take this code and use it for something shady or downright evil. You wanna build a cool thing? Awesome! You wanna cause chaos? Not on my watch — but also not my problem. Use it at your own risk!

So, feel free to grab whatever you like, play with it, break it, or make it better. Just don’t come crying to me if the world explodes because of a misplaced semicolon. Happy coding (or copying)!

Made with laziness and a lot of Ctrl+C / Ctrl+V

Markdown Language Tutorials

Markdown is a lightweight markup language used to format plain text into structured documents, often used for writing documentation, README files, and web content.

Basic Markdown Syntax

Headings

Use # followed by a space for different heading levels:

1
2
3
4
5
6
# Heading 1
## Heading 2
### Heading 3
#### Heading 4
##### Heading 5
###### Heading 6

Bold & Italic

1
2
3
**Bold Text** or __Bold Text__
*Italic Text* or _Italic Text_
***Bold and Italic*** or ___Bold and Italic___

Lists

Unordered List

1
2
3
4
- Item 1
- Item 2
- Sub-item 1
- Sub-item 2

Ordered List

1
2
3
4
1. First item
2. Second item
1. Nested item
2. Nested item
1
[OpenAI](https://openai.com)

Images

1
![Alt Text](https://example.com/image.jpg)

Code Blocks

1
This is `inline code`.

Example: This is inline code.

Block Code

Use triple backticks (```) for multi-line code blocks:

1
2
3
```python
def hello():
print("Hello, World!")

Tables

1
2
3
4
| Column 1 | Column 2 | Column 3 |
|----------|----------|----------|
| Row 1 | Data 1 | Data 2 |
| Row 2 | Data 3 | Data 4 |

Task Lists

1
2
3
- [x] Task 1
- [ ] Task 2
- [ ] Task 3

Example:

  • Task 1
  • Task 2
  • Task 3

Horizontal Line

1
---

Footnotes

1
This is a footnote reference[^1].

Example:
This is a footnote reference[^1].

Escaping Characters

Use \ before Markdown symbols to escape them:

1
\*This is not italic\*

Markdown is widely used in GitHub, documentation, and blogging platforms.