This repository demonstrates simple Ethereum interactions in Python using Web3.py.
ethereum-interactions/bored_ape_interaction.py:- Connects to an Ethereum HTTPS provider (e.g., Infura)
- Fetches the latest block
- Reads a wallet balance in Wei
- Interacts with the Bored Ape Yacht Club contract (owner, total supply, symbol, token URI, ownerOf)
python -m venv .venv
source .venv/bin/activate
pip install web3
export INFURA_HTTPS_URI="https://mainnet.infura.io/v3/<your-key>"
python ethereum-interactions/bored_ape_interaction.py- The script is read-only (no transactions are sent).
- The provider URL is read from
INFURA_HTTPS_URI.
- Dependency pinning
- Add a
requirements.txtorpyproject.tomlwith pinned versions for reproducibility.
- Add a
- Configuration clarity
- Add a
.env.exampleshowing required environment variables.
- Add a
- Error handling for RPC calls
- Catch and explain common JSON-RPC/network errors for smoother onboarding.
- Minimal test coverage
- Add unit tests for helper functions and optionally mock Web3 calls.
- Output formatting
- Print selected latest-block fields (number/hash/timestamp) to keep output readable.
- Structure-preserving split
- Keep one script for demo use, but move constants and ABI into a small helper module.