Skip to main content

Python SDK for Chain Sentinel — Free token safety scanner across 9 blockchains

Project description

Chain Sentinel — Python SDK

PyPI version Python License: MIT

Official Python SDK for Chain Sentinel — Free token safety scanner across 9 blockchains.

Installation

pip install chain-sentinel

Quick Start

from chain_sentinel import ChainSentinel

# Free tier (no API key needed)
client = ChainSentinel()

# Scan a token
result = client.scan("0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82", chain="bsc")

print(result.summary)        # ✅ PancakeSwap Token (CAKE) — Score: 85/100 [SAFE]
print(result.safety_score)   # 85
print(result.is_honeypot)    # False
print(result.buy_tax)        # 0.0
print(result.is_safe)        # True

With API Key (Pro/Enterprise)

client = ChainSentinel(api_key="cs_your_api_key_here")

# Validate your key
info = client.validate_key()
print(f"Plan: {info['plan']}, Usage: {info['usage_count']}")

API Reference

Scanning

client.scan(address, chain="bsc") -> ScanResult

Scan a token for safety indicators.

Parameters:

  • address (str): Token contract address
  • chain (str): Blockchain network. Options: bsc, eth, base, arbitrum, polygon, avalanche, fantom, optimism, solana

Returns: ScanResult with fields:

  • safety_score (int): 0-100, higher is safer
  • risk_level (str): safe, caution, danger, critical
  • is_honeypot (bool): Can't sell if True
  • can_sell (bool): Whether selling is possible
  • buy_tax / sell_tax (float): Tax percentages
  • owner_renounced (bool): Contract ownership status
  • is_verified (bool): Source code verified
  • liquidity_locked (bool): LP locked status
  • price_usd, volume_24h, market_cap (float): Market data
  • warnings (list): Risk warnings found
  • positives (list): Positive indicators

Example:

result = client.scan("0xNewToken...", chain="base")

if result.is_honeypot:
    print("🚨 HONEYPOT — DO NOT BUY!")
elif result.safety_score < 50:
    print(f"🔴 High risk (score: {result.safety_score})")
elif result.buy_tax > 10:
    print(f"⚠️ High buy tax: {result.buy_tax}%")
else:
    print(f"✅ Looks safe — Score: {result.safety_score}")

Health Check

client.health() -> HealthResponse

health = client.health()
print(f"Status: {health.status}, Version: {health.version}")

Plans

client.get_plans() -> List[Plan]

plans = client.get_plans()
for plan in plans:
    print(f"{plan.name}: ${plan.price}/{plan.interval}")

Webhooks (Pro/Enterprise)

client.create_webhook(url, events, description) -> WebhookInfo

webhook = client.create_webhook(
    url="https://myapp.com/webhooks/chain-sentinel",
    events=["scan.complete", "scan.honeypot"],
    description="Production alerts"
)
print(f"Webhook ID: {webhook.id}")
print(f"Secret: {webhook.secret}")  # Save this for signature verification!

client.list_webhooks() -> List[WebhookInfo]

webhooks = client.list_webhooks()
for wh in webhooks:
    print(f"{wh.id}: {wh.url} ({wh.delivery_count} deliveries)")

client.test_webhook(webhook_id) -> dict

result = client.test_webhook("wh_abc123")
print(f"Status: {result['status']}")

client.delete_webhook(webhook_id)

client.delete_webhook("wh_abc123")

Error Handling

from chain_sentinel import (
    ChainSentinel,
    ChainSentinelError,
    RateLimitError,
    AuthenticationError,
    NotFoundError,
)

client = ChainSentinel()

try:
    result = client.scan("0xToken...")
except RateLimitError as e:
    print(f"Rate limited! Retry after {e.retry_after}s")
except AuthenticationError:
    print("Invalid API key")
except NotFoundError:
    print("Token not found")
except ChainSentinelError as e:
    print(f"Error: {e} (status: {e.status_code})")

Pre-Trade Safety Check

from chain_sentinel import ChainSentinel

def is_safe_to_buy(address: str, chain: str = "bsc",
                   min_score: int = 60, max_tax: float = 10.0) -> dict:
    """Check if a token is safe to buy."""
    client = ChainSentinel()
    result = client.scan(address, chain)

    if result.is_honeypot:
        return {"safe": False, "reason": "Honeypot detected"}

    if result.safety_score < min_score:
        return {"safe": False, "reason": f"Score {result.safety_score} < {min_score}"}

    if result.buy_tax > max_tax:
        return {"safe": False, "reason": f"Buy tax {result.buy_tax}% > {max_tax}%"}

    return {"safe": True, "reason": result.summary}

# Usage
check = is_safe_to_buy("0xNewToken...")
if check["safe"]:
    print(f"✅ {check['reason']}")
    # execute_buy()
else:
    print(f"❌ {check['reason']}")

Context Manager

with ChainSentinel(api_key="cs_key") as client:
    result = client.scan("0xToken...")
    print(result.summary)
# Client automatically closed

Requirements

  • Python 3.8+
  • httpx >= 0.24.0

Links

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

chain_sentinel-1.0.0.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

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

chain_sentinel-1.0.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file chain_sentinel-1.0.0.tar.gz.

File metadata

  • Download URL: chain_sentinel-1.0.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for chain_sentinel-1.0.0.tar.gz
Algorithm Hash digest
SHA256 40d027358b25ea78ad917e760bc0276dcf5d5a7239eda164249844c6c2e3540a
MD5 869169fe9c69f4713d8582f2c73d6249
BLAKE2b-256 ffa006a31eb4a448c8f7481536d67bc44e68503b0bd51609947a2f5cb451726e

See more details on using hashes here.

File details

Details for the file chain_sentinel-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: chain_sentinel-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for chain_sentinel-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 89b370362b13e082fe72b8a0b075481d4aefc8e5b9eafa9a5ad6d120b00e2631
MD5 c6140c225399d5c567e8974264ee2d23
BLAKE2b-256 035235dc8c5aad4c9dec3778fd712a5c19d304a2e5eca3d67516382dbf5aa83e

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