chainledger-core
Neutral, read-only on-chain data over public BigQuery blockchain datasets. Address and flow metrics, token transfer history, contract detection, and activity-based wallet labeling -- built for developers who need factual on-chain data, not a compliance or risk-scoring product.
This library never returns a risk score, AML flag, or compliance judgment, and never will. See CONTRIBUTING.md for why that's a hard rule, not a style choice.
Install
pip install chainledger-core
Usage
from google.cloud import bigquery
from chainledger_core import ChainLedgerClient
bq = bigquery.Client() # needs BigQuery credentials + a project with
# billing enabled to run queries, even against
# the public dataset
client = ChainLedgerClient(bq)
metrics = client.address_flow_metrics(
"0x0000000000000000000000000000000000000000",
lookback_days=30,
max_bytes_billed=500_000_000, # required -- there is no unbounded default
)
print(metrics.tx_count_in, metrics.tx_count_out, metrics.unique_counterparties)
print(client.wallet_label(metrics)) # e.g. "moderate-frequency"
transfers = client.token_transfers("0x0000...", limit=25)
contract = client.contract_info("0x0000...")
The max_bytes_billed guardrail
Every query method takes max_bytes_billed and enforces it at the
BigQuery job-config level -- a query that would scan more than the
ceiling fails with MaxBytesBilledExceeded instead of silently running
up a bill. There's no method or code path that skips this.
The neutral-language guardrail
from chainledger_core import assert_neutral_language, NeutralLanguageViolation
try:
assert_neutral_language("This wallet has a high risk score.")
except NeutralLanguageViolation as e:
print(e.matched_terms) # ['risk score']
Run any AI-generated or templated text describing on-chain activity
through this before returning it to a user. chainledger_api's
/summarize endpoint does this on every response.
Schema note
Queries are written against the documented public schema of
bigquery-public-data.crypto_ethereum (transactions, token_transfers,
contracts). Confirm current column names against the live dataset
(bq show --schema bigquery-public-data:crypto_ethereum.transactions)
before a first production deploy -- public dataset schemas can drift.
Development
poetry install
poetry run pytest
poetry run ruff check src/ tests/
Tests run against a fake BigQuery client (see tests/test_client.py) --
no GCP credentials or network access needed to run the suite.
License
MIT. See LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 chainledger_core-0.1.0.tar.gz.
File metadata
- Download URL: chainledger_core-0.1.0.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea7fddca00d38640f6fd93f9a80d4e64f11889722094952da78333809fccf230
|
|
| MD5 |
6eecd98e090ad7dff17c79d7cef6a191
|
|
| BLAKE2b-256 |
3214ac2e33cbc3f05a869eb4afdd0adb7cf67c7882cd2bb868c3183fd4c652de
|
File details
Details for the file chainledger_core-0.1.0-py3-none-any.whl.
File metadata
- Download URL: chainledger_core-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea3098249fbc966b69dadc8c86f323ed9a70f0dd6082858102bbf45241f7454a
|
|
| MD5 |
febb6a28703ea25ac7635f3fff9cc31f
|
|
| BLAKE2b-256 |
5bcc834d98571a9a37016f8d6cad01188cd4e66229afa1c33a4fffc8ec5c5476
|