Skip to main content

Python library for managing Ethswarm smart contract deployment data across all versions and networks

Project description

ethswarm-deployments

Python library for managing Ethswarm smart contract deployment data across all versions and networks.

Overview

This library ingests Swarm smart contract deployment data from the ethersphere/storage-incentives GitHub repository and provides a clean Python interface for accessing deployment information across:

  • Multiple contract versions (v0.4.0 through v0.9.4+)
  • Multiple networks (mainnet, testnet)
  • Both legacy and hardhat-deploy format contracts

Features

  • Multi-network support: Query deployments on Gnosis Chain mainnet and Sepolia testnet
  • Version tracking: Access any version of deployed contracts
  • Backward compatible: Supports both legacy (staking) and canonical (StakeRegistry) contract names
  • Persistent caching: Local cache with block timestamp optimization
  • Rich metadata: Includes ABIs, bytecode, constructor args, and transaction hashes

Installation

pip install ethswarm-deployments

Quick Start

from ethswarm_deployments import DeploymentManager

# Initialize (uses cached data at ./.ethswarm-deployments/deployments.json)
mgr = DeploymentManager()

# Use a shared cache in your home directory instead of the project directory
mgr = DeploymentManager(location="user")  # ~/.cache/ethswarm-deployments

# Build the cache from GitHub on first use if it is missing
# (requires an RPC URL in the environment; see "Regenerating Cache" below)
mgr = DeploymentManager(auto_regenerate=True)

# Get latest deployment on mainnet (default)
deployment = mgr.deployment("StakeRegistry")
print(f"StakeRegistry at {deployment.address}")

# Get specific version on testnet
deployment = mgr.deployment("Redistribution", version="v0.9.2", network="testnet")

# List all versions
versions = mgr.versions()

# Get all deployments of a contract across versions
all_staking = mgr.all_deployments("StakeRegistry")

Cache Location

By default the cache lives in a project-local ./.ethswarm-deployments directory, so nothing is written to your home directory unless you ask for it.

To use a shared cache in your XDG cache home (~/.cache/ethswarm-deployments, or $XDG_CACHE_HOME/ethswarm-deployments):

from ethswarm_deployments import DeploymentManager

mgr = DeploymentManager(location="user")

Resolution precedence for the cache directory (first match wins):

  1. An explicit cache_dir= path argument.
  2. An explicit location= argument ("project" or "user").
  3. The ETHSWARM_DEPLOYMENTS_CACHE environment variable — set it to project, user, or a directory path.
  4. The default project location (./.ethswarm-deployments).

Regenerating Cache

If the cache is missing, DeploymentManager() raises CacheNotFoundError by default. Pass auto_regenerate=True to build it on demand instead (this requires an RPC URL in the environment and may take a while):

mgr = DeploymentManager(auto_regenerate=True)

The cache can also be regenerated explicitly from GitHub:

from ethswarm_deployments import regenerate_from_github

# Regenerate cache (requires RPC endpoints)
regenerate_from_github(
    mainnet_rpc_url="https://rpc.gnosischain.com",
    testnet_rpc_url="https://ethereum-sepolia-rpc.publicnode.com"
)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ethswarm_deployments-0.3.0.tar.gz (85.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ethswarm_deployments-0.3.0-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file ethswarm_deployments-0.3.0.tar.gz.

File metadata

  • Download URL: ethswarm_deployments-0.3.0.tar.gz
  • Upload date:
  • Size: 85.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for ethswarm_deployments-0.3.0.tar.gz
Algorithm Hash digest
SHA256 0703f8d4741cd5df238fbea5413e8e2d5cb7b4aea6709a57e9587829f8d1462d
MD5 e658427fbead7fd6091ca099c5b0e00d
BLAKE2b-256 c38306265ee804ff7ecb612e817a73c75d5b7508b2b5b62fdd6894318278fca0

See more details on using hashes here.

File details

Details for the file ethswarm_deployments-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ethswarm_deployments-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e4100c2e04b529fa7cfc3afcd7b9c9c514b1a54d802ce00006cb7cdd2438b900
MD5 5aad572cb76fdabd52a83831ed075908
BLAKE2b-256 031456fdfbe2bbef41f1b57c9ce28e0a31fa90f4973b628d07599d4d3683f47a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page