Hanzo Web3 SDK
Enterprise blockchain infrastructure SDK for Python. Multi-chain RPC, Token APIs, NFT APIs, Smart Wallets, Webhooks, and more.
Installation
pip install hanzo-web3
# Or with uv
uv add hanzo-web3
Quick Start
from hanzo_web3 import Client
# Initialize client
client = Client(api_key="hz_live_...")
# Get latest block number
block = client.rpc.eth_block_number(chain="ethereum")
print(f"Latest block: {block}")
# Get token balances
balances = client.tokens.get_balances("0x...", chain="polygon")
for token in balances:
print(f"{token['symbol']}: {token['balance_formatted']}")
# Get NFTs owned
nfts = client.nfts.get_owned("0x...", chain="ethereum")
for nft in nfts:
print(f"{nft['name']} #{nft['token_id']}")
Async Client
import asyncio
from hanzo_web3 import AsyncClient
async def main():
async with AsyncClient(api_key="hz_live_...") as client:
# Parallel requests
eth_block, polygon_block = await asyncio.gather(
client.rpc.eth_block_number(chain="ethereum"),
client.rpc.eth_block_number(chain="polygon"),
)
print(f"ETH: {eth_block}, Polygon: {polygon_block}")
asyncio.run(main())
Features
RPC API
Direct JSON-RPC access to 100+ chains:
# Any RPC method
result = client.rpc.call("eth_getBalance", ["0x...", "latest"], chain="ethereum")
# Convenience methods
balance = client.rpc.eth_get_balance("0x...", chain="ethereum")
Token API
ERC-20 token data:
# Get all token balances
balances = client.tokens.get_balances("0x...", chain="ethereum")
# Get token metadata
metadata = client.tokens.get_metadata("0xA0b8...", chain="ethereum")
NFT API
NFT collections and metadata:
# Get owned NFTs
nfts = client.nfts.get_owned("0x...", chain="ethereum")
# Get NFT metadata
metadata = client.nfts.get_metadata("0x...", "1234", chain="ethereum")
Smart Wallets (ERC-4337)
Account abstraction:
# Create smart wallet
wallet = client.wallets.create(owner="0x...", chain="base")
print(f"Smart wallet: {wallet['address']}")
# Get wallet details
info = client.wallets.get(wallet['address'], chain="base")
Webhooks
Real-time event notifications:
# Create webhook
webhook = client.webhooks.create(
url="https://your-server.com/webhook",
event_type="ADDRESS_ACTIVITY",
chain="ethereum",
filters={"addresses": ["0x..."]}
)
# List webhooks
webhooks = client.webhooks.list()
# Delete webhook
client.webhooks.delete(webhook["id"])
Supported Chains
| Chain | Networks |
|---|---|
| Ethereum | mainnet, sepolia, holesky |
| Polygon | mainnet, amoy |
| Arbitrum | mainnet, sepolia |
| Optimism | mainnet, sepolia |
| Base | mainnet, sepolia |
| Avalanche | mainnet, fuji |
| BNB Chain | mainnet, testnet |
| Lux | mainnet, testnet |
| Solana | mainnet, devnet |
| + 90 more | ... |
Environment Variables
# API Key (alternative to passing in code)
export HANZO_WEB3_API_KEY=hz_live_...
# Custom API URL (for white-label deployments)
export HANZO_WEB3_BASE_URL=https://api.lux.cloud
Error Handling
from hanzo_web3 import Client
from hanzo_web3.exceptions import (
AuthenticationError,
RateLimitError,
ChainNotSupportedError,
)
try:
client = Client(api_key="invalid")
client.rpc.eth_block_number()
except AuthenticationError:
print("Invalid API key")
except RateLimitError as e:
print(f"Rate limited. Retry after {e.retry_after}s")
except ChainNotSupportedError as e:
print(f"Chain {e.chain} not supported")
Links
License
Apache 2.0 - See LICENSE for details.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hanzo_web3-0.1.0.tar.gz
(7.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hanzo_web3-0.1.0.tar.gz.
File metadata
- Download URL: hanzo_web3-0.1.0.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
904f2ec2c099e61c3ca764b319ffe1fa3860ae2c8cccda9be39a0fe3c80d13ef
|
|
| MD5 |
871457ae50cbe01af6f6f64d250cb0e7
|
|
| BLAKE2b-256 |
38b9b8c12dc43b347ab22e61611370a22a67f717a5eba970e7401b623175c975
|
File details
Details for the file hanzo_web3-0.1.0-py3-none-any.whl.
File metadata
- Download URL: hanzo_web3-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d0149a10ee60da47366cbe4a5de568ba4f5468163b893bc830c308c311da39f
|
|
| MD5 |
6a9b710a793ffcf815a15549465a9038
|
|
| BLAKE2b-256 |
c5324e22261d223dc84d4536f0739fb287a2b658423ba0f60adfd6798615c5af
|