Skip to main content

python-viem

python-viem is a lightweight Python utility that mirrors EVM chain metadata from the Viem TypeScript library. It enables standardized, cross-language access to chain definitions and supports fast O(1) lookups by chain ID, name, or network slug.


Installation

pip install python-viem

uv add python-viem # for uv users

Features

  • Instant chain metadata lookup by:
    • chain_id (e.g., 8453 → "Base")
    • name (e.g., "Polygon" → 137)
    • network (e.g., "base-sepolia" → 84532)

Usage

from python_viem import get_chain_by_id, get_chain_by_name, get_chain_by_network
from python_viem.viem import CHAINS_BY_NETWORK, CHAINS_BY_NAME, CHAINS_BY_ID

print(get_chain_by_id(8453)["name"])        # Base
print(get_chain_by_name("polygon")["id"])   # 137
print(get_chain_by_network("base-sepolia")["id"])  # 43113

print(list(CHAINS_BY_NETWORK.keys())) # List of all network keys
print(list(CHAINS_BY_NAME.keys()))    # List of all chain names
print(list(CHAINS_BY_ID.keys()))      # List of all chain IDs

Functions

get_chain_by_id(chain_id: int) -> Optional[Dict[str, Any]]
get_chain_by_name(name: str) -> Optional[Dict[str, Any]]
get_chain_by_network(network: str) -> Optional[Dict[str, Any]]

All functions return the full chain metadata dictionary or None if not found.


Project Structure

python_viem/
├── __init__.py
├── viem.py
├── viem-chains.json

License

MIT

Metadata

Release files for python-viem 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-viem 0.1.3
File Size Uploaded
python_viem-0.1.3.tar.gz 45.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-viem 0.1.3
File Interpreter ABI Platform
python_viem-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 89.9 kB

Release files / python_viem-0.1.3.tar.gz

Download URL python_viem-0.1.3.tar.gz
Size 45.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ddccf689d0e2b232d981084c73c9c6332486cbc039a54d68add842749c810a6f
BLAKE2b-256 checksum
How to use checksums
df2c65f7bcc446a263eb5a0b32916c6f37c71c1276c7ccd693cd01b9f9812eda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

Release files / python_viem-0.1.3-py3-none-any.whl

Download URL python_viem-0.1.3-py3-none-any.whl
Size 44.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b5adf8fa115caa838c4a2d4b1fb4bb37536c092bcd6c48b5a01f7620ad1990a9
BLAKE2b-256 checksum
How to use checksums
a74a0bca58cc111dff780fa944791fadd2a66b5942b2c88add2014a61aeba3e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page