Skip to main content

healchain-sdk

Python SDK for HealChain — self-healing decentralized storage using Reed-Solomon erasure coding on Ethereum and Arbitrum.

Zero dependencies. Works with Python 3.8+.

Install

pip install healchain-sdk

Quick Start

from healchain import HealChain

hc = HealChain(api_url="https://api.healchain.org")

# Store data — blocks until oracle fulfills. The SDK stores unencrypted, so
# anyone can read this on chain: acknowledge_plaintext says you mean it.
result = hc.store("Hello World", label="my first record", acknowledge_plaintext=True)
print(f"Stored as record #{result['record_id']} on chain {result['chain_id']}")

# Retrieve — auto-discovers chain from GlobalRegistry
record = hc.retrieve(result["record_id"])
print(record["text"])  # Hello World

API

HealChain(api_url, **options)

Parameter Type Default Description
api_url str https://api.healchain.org API base URL
api_key str None Optional API key
network str 'sepolia' Default network: 'sepolia' or 'arbitrum'
poll_interval float 4.0 Seconds between oracle fulfillment polls
poll_timeout float 120.0 Max seconds to wait for fulfillment
data_shards int 10 Default RS data shards
parity_shards int 4 Default RS parity shards
timeout float 30.0 HTTP request timeout in seconds

hc.store(data, *, label, network, on_pending, on_fulfilled, acknowledge_plaintext)

Store data on-chain. Blocks until the oracle fulfills the request.

Parameters:

  • data — str or bytes
  • label — record label (default: 'sdk upload')
  • network — override network: 'sepolia' or 'arbitrum'
  • on_pending(info) — callback when tx is submitted
  • on_fulfilled(result) — callback when oracle fulfills
  • acknowledge_plaintext — must be True to store (default False; only True counts). store_file(), AsyncHealChain.store() and store_many() take the same option.

Returns:

{
    "record_id":    str,   # on-chain record ID
    "request_id":   str,   # oracle request ID
    "tx":           str,   # submission transaction hash
    "chain_id":     str,   # chain where data is stored
    "original_size": str,  # original size in bytes
    "encoded_size":  str,  # encoded shard size in bytes
    # when the server stored the data unencrypted:
    "plaintext":        True,
    "plaintext_notice": str,  # the server's fixed notice
}

Unencrypted stores must be acknowledged. This SDK sends your data unencrypted. Unencrypted data is publicly readable by anyone on chain and on IPFS, and cannot be removed from the blockchain. The server refuses an unencrypted store unless the request says so on purpose: without acknowledge_plaintext=True, store() raises HealChainError with status 400 and code 'PLAINTEXT_NOT_ACKNOWLEDGED'. Encrypt your data before storing it if it is not meant to be public. The label is always public.

Example with progress callbacks:

def on_pending(info):
    print(f"Submitted! request_id={info['request_id']}")

def on_fulfilled(result):
    print(f"Fulfilled! record_id={result['record_id']}")

result = hc.store(
    "important data",
    label="archive",
    network="arbitrum",      # ~75x cheaper than Sepolia
    on_pending=on_pending,
    on_fulfilled=on_fulfilled,
    acknowledge_plaintext=True,
)

Storing bytes:

with open("document.pdf", "rb") as f:
    result = hc.store(f.read(), label="my document", acknowledge_plaintext=True)

hc.retrieve(record_id)

Retrieve a record by ID. Automatically queries the GlobalRegistry to find which chain holds the data.

Returns:

{
    "record_id": str,
    "data":      str,   # hex-encoded original data (0x...)
    "text":      str,   # UTF-8 decoded text
    "bytes":     int,   # original data size
    "chain_id":  str,   # '11155111' (Sepolia) or '421614' (Arbitrum)
}

hc.get_metadata(record_id)

Fetch record metadata without retrieving the full data.

Returns: dict with label, owner, original_size, encoded_size, data_shards, parity_shards, timestamp, data_hash


hc.list(page=0, limit=10)

List records with pagination.

Returns:

{
    "records": list,   # record summaries
    "total":   int,    # total record count
    "pages":   int,    # total page count
    "page":    int,    # current page
    "limit":   int,    # records per page
}

hc.health()

Check service health.

Returns: dict with status, version, geth, lastBlock


Error Handling

from healchain import HealChain, HealChainError

hc = HealChain()

try:
    record = hc.retrieve(999999)
except HealChainError as e:
    print(e)           # human-readable message
    print(e.status)    # HTTP status code (int or None)
    print(e.code)      # the server's stable code, e.g. 'PLAINTEXT_NOT_ACKNOWLEDGED',
                       # or 'NETWORK_ERROR' | 'FULFILLMENT_TIMEOUT' | None
                       # check the code, never the message
    print(e.response)  # raw response body (dict or None)

Networks

Network Chain ID Notes
sepolia 11155111 Ethereum Sepolia testnet
arbitrum 421614 Arbitrum Sepolia testnet — ~75x cheaper gas

Retrieve works automatically regardless of which chain the data is on.


Async Usage

The SDK is synchronous by default. For async contexts use a thread executor:

import asyncio
from concurrent.futures import ThreadPoolExecutor
from healchain import HealChain

hc = HealChain()
executor = ThreadPoolExecutor()

async def store_async(data, label):
    loop = asyncio.get_event_loop()
    return await loop.run_in_executor(executor, lambda: hc.store(data, label=label, acknowledge_plaintext=True))

result = asyncio.run(store_async("Hello", label="async test"))

Async Usage (v0.2+)

Import AsyncHealChain for full async/await support:

import asyncio
from healchain import AsyncHealChain

async def main():
    async with AsyncHealChain(api_url="https://api.healchain.org") as hc:
        result = await hc.store("Hello World", label="my record", acknowledge_plaintext=True)
        record = await hc.retrieve(result["record_id"])
        print(record["text"])

asyncio.run(main())

Concurrent operations

async with AsyncHealChain() as hc:
    # Store multiple records concurrently
    results = await hc.store_many([
        ("Hello", "record 1"),
        ("World", "record 2"),
    ], concurrency=3, acknowledge_plaintext=True)

    # Retrieve multiple records concurrently
    records = await hc.retrieve_many([0, 1, 2, 3, 4], concurrency=5)

FastAPI integration

from fastapi import FastAPI
from healchain import AsyncHealChain

app = FastAPI()
hc  = AsyncHealChain(api_url="https://api.healchain.org")

@app.get("/retrieve/{record_id}")
async def retrieve(record_id: int):
    return await hc.retrieve(record_id)

Roadmap

  • v0.1 — REST API client ✅
  • v0.2 — Async support + concurrent store_many/retrieve_many ✅
  • v0.3 — Streaming large file support
  • v1.0 — Mainnet support

Chain Chain ID Contract Status
Sepolia 11155111 0x21659D0df6Ffd35574D2B2D5Ed193747F79Bf705 ✅ v2 + 1MB cap
Arbitrum Sepolia 421614 0x5723713479b1F391e1F33962d310274e05E6AA18 ✅ v2 + 1MB cap
Jasmy Testnet 681 0x4E339437e674fcA7D37E95c3306ACAd8a6175868 ✅ v2 + 1MB cap
Optimism Sepolia 11155420 0x07B3F16865d4E993E1102E1ca8A4e5199169E9DE ✅ v2 + 1MB cap
Base Sepolia 84532 0x4E339437e674fcA7D37E95c3306ACAd8a6175868 ✅ v2 + 1MB cap
Unichain Sepolia 1301 0xBffb39930647DBB5971690ea6e9F0CF393307e64 ✅ v2 + 1MB cap
Avalanche Fuji 43113 0x91d3440023A9dAdF62E2a43CcC85Da5B427dd26f ✅ v2 + 1MB cap
Plume Testnet 98867 0xcBa6D4606A311f0a99fE62A24b94a3DBAC39f189 ✅ v2 + 1MB cap
Sonic Testnet 57054 0x91d3440023A9dAdF62E2a43CcC85Da5B427dd26f ✅ v2 + 1MB cap
XDC Apothem 51 0x91d3440023A9dAdF62E2a43CcC85Da5B427dd26f ✅ v2 + 1MB cap
XRPL EVM Testnet 1449000 0x9372379beb8fFf7E18d71375e842E3e8c126d944 ✅ v2 + 1MB cap
Hedera Testnet 296 0xA97709EB4fF8a441D8Ea653ae7472f2652B2D580 ✅ v2 + 1MB cap
Linea Sepolia 59141 Pending ⏳ Awaiting faucet

License

MIT


Built on HealChain · GitHub

Metadata

Release files for healchain-sdk 1.3.0

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

Source distribution (sdist)

Source distribution for healchain-sdk 1.3.0
File Size Uploaded Provenance Actions
healchain_sdk-1.3.0.tar.gz 22.0 kB Without provenance Details for healchain_sdk-1.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for healchain-sdk 1.3.0
File Interpreter ABI Platform Actions
healchain_sdk-1.3.0-py3-none-any.whl Python 3 none any Details for healchain_sdk-1.3.0-py3-none-any.whl

Total release size: 40.0 kB

Release files / healchain_sdk-1.3.0.tar.gz

Download URL healchain_sdk-1.3.0.tar.gz
Size 22.0 kB
Tags Source
SHA-256 checksum
How to use checksums
11d6c324a654843da5c774ba1ffa37a928cd4c336d19b975793adef699656498
BLAKE2b-256 checksum
How to use checksums
735b23a938ff124a2f8ad63ad70250abb1e97fde2f5663eb6c4e283e4fb9270a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.14

Release files / healchain_sdk-1.3.0-py3-none-any.whl

Download URL healchain_sdk-1.3.0-py3-none-any.whl
Size 18.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1f058085094819aa2b981cc28eb2c1a8944f932ee6433100ad0f55048d81d7e3
BLAKE2b-256 checksum
How to use checksums
4c0a7a08841f1e381877c81681a8c76277cba55129937780704c03f090c8e451
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.14

Security for healchain-sdk 1.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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