This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
- Install dependencies:
uv sync --group dev
- Run all tests:
uv run pytest - Run specific test file:
uv run pytest tests/unit/test_client.py - Run e2e tests:
uv run pytest tests/e2e/ - Run with verbose output:
uv run pytest -v
- Build distribution:
uv build
- Semantic version release:
./scripts/semantic-version-release.sh - Verify upstream:
./scripts/verify-upstream.sh
GenLayerPY is a Python SDK for interacting with the GenLayer blockchain protocol. The codebase follows a modular architecture:
-
Client Layer (
genlayer_py/client/)GenLayerClient: Main client class that wraps web3.py functionalitycreate_client(): Factory function for client instantiation- Handles consensus smart contract initialization automatically
-
Chain Configuration (
genlayer_py/chains/)- Pre-configured chain objects (localnet, studionet, testnet_asimov, testnet_bradbury)
- Each chain includes RPC URLs, contract addresses, and consensus parameters
- Consensus contracts: CONSENSUS_MAIN and CONSENSUS_DATA with their ABIs
-
Account Management (
genlayer_py/accounts/)- Account creation and private key generation
- Integration with eth_account for signing operations
-
Transaction Handling (
genlayer_py/transactions/)- Transaction creation, signing, and submission
- Support for contract interactions (read/write operations)
- Built-in transaction receipt waiting with status checking
-
ABI and Encoding (
genlayer_py/abi/)- Calldata encoding/decoding utilities
- Transaction ABI handling
- Consensus-specific encoding for GenLayer protocol
-
Contract Utilities (
genlayer_py/contracts/)- Contract interaction helpers
- State status management (accepted, finalized)
- Chain Abstraction: All network configurations are encapsulated in chain objects
- Web3.py Integration: Built on top of web3.py for Ethereum compatibility
- Consensus Integration: Automatic initialization of consensus smart contracts
- Type Safety: Comprehensive type definitions in
genlayer_py/types/
- Unit Tests (
tests/unit/): Component-level testing for individual modules - E2E Tests (
tests/e2e/): Full integration tests against different networks - Test Configuration:
conftest.pysets up project root in Python path
Main SDK exports from genlayer_py/__init__.py:
create_client(): Primary client factorycreate_account(),generate_private_key(): Account utilities- All chain configurations via wildcard import
- The SDK is distributed via PyPI as
genlayer-py - Supports Python 3.12+ with web3.py as the core dependency
- Uses setuptools for packaging with automatic JSON ABI inclusion
- Semantic versioning with automated release scripts