Skip to main content

Sentinel SDK

 Continuous Integration License python versions PyPI version

Sentinel SDK is a Python toolkit for extracting and working with Bittensor blockchain data. It provides a typed, versioned API for reading chain state — extrinsics, events, hyperparameters, metagraph snapshots, and subnet info — without dealing with raw substrate calls.

Features:

  • Blockchain data extraction — extrinsics, events, hyperparameters, metagraph snapshots, and subnet info with typed Pydantic DTOs
  • Pluggable providers — connect via the Bittensor SDK directly or through Pylon caching proxy
  • CLI — query chain data from the terminal (extrinsics, events, hyperparameters, metagraph)
  • Testing utilities — factories and a fake provider for writing tests without a live node (see docs/testing.md)
  • Versioned API — uses ApiVer (sentinel.v1) to guarantee backwards compatibility

Installation

pip install bittensor-sentinel

Usage

[!IMPORTANT] This package uses ApiVer, make sure to import sentinel.v1.

As a library

from sentinel.v1.providers.bittensor import bittensor_provider
from sentinel.v1.services.sentinel import sentinel_service

provider = bittensor_provider()
service = sentinel_service(provider)

# Extract extrinsics and events from a block
block = service.ingest_block(block_number=4_000_000)
for extrinsic in block.extrinsics:
    print(extrinsic.call.call_module, extrinsic.call.call_function)

# Extract metagraph snapshot for a subnet
subnet = service.ingest_subnet(netuid=1, block_number=4_000_000)
snapshot = subnet.metagraph
for neuron in snapshot.neurons:
    print(neuron.uid, neuron.neuron.hotkey.hotkey)

CLI

# Read extrinsics from a block
sentinel extrinsics --block 4000000

# Read events from a block
sentinel events --block 4000000

# Query subnet metagraph
sentinel subnet --netuid 1 metagraph

# JSON output
sentinel -f json extrinsics --block 4000000

Pylon provider

Pylon is a caching proxy for the Bittensor network that provides faster neuron and validator queries. Sentinel supports it as an alternative provider.

  1. Run a Pylon instance (see Pylon documentation).
  2. Set the environment variables (optional — PYLON_URL defaults to http://localhost:8000):
    export PYLON_URL="http://your-pylon-instance:8090"
    export PYLON_OPEN_ACCESS_TOKEN="your-token"  # only if Pylon requires authentication
    

Use PylonProvider as an alternative for the supported provider operations:

from sentinel.v1.providers.pylon import pylon_provider

# Uses PYLON_URL env var, or pass url directly
provider = pylon_provider(url="http://localhost:8090")

# Fetch metagraph (constructed from Pylon neuron data, always lite mode)
metagraph = provider.get_metagraph(netuid=1, block_number=100000, lite=True)

# Pylon-specific methods (not in the base BlockchainProvider interface)
neurons = provider.get_neurons(netuid=1, block_number=100000)
validators = provider.get_validators(netuid=1, block_number=100000)
latest = provider.get_latest_neurons(netuid=1)

[!NOTE] PylonProvider does not support full block info, block events, extrinsics listing or status, subnet hyperparameters, subnet registry listing (get_all_subnets_netuids), historical block timestamps (get_block_timestamp), or subnet emission state (get_subnet_emission_enabled). Unsupported event/extrinsic operations and the three named methods raise NotImplementedError; full block info and subnet hyperparameters return None. Use BittensorProvider for full chain access.

Or via CLI with the --provider pylon flag:

sentinel subnet --netuid 1 --provider pylon metagraph
sentinel subnet --netuid 1 --provider pylon --network http://my-pylon:8090 metagraph

Versioning

This package uses Semantic Versioning. TL;DR you are safe to use compatible release version specifier ~=MAJOR.MINOR in your pyproject.toml or requirements.txt.

Additionally, this package uses ApiVer to further reduce the risk of breaking changes. This means, the public API of this package is explicitly versioned, e.g. sentinel.v1, and will not change in a backwards-incompatible way even when sentinel.v2 is released.

Internal packages, i.e. prefixed by sentinel._ do not share these guarantees and may change in a backwards-incompatible way at any time even in patch releases.

Development

Pre-requisites:

Ideally, you should run nox -t format lint before every commit to ensure that the code is properly formatted and linted. Before submitting a PR, make sure that tests pass as well, you can do so using:

nox -t check # equivalent to `nox -t format lint test`

If you wish to install dependencies into .venv so your IDE can pick them up, you can do so using:

uv sync --all-extras --dev

Release process

Run nox -s make_release -- X.Y.Z where X.Y.Z is the version you're releasing and follow the printed instructions.

Download files

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

Source Distribution

bittensor_sentinel-0.2.6.tar.gz (203.0 kB view details)

Uploaded Source

Built Distribution

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

bittensor_sentinel-0.2.6-py3-none-any.whl (58.6 kB view details)

Uploaded Python 3

File details

Details for the file bittensor_sentinel-0.2.6.tar.gz.

File metadata

  • Download URL: bittensor_sentinel-0.2.6.tar.gz
  • Upload date:
  • Size: 203.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for bittensor_sentinel-0.2.6.tar.gz
Algorithm Hash digest
SHA256 40002f72f95b1968fd762cfbb4ebe8e5bf677b416c7fe672958746a0a40ac070
MD5 ddd3d779c4058748eee46fed5f6d350d
BLAKE2b-256 36e76fa1886ea2f86736ce472a12a69964506a8f1e008fad17c28dced9b087f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for bittensor_sentinel-0.2.6.tar.gz:

Publisher: publish.yml on bittensor-church/sentinel-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bittensor_sentinel-0.2.6-py3-none-any.whl.

File metadata

File hashes

Hashes for bittensor_sentinel-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 2596bc1aaf7cdc8603970c8094bd61ca42f4e9bf0c481db36842994daed56367
MD5 c32d4fd752b450f97dfe146b7d4222e7
BLAKE2b-256 55d2570a901e1fcb219a8b55ded1fee3cb8e3e41486ca9060842d27860fa70b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for bittensor_sentinel-0.2.6-py3-none-any.whl:

Publisher: publish.yml on bittensor-church/sentinel-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.2.6 This release

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.0

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

Supported by

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