Skip to main content

four-life

Python SDK for the FOUR-LIFE Certified trust layer — Four.meme token grading, risk snapshots, creator scores, protection mode, and signed webhooks.

Zero runtime magic. Pure HTTP + HMAC. Works in any Python 3.9+ runtime.

Install

pip install four-life

Quick start

from four_life import FourLife

fl = FourLife()

# Deterministic trust tier for any Four.meme token
badge = fl.get_badge("0xabc...")
print(badge["badge"]["tier"])            # "graduation_watch"
print(badge["badge"]["why"][0]["rule"])  # "curve_advanced"

# Live Graduation Radar
radar = fl.get_graduation_radar(limit=20, min_confidence="high")
for entry in radar["radar"]:
    print(entry["symbol"], entry["confidence_score"], entry["graduation_probability"])

# Creator ledger — survival rate across every tracked launch
score = fl.get_creator_score("0xcreator...")
print(score["trust_tier"], score["graduation_rate"])

Async

import asyncio
from four_life import AsyncFourLife

async def main():
    async with AsyncFourLife() as fl:
        badge = await fl.get_badge("0xabc...")
        print(badge["badge"]["tier"])

asyncio.run(main())

Write endpoints (require an API_SECRET bearer token)

fl = FourLife(api_secret="your-deployment-secret")

# Track a token you just launched
fl.track_token(
    token_address="0xabc...",
    name="My Token",
    symbol="MYT",
    quote_asset="BNB",
)

# Configure Protection Mode with stricter defaults
fl.set_protection_policy(
    "0xabc...",
    max_whale_concentration=25.0,
    critical_contract_risk=50,
)

# Create a webhook subscription — the secret is returned ONCE
sub = fl.create_webhook(
    url="https://your-service/fourlife-webhook",
    events=["badge.tier_changed", "protection.level_changed"],
)
secret = sub["secret"]  # store this now; it is not retrievable later

Verify webhook signatures

from four_life import verify_webhook_signature

# Inside your HTTP handler
def handle(request):
    body = request.get_data(as_text=True)          # RAW body, not parsed JSON
    header = request.headers["X-FourLife-Signature"]
    if not verify_webhook_signature(
        secret=MY_SECRET,
        body=body,
        signature_header=header,
    ):
        return ("bad signature", 401)
    # ...dispatch the event...
    return ("ok", 200)

History + replay

# Every snapshot ever recorded for a token
history = fl.get_history("0xabc...", limit=100)
for snap in history["snapshots"]:
    print(snap["recorded_at"], snap["tier"])

# Only the boundary rows (tier actually changed)
transitions = fl.get_history("0xabc...", transitions_only=True)

# Diff since timestamp
diff = fl.get_diff("0xabc...", since=1776000000)
print(diff["tier_changes"])

# Bulk export — streams NDJSON for large backfills
for snap in fl.iter_history_export():
    process(snap)

Watch a token (poll-based, sync)

def on_change(badge):
    print("tier:", badge["badge"]["tier"])

unwatch = fl.watch_token("0xabc...", on_change, interval_seconds=60)
# ... later
unwatch()

Full surface

Method Endpoint
get_badge(addr) GET /api/token/{addr}/badge
get_risk_snapshot(addr) GET /api/token/{addr}/risk-snapshot
get_operator_checklist(addr) GET /api/token/{addr}/operator-checklist
get_contract_risk(addr) GET /api/token/{addr}/contract-risk
get_health_score(addr) GET /api/health-score/{addr}
get_graduation_radar(...) GET /api/graduation-radar
get_platform_cohorts() GET /api/platform/cohorts
get_creator_score(wallet) GET /api/creator/{wallet}/survival-score
get_creators_leaderboard(...) GET /api/creators/leaderboard
get_identity() GET /api/identity
get_dgrid_stats() GET /api/dgrid/stats
get_history(addr, ...) GET /api/token/{addr}/history
get_diff(addr, since=...) GET /api/token/{addr}/diff
get_tokens_with_history() GET /api/history/tokens
iter_history_export(...) GET /api/history/export.ndjson (streaming)
get_protection_policy(addr) GET /api/protection/{addr}
set_protection_policy(addr, ...) PUT /api/protection/{addr} (auth)
delete_protection_policy(addr) DELETE /api/protection/{addr} (auth)
list_protection_policies() GET /api/protection
create_webhook(url=..., events=...) POST /api/webhooks (auth)
list_webhooks() GET /api/webhooks (auth)
delete_webhook(id) DELETE /api/webhooks/{id} (auth)
list_webhook_deliveries(id) GET /api/webhooks/{id}/deliveries (auth)
get_notifications_status() GET /api/notifications/status
send_test_notification() POST /api/notifications/test (auth)
track_token(...) POST /api/agent/track (auth)
generate_raise_plan(addr) POST /api/raise-plan/{addr}
watch_token(addr, cb) 60s poll on get_badge, returns unwatch()

Every method has an awaitable AsyncFourLife equivalent with identical arguments.

License

MIT.

Metadata

Release files for four-life 0.1.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 four-life 0.1.0
File Size Uploaded Provenance Actions
four_life-0.1.0.tar.gz 15.5 kB Without provenance Details for four_life-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for four-life 0.1.0
File Interpreter ABI Platform Actions
four_life-0.1.0-py3-none-any.whl Python 3 none any Details for four_life-0.1.0-py3-none-any.whl

Total release size: 27.0 kB

Release files / four_life-0.1.0.tar.gz

Download URL four_life-0.1.0.tar.gz
Size 15.5 kB
Tags Source
SHA-256 checksum
How to use checksums
3b2d60fb0e1ae2063277d7057cbebae7cf96bca47db205f907a8af0cd78dfd87
BLAKE2b-256 checksum
How to use checksums
1ed83934aeed7c56ae00c99125244da9b77fe2f65070aa5fda26ff54a773366b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / four_life-0.1.0-py3-none-any.whl

Download URL four_life-0.1.0-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d9a8bb0364d6cd2f07aba8e1560321b2884e141ab956a708df66852cda86ced5
BLAKE2b-256 checksum
How to use checksums
53bbe6e40d6aa954546affbefda7df323be88bcedf7a8020c78e434098ed6f91
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Security for four-life 0.1.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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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