A production-ready Python Web3 starter template.
Create your first blockchain wallet using Python and learn how to manage private keys securely.
wallet_tutorial/
├── scripts/
│ └── activate.ps1
├── src/
│ ├── main.py
│ ├── wallet.py
│ └── check_key.py
├── tests/
├── logs/
├── .venv/
├── .env
├── .gitignore
├── requirements.txt
└── README.md
- Generate a wallet
- Create a wallet address
- Store private keys in
.env - Recover wallet from private key
- Verify wallet address
- Automatic virtual environment management
- Python 3.11+
- Windows PowerShell
Check your Python version:
python --versionCreate a virtual environment:
python -m venv .venvActivate the environment:
.\scripts\activate.ps1If .venv does not exist, the script will create it automatically.
pip install web3
pip install eth-account
pip install python-dotenvOr install all dependencies:
pip install -r requirements.txtpython src/main.pyExample output:
Wallet Address: 0x1234...
Recovered Address: 0x1234...
Wallet verification success
The application automatically creates:
PRIVATE_KEY=xxxxxxxxxxxxxxxx
WALLET_ADDRESS=0x1234567890Never:
- Upload your
.env - Commit
.envto GitHub - Share your private key with anyone
Recommended .gitignore:
.env
.venv/
__pycache__/
logs/
Responsible for:
- Wallet generation
- Wallet persistence
Responsible for:
- Loading private keys
- Recovering wallets
- Verifying addresses
Application entry point:
Create Wallet
↓
Save Private Key
↓
Recover Wallet
↓
Verify Wallet
Connect to an RPC node and query wallet balances.
Topics include:
- Web3 initialization
- RPC configuration
- Query ETH balance
- Query latest block number
- Verify blockchain connectivity